[llvm-commits] [lld] r158547 - in /lld/trunk/lib/ReaderWriter/MachO: ReferenceKinds.cpp ReferenceKinds.h
Nick Kledzik
kledzik at apple.com
Fri Jun 15 14:26:18 PDT 2012
Author: kledzik
Date: Fri Jun 15 16:26:18 2012
New Revision: 158547
URL: http://llvm.org/viewvc/llvm-project?rev=158547&view=rev
Log:
Add 'invalid' as a Reference Kind so that unknown/invalid kind strings can return that fact to the caller for use in constructing an error message, rather that triggering an assertion.
Modified:
lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp
lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.h
Modified: lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp?rev=158547&r1=158546&r2=158547&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp Fri Jun 15 16:26:18 2012
@@ -71,13 +71,16 @@
.Case("lazyTarget", lazyTarget)
.Case("lazyImmediate", lazyImmediate)
.Case("subordinateFDE", subordinateFDE)
- .Case("subordinateLSDA", subordinateLSDA);
+ .Case("subordinateLSDA", subordinateLSDA)
+ .Default(invalid);
llvm_unreachable("invalid x86_64 Reference kind");
}
StringRef KindHandler_x86_64::kindToString(Reference::Kind kind) {
switch ( (Kinds)kind ) {
+ case invalid:
+ return StringRef("invalid");
case none:
return StringRef("none");
case branch32:
@@ -175,6 +178,9 @@
case subordinateLSDA:
// do nothing
break;
+ case invalid:
+ assert(0 && "invalid Reference Kind");
+ break;
}
}
@@ -194,13 +200,16 @@
.Case("funcRel32", funcRel32)
.Case("pointer32", pointer32)
.Case("lazyTarget", lazyTarget)
- .Case("lazyImmediate", lazyImmediate);
+ .Case("lazyImmediate", lazyImmediate)
+ .Default(invalid);
llvm_unreachable("invalid x86 Reference kind");
}
StringRef KindHandler_x86::kindToString(Reference::Kind kind) {
switch ( (Kinds)kind ) {
+ case invalid:
+ return StringRef("invalid");
case none:
return StringRef("none");
case branch32:
@@ -263,6 +272,9 @@
case subordinateLSDA:
// do nothing
break;
+ case invalid:
+ assert(0 && "invalid Reference Kind");
+ break;
}
}
@@ -287,13 +299,16 @@
.Case("pointer32", pointer32)
.Case("lazyTarget", lazyTarget)
.Case("lazyImmediate", lazyImmediate)
- .Case("subordinateLSDA", subordinateLSDA);
+ .Case("subordinateLSDA", subordinateLSDA)
+ .Default(invalid);
llvm_unreachable("invalid ARM Reference kind");
}
StringRef KindHandler_arm::kindToString(Reference::Kind kind) {
switch ( (Kinds)kind ) {
+ case invalid:
+ return StringRef("invalid");
case none:
return StringRef("none");
case thumbBranch22:
@@ -375,6 +390,9 @@
case subordinateLSDA:
// do nothing
break;
+ case invalid:
+ assert(0 && "invalid Reference Kind");
+ break;
}
}
Modified: lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.h?rev=158547&r1=158546&r2=158547&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.h Fri Jun 15 16:26:18 2012
@@ -48,6 +48,7 @@
class KindHandler_x86_64 : public KindHandler {
public:
enum Kinds {
+ invalid, // used to denote an error creating a Reference
none,
branch32, // CALL or JMP 32-bit pc-rel
ripRel32, // RIP-rel access pc-rel to fix up location
@@ -83,6 +84,7 @@
class KindHandler_x86 : public KindHandler {
public:
enum Kinds {
+ invalid, // used to denote an error creating a Reference
none,
branch32, // CALL or JMP 32-bit pc-rel
abs32, // 32-bit absolute address embedded in instruction
@@ -109,6 +111,7 @@
class KindHandler_arm : public KindHandler {
public:
enum Kinds {
+ invalid, // used to denote an error creating a Reference
none,
thumbBranch22, // thumb b or bl with 22/24-bits of displacement
armBranch24, // arm b or bl with 24-bits of displacement
More information about the llvm-commits
mailing list