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>
parseDebugTableName(llvm::StringRef SecName)16 llvm::dwarf_linker::parseDebugTableName(llvm::StringRef SecName) {
17   return llvm::StringSwitch<std::optional<DebugSectionKind>>(
18              SecName.substr(SecName.find_first_not_of("._")))
19       .Case(getSectionName(DebugSectionKind::DebugInfo),
20             DebugSectionKind::DebugInfo)
21       .Case(getSectionName(DebugSectionKind::DebugLine),
22             DebugSectionKind::DebugLine)
23       .Case(getSectionName(DebugSectionKind::DebugFrame),
24             DebugSectionKind::DebugFrame)
25       .Case(getSectionName(DebugSectionKind::DebugRange),
26             DebugSectionKind::DebugRange)
27       .Case(getSectionName(DebugSectionKind::DebugRngLists),
28             DebugSectionKind::DebugRngLists)
29       .Case(getSectionName(DebugSectionKind::DebugLoc),
30             DebugSectionKind::DebugLoc)
31       .Case(getSectionName(DebugSectionKind::DebugLocLists),
32             DebugSectionKind::DebugLocLists)
33       .Case(getSectionName(DebugSectionKind::DebugARanges),
34             DebugSectionKind::DebugARanges)
35       .Case(getSectionName(DebugSectionKind::DebugAbbrev),
36             DebugSectionKind::DebugAbbrev)
37       .Case(getSectionName(DebugSectionKind::DebugMacinfo),
38             DebugSectionKind::DebugMacinfo)
39       .Case(getSectionName(DebugSectionKind::DebugMacro),
40             DebugSectionKind::DebugMacro)
41       .Case(getSectionName(DebugSectionKind::DebugAddr),
42             DebugSectionKind::DebugAddr)
43       .Case(getSectionName(DebugSectionKind::DebugStr),
44             DebugSectionKind::DebugStr)
45       .Case(getSectionName(DebugSectionKind::DebugLineStr),
46             DebugSectionKind::DebugLineStr)
47       .Case(getSectionName(DebugSectionKind::DebugStrOffsets),
48             DebugSectionKind::DebugStrOffsets)
49       .Case(getSectionName(DebugSectionKind::DebugPubNames),
50             DebugSectionKind::DebugPubNames)
51       .Case(getSectionName(DebugSectionKind::DebugPubTypes),
52             DebugSectionKind::DebugPubTypes)
53       .Case(getSectionName(DebugSectionKind::DebugNames),
54             DebugSectionKind::DebugNames)
55       .Case(getSectionName(DebugSectionKind::AppleNames),
56             DebugSectionKind::AppleNames)
57       .Case(getSectionName(DebugSectionKind::AppleNamespaces),
58             DebugSectionKind::AppleNamespaces)
59       .Case(getSectionName(DebugSectionKind::AppleObjC),
60             DebugSectionKind::AppleObjC)
61       .Case(getSectionName(DebugSectionKind::AppleTypes),
62             DebugSectionKind::AppleTypes)
63       .Default(std::nullopt);
64 }
65