1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Use StringSwitch instead of long chain of if-else. No functionality change.

llvm-svn: 179682
This commit is contained in:
Alexey Samsonov 2013-04-17 14:27:04 +00:00
parent 542f535116
commit 7abfd15675

View File

@ -9,6 +9,7 @@
#include "DWARFContext.h" #include "DWARFContext.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
@ -495,49 +496,39 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
i->getContents(data); i->getContents(data);
name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes. name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.
if (name == "debug_info")
InfoSection = data; StringRef *Section = StringSwitch<StringRef*>(name)
else if (name == "debug_abbrev") .Case("debug_info", &InfoSection)
AbbrevSection = data; .Case("debug_abbrev", &AbbrevSection)
else if (name == "debug_line") .Case("debug_line", &LineSection)
LineSection = data; .Case("debug_aranges", &ARangeSection)
else if (name == "debug_aranges") .Case("debug_frame", &DebugFrameSection)
ARangeSection = data; .Case("debug_str", &StringSection)
else if (name == "debug_frame") .Case("debug_ranges", &RangeSection)
DebugFrameSection = data; .Case("debug_pubnames", &PubNamesSection)
else if (name == "debug_str") .Case("debug_info.dwo", &InfoDWOSection)
StringSection = data; .Case("debug_abbrev.dwo", &AbbrevDWOSection)
else if (name == "debug_ranges") { .Case("debug_str.dwo", &StringDWOSection)
.Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
.Case("debug_addr", &AddrSection)
// Any more debug info sections go here.
.Default(0);
if (!Section)
continue;
*Section = data;
if (name == "debug_ranges") {
// FIXME: Use the other dwo range section when we emit it. // FIXME: Use the other dwo range section when we emit it.
RangeDWOSection = data; RangeDWOSection = data;
RangeSection = data;
} }
else if (name == "debug_pubnames")
PubNamesSection = data;
else if (name == "debug_info.dwo")
InfoDWOSection = data;
else if (name == "debug_abbrev.dwo")
AbbrevDWOSection = data;
else if (name == "debug_str.dwo")
StringDWOSection = data;
else if (name == "debug_str_offsets.dwo")
StringOffsetDWOSection = data;
else if (name == "debug_addr")
AddrSection = data;
// Any more debug info sections go here.
else
continue;
// TODO: Add support for relocations in other sections as needed. // TODO: Add support for relocations in other sections as needed.
// Record relocations for the debug_info and debug_line sections. // Record relocations for the debug_info and debug_line sections.
RelocAddrMap *Map; RelocAddrMap *Map = StringSwitch<RelocAddrMap*>(name)
if (name == "debug_info") .Case("debug_info", &InfoRelocMap)
Map = &InfoRelocMap; .Case("debug_info.dwo", &InfoDWORelocMap)
else if (name == "debug_info.dwo") .Case("debug_line", &LineRelocMap)
Map = &InfoDWORelocMap; .Default(0);
else if (name == "debug_line") if (!Map)
Map = &LineRelocMap;
else
continue; continue;
if (i->begin_relocations() != i->end_relocations()) { if (i->begin_relocations() != i->end_relocations()) {