[llvm-commits] [lld] r158542 - in /lld/trunk/lib: Core/Resolver.cpp ReaderWriter/MachO/ReferenceKinds.cpp ReaderWriter/MachO/SimpleAtoms.hpp ReaderWriter/MachO/WriterOptionsMachO.cpp
Nick Kledzik
kledzik at apple.com
Fri Jun 15 13:37:25 PDT 2012
Author: kledzik
Date: Fri Jun 15 15:37:24 2012
New Revision: 158542
URL: http://llvm.org/viewvc/llvm-project?rev=158542&view=rev
Log:
use llvm_unreachable() instead of assert(0) for invalid enum values in switch statements
Modified:
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp
lld/trunk/lib/ReaderWriter/MachO/SimpleAtoms.hpp
lld/trunk/lib/ReaderWriter/MachO/WriterOptionsMachO.cpp
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=158542&r1=158541&r2=158542&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Fri Jun 15 15:37:24 2012
@@ -359,7 +359,7 @@
} else if (const AbsoluteAtom* abAtom = dyn_cast<AbsoluteAtom>(&atom)) {
_absoluteAtoms._atoms.push_back(abAtom);
} else {
- assert(0 && "atom has unknown definition kind");
+ llvm_unreachable("atom has unknown definition kind");
}
}
Modified: lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp?rev=158542&r1=158541&r2=158542&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp Fri Jun 15 15:37:24 2012
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ErrorHandling.h"
namespace lld {
namespace mach_o {
@@ -72,7 +73,7 @@
.Case("subordinateFDE", subordinateFDE)
.Case("subordinateLSDA", subordinateLSDA);
- assert(0 && "invalid x86_64 Reference kind");
+ llvm_unreachable("invalid x86_64 Reference kind");
return 0;
}
@@ -113,7 +114,7 @@
case subordinateLSDA:
return StringRef("subordinateLSDA");
}
- assert(0 && "invalid x86_64 Reference kind");
+ llvm_unreachable("invalid x86_64 Reference kind");
return StringRef();
}
@@ -197,7 +198,7 @@
.Case("lazyTarget", lazyTarget)
.Case("lazyImmediate", lazyImmediate);
- assert(0 && "invalid x86 Reference kind");
+ llvm_unreachable("invalid x86 Reference kind");
return 0;
}
@@ -222,7 +223,7 @@
case subordinateLSDA:
return StringRef("subordinateLSDA");
}
- assert(0 && "invalid x86 Reference kind");
+ llvm_unreachable("invalid x86 Reference kind");
return StringRef();
}
@@ -292,7 +293,7 @@
.Case("lazyImmediate", lazyImmediate)
.Case("subordinateLSDA", subordinateLSDA);
- assert(0 && "invalid ARM Reference kind");
+ llvm_unreachable("invalid ARM Reference kind");
return 0;
}
@@ -323,7 +324,7 @@
case subordinateLSDA:
return StringRef("subordinateLSDA");
}
- assert(0 && "invalid ARM Reference kind");
+ llvm_unreachable("invalid ARM Reference kind");
return StringRef();
}
Modified: lld/trunk/lib/ReaderWriter/MachO/SimpleAtoms.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/SimpleAtoms.hpp?rev=158542&r1=158541&r2=158542&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/SimpleAtoms.hpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/SimpleAtoms.hpp Fri Jun 15 15:37:24 2012
@@ -45,7 +45,7 @@
_absoluteAtoms._atoms.push_back(abAtom);
}
else {
- assert(0 && "atom has unknown definition kind");
+ llvm_unreachable("atom has unknown definition kind");
}
}
Modified: lld/trunk/lib/ReaderWriter/MachO/WriterOptionsMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterOptionsMachO.cpp?rev=158542&r1=158541&r2=158542&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/WriterOptionsMachO.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/WriterOptionsMachO.cpp Fri Jun 15 15:37:24 2012
@@ -41,7 +41,7 @@
case arch_armv7:
return StringRef("armv7");
}
- assert(0 && "unknown arch");
+ llvm_unreachable("unknown arch");
return StringRef("???");
}
@@ -55,7 +55,7 @@
case arch_armv7:
return mach_o::CPU_TYPE_ARM;
}
- assert(0 && "unknown arch");
+ llvm_unreachable("unknown arch");
return 0;
}
@@ -70,7 +70,7 @@
case arch_armv7:
return mach_o::CPU_SUBTYPE_ARM_V7;
}
- assert(0 && "unknown arch");
+ llvm_unreachable("unknown arch");
return 0;
}
@@ -84,7 +84,7 @@
assert(_pageZeroSize == 0);
return 0;
}
- assert(0 && "unknown outputkind");
+ llvm_unreachable("unknown outputkind");
return 0;
}
@@ -98,7 +98,7 @@
case outputObjectFile:
return false;
}
- assert(0 && "unknown outputkind");
+ llvm_unreachable("unknown outputkind");
return false;
}
@@ -112,7 +112,7 @@
case outputObjectFile:
return false;
}
- assert(0 && "unknown outputkind");
+ llvm_unreachable("unknown outputkind");
return false;
}
@@ -135,7 +135,7 @@
case outputObjectFile:
return StringRef();
}
- assert(0 && "unknown outputkind");
+ llvm_unreachable("unknown outputkind");
return StringRef();
}
More information about the llvm-commits
mailing list