Use ADT/StringSwitch

llvm-svn: 158541
This commit is contained in:
Nick Kledzik 2012-06-15 20:29:27 +00:00
parent 8370c7c38f
commit d6a27324f9
1 changed files with 41 additions and 73 deletions
lld/lib/ReaderWriter/MachO

View File

@ -11,6 +11,7 @@
#include "ReferenceKinds.h" #include "ReferenceKinds.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
namespace lld { namespace lld {
@ -52,41 +53,25 @@ KindHandler_x86_64::~KindHandler_x86_64() {
} }
Reference::Kind KindHandler_x86_64::stringToKind(StringRef str) { Reference::Kind KindHandler_x86_64::stringToKind(StringRef str) {
if ( str.equals("none") ) return llvm::StringSwitch<Reference::Kind>(str)
return none; .Case("none", none)
else if ( str.equals("branch32") ) .Case("branch32", branch32)
return branch32; .Case("ripRel32", ripRel32)
else if ( str.equals("ripRel32") ) .Case("ripRel32_1", ripRel32_1)
return ripRel32; .Case("ripRel32_2", ripRel32_2)
else if ( str.equals("ripRel32_1") ) .Case("ripRel32_4", ripRel32_4)
return ripRel32_1; .Case("gotLoadRipRel32", gotLoadRipRel32)
else if ( str.equals("ripRel32_2") ) .Case("gotLoadRipRel32NowLea", gotLoadRipRel32NowLea)
return ripRel32_2; .Case("gotUseRipRel32", gotUseRipRel32)
else if ( str.equals("ripRel32_4") ) .Case("tlvLoadRipRel32", tlvLoadRipRel32)
return ripRel32_4; .Case("tlvLoadRipRel32NowLea", tlvLoadRipRel32NowLea)
else if ( str.equals("gotLoadRipRel32") ) .Case("pointer64", pointer64)
return gotLoadRipRel32; .Case("pointerRel32", pointerRel32)
else if ( str.equals("gotLoadRipRel32NowLea") ) .Case("lazyTarget", lazyTarget)
return gotLoadRipRel32NowLea; .Case("lazyImmediate", lazyImmediate)
else if ( str.equals("gotUseRipRel32") ) .Case("subordinateFDE", subordinateFDE)
return gotUseRipRel32; .Case("subordinateLSDA", subordinateLSDA);
else if ( str.equals("tlvLoadRipRel32") )
return tlvLoadRipRel32;
else if ( str.equals("tlvLoadRipRel32NowLea") )
return tlvLoadRipRel32NowLea;
else if ( str.equals("pointer64") )
return pointer64;
else if ( str.equals("pointerRel32") )
return pointerRel32;
else if ( str.equals("lazyTarget") )
return lazyTarget;
else if ( str.equals("lazyImmediate") )
return lazyImmediate;
else if ( str.equals("subordinateFDE") )
return subordinateFDE;
else if ( str.equals("subordinateLSDA") )
return subordinateLSDA;
assert(0 && "invalid x86_64 Reference kind"); assert(0 && "invalid x86_64 Reference kind");
return 0; return 0;
} }
@ -203,20 +188,14 @@ KindHandler_x86::~KindHandler_x86() {
} }
Reference::Kind KindHandler_x86::stringToKind(StringRef str) { Reference::Kind KindHandler_x86::stringToKind(StringRef str) {
if ( str.equals("none") ) return llvm::StringSwitch<Reference::Kind>(str)
return none; .Case("none", none)
else if ( str.equals("branch32") ) .Case("branch32", branch32)
return branch32; .Case("abs32", abs32)
else if ( str.equals("abs32") ) .Case("funcRel32", funcRel32)
return abs32; .Case("pointer32", pointer32)
else if ( str.equals("funcRel32") ) .Case("lazyTarget", lazyTarget)
return funcRel32; .Case("lazyImmediate", lazyImmediate);
else if ( str.equals("pointer32") )
return pointer32;
else if ( str.equals("lazyTarget") )
return lazyTarget;
else if ( str.equals("lazyImmediate") )
return lazyImmediate;
assert(0 && "invalid x86 Reference kind"); assert(0 && "invalid x86 Reference kind");
return 0; return 0;
@ -299,30 +278,19 @@ KindHandler_arm::~KindHandler_arm() {
} }
Reference::Kind KindHandler_arm::stringToKind(StringRef str) { Reference::Kind KindHandler_arm::stringToKind(StringRef str) {
if ( str.equals("none") ) return llvm::StringSwitch<Reference::Kind>(str)
return none; .Case("none", none)
else if ( str.equals("thumbBranch22") ) .Case("thumbBranch22", thumbBranch22)
return thumbBranch22; .Case("armBranch24", armBranch24)
else if ( str.equals("armBranch24") ) .Case("thumbAbsLow16", thumbAbsLow16)
return armBranch24; .Case("thumbAbsHigh16", thumbAbsHigh16)
else if ( str.equals("thumbAbsLow16") ) .Case("thumbPcRelLow16", thumbPcRelLow16)
return thumbAbsLow16; .Case("thumbPcRelHigh16", thumbPcRelHigh16)
else if ( str.equals("thumbAbsHigh16") ) .Case("abs32", abs32)
return thumbAbsHigh16; .Case("pointer32", pointer32)
else if ( str.equals("thumbPcRelLow16") ) .Case("lazyTarget", lazyTarget)
return thumbPcRelLow16; .Case("lazyImmediate", lazyImmediate)
else if ( str.equals("thumbPcRelHigh16") ) .Case("subordinateLSDA", subordinateLSDA);
return thumbPcRelHigh16;
else if ( str.equals("abs32") )
return abs32;
else if ( str.equals("pointer32") )
return pointer32;
else if ( str.equals("lazyTarget") )
return lazyTarget;
else if ( str.equals("lazyImmediate") )
return lazyImmediate;
else if ( str.equals("subordinateLSDA") )
return subordinateLSDA;
assert(0 && "invalid ARM Reference kind"); assert(0 && "invalid ARM Reference kind");
return 0; return 0;