1 | //=== DWARFLinkerBase.cpp -------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "llvm/DWARFLinker/DWARFLinkerBase.h" |
10 | #include "llvm/ADT/StringSwitch.h" |
11 | |
12 | using namespace llvm; |
13 | using namespace llvm::dwarf_linker; |
14 | |
15 | std::optional<DebugSectionKind> |
16 | llvm::dwarf_linker::parseDebugTableName(llvm::StringRef SecName) { |
17 | return llvm::StringSwitch<std::optional<DebugSectionKind>>( |
18 | SecName.substr(Start: SecName.find_first_not_of(Chars: "._" ))) |
19 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugInfo), |
20 | Value: DebugSectionKind::DebugInfo) |
21 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugLine), |
22 | Value: DebugSectionKind::DebugLine) |
23 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugFrame), |
24 | Value: DebugSectionKind::DebugFrame) |
25 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugRange), |
26 | Value: DebugSectionKind::DebugRange) |
27 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugRngLists), |
28 | Value: DebugSectionKind::DebugRngLists) |
29 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugLoc), |
30 | Value: DebugSectionKind::DebugLoc) |
31 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugLocLists), |
32 | Value: DebugSectionKind::DebugLocLists) |
33 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugARanges), |
34 | Value: DebugSectionKind::DebugARanges) |
35 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugAbbrev), |
36 | Value: DebugSectionKind::DebugAbbrev) |
37 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugMacinfo), |
38 | Value: DebugSectionKind::DebugMacinfo) |
39 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugMacro), |
40 | Value: DebugSectionKind::DebugMacro) |
41 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugAddr), |
42 | Value: DebugSectionKind::DebugAddr) |
43 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugStr), |
44 | Value: DebugSectionKind::DebugStr) |
45 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugLineStr), |
46 | Value: DebugSectionKind::DebugLineStr) |
47 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugStrOffsets), |
48 | Value: DebugSectionKind::DebugStrOffsets) |
49 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugPubNames), |
50 | Value: DebugSectionKind::DebugPubNames) |
51 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugPubTypes), |
52 | Value: DebugSectionKind::DebugPubTypes) |
53 | .Case(S: getSectionName(SectionKind: DebugSectionKind::DebugNames), |
54 | Value: DebugSectionKind::DebugNames) |
55 | .Case(S: getSectionName(SectionKind: DebugSectionKind::AppleNames), |
56 | Value: DebugSectionKind::AppleNames) |
57 | .Case(S: getSectionName(SectionKind: DebugSectionKind::AppleNamespaces), |
58 | Value: DebugSectionKind::AppleNamespaces) |
59 | .Case(S: getSectionName(SectionKind: DebugSectionKind::AppleObjC), |
60 | Value: DebugSectionKind::AppleObjC) |
61 | .Case(S: getSectionName(SectionKind: DebugSectionKind::AppleTypes), |
62 | Value: DebugSectionKind::AppleTypes) |
63 | .Default(Value: std::nullopt); |
64 | } |
65 | |