diff options
author | Torok Edwin <edwintorok@gmail.com> | 2009-07-11 20:10:48 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2009-07-11 20:10:48 +0000 |
commit | c25e7581b9b8088910da31702d4ca21c4734c6d7 (patch) | |
tree | e4bb95c96a33fda5d5204f2c9d1b906084760415 /include/llvm | |
parent | d51ffcf303070b0a5aea7f365b85f6f969c384cb (diff) | |
download | llvm-c25e7581b9b8088910da31702d4ca21c4734c6d7.tar.gz llvm-c25e7581b9b8088910da31702d4ca21c4734c6d7.tar.bz2 llvm-c25e7581b9b8088910da31702d4ca21c4734c6d7.tar.xz |
assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 7 | ||||
-rw-r--r-- | include/llvm/MDNode.h | 4 | ||||
-rw-r--r-- | include/llvm/Support/ErrorHandling.h | 4 | ||||
-rw-r--r-- | include/llvm/Support/InstVisitor.h | 4 | ||||
-rw-r--r-- | include/llvm/Support/PassNameParser.h | 3 | ||||
-rw-r--r-- | include/llvm/Target/TargetData.h | 6 | ||||
-rw-r--r-- | include/llvm/Target/TargetInstrInfo.h | 4 |
7 files changed, 16 insertions, 16 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index e87d063501..fc03e9fe78 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -15,6 +15,7 @@ #define LLVM_ANALYSIS_SCALAREVOLUTION_EXPRESSIONS_H #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Support/ErrorHandling.h" namespace llvm { class ConstantInt; @@ -584,14 +585,12 @@ namespace llvm { case scCouldNotCompute: return ((SC*)this)->visitCouldNotCompute((const SCEVCouldNotCompute*)S); default: - assert(0 && "Unknown SCEV type!"); - abort(); + LLVM_UNREACHABLE("Unknown SCEV type!"); } } RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S) { - assert(0 && "Invalid use of SCEVCouldNotCompute!"); - abort(); + LLVM_UNREACHABLE("Invalid use of SCEVCouldNotCompute!"); return RetVal(); } }; diff --git a/include/llvm/MDNode.h b/include/llvm/MDNode.h index d632e4ea4a..dcda5d05eb 100644 --- a/include/llvm/MDNode.h +++ b/include/llvm/MDNode.h @@ -25,6 +25,7 @@ #include "llvm/Type.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ValueHandle.h" namespace llvm { @@ -119,8 +120,7 @@ public: virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { - assert(0 && "This should never be called because MDNodes have no ops"); - abort(); + LLVM_UNREACHABLE("This should never be called because MDNodes have no ops"); } /// Methods for support type inquiry through isa, cast, and dyn_cast: diff --git a/include/llvm/Support/ErrorHandling.h b/include/llvm/Support/ErrorHandling.h index c7e4297f00..1a401eb7c0 100644 --- a/include/llvm/Support/ErrorHandling.h +++ b/include/llvm/Support/ErrorHandling.h @@ -46,11 +46,11 @@ namespace llvm { /// This function calls abort(). /// Call this after assert(0), so that compiler knows the path is not /// reachable. - void llvm_unreachable(void) NORETURN; + void llvm_unreachable(const char *msg=0) NORETURN; } #ifndef NDEBUG -#define LLVM_UNREACHABLE(msg) do {cerr<<msg<<"\n";llvm_unreachable();}while(0) +#define LLVM_UNREACHABLE(msg) llvm_unreachable(msg) #else #define LLVM_UNREACHABLE(msg) llvm_unreachable() #endif diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index 768f4877ad..2fa8c4793c 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -14,6 +14,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Module.h" +#include "llvm/Support/ErrorHandling.h" namespace llvm { @@ -113,8 +114,7 @@ public: // RetTy visit(Instruction &I) { switch (I.getOpcode()) { - default: assert(0 && "Unknown instruction type encountered!"); - abort(); + default: LLVM_UNREACHABLE("Unknown instruction type encountered!"); // Build the switch statement using the Instruction.def file... #define HANDLE_INST(NUM, OPCODE, CLASS) \ case Instruction::OPCODE: return \ diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index e489e0a6f0..12c124074d 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -24,6 +24,7 @@ #define LLVM_SUPPORT_PASS_NAME_PARSER_H #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Pass.h" #include <algorithm> #include <cstring> @@ -67,7 +68,7 @@ public: if (findOption(P->getPassArgument()) != getNumOptions()) { cerr << "Two passes with the same argument (-" << P->getPassArgument() << ") attempted to be registered!\n"; - abort(); + llvm_unreachable(); } addLiteralOption(P->getPassArgument(), P, P->getPassName()); } diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index 82abfc7286..c06165c62d 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -22,6 +22,7 @@ #include "llvm/Pass.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/ADT/SmallVector.h" #include <string> @@ -111,9 +112,8 @@ public: /// @note This has to exist, because this is a pass, but it should never be /// used. TargetData() : ImmutablePass(&ID) { - assert(0 && "ERROR: Bad TargetData ctor used. " - "Tool did not specify a TargetData to use?"); - abort(); + llvm_report_error("ERROR: Bad TargetData ctor used. " + "Tool did not specify a TargetData to use?"); } /// Constructs a TargetData from a specification string. See init(). diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index 0635c23cbe..242bbdcef4 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -14,6 +14,7 @@ #ifndef LLVM_TARGET_TARGETINSTRINFO_H #define LLVM_TARGET_TARGETINSTRINFO_H +#include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetInstrDesc.h" #include "llvm/CodeGen/MachineFunction.h" @@ -428,8 +429,7 @@ public: /// point. virtual void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const { - assert(0 && "Target didn't implement insertNoop!"); - abort(); + LLVM_UNREACHABLE("Target didn't implement insertNoop!"); } /// isPredicated - Returns true if the instruction is already predicated. |