llvm.org GIT mirror llvm / 93990d7
After converting assert(0) to LLVM_UNREACHABLE we lost file/line location. Fix by making the LLVM_UNREACHABLE pass __FILE__ and __LINE__ to llvm_unreachable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75631 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 10 years ago
3 changed file(s) with 12 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4848 /// This function calls abort(), and prints the optional message to stderr.
4949 /// Call this instead of assert(0), so that compiler knows the path is not
5050 /// reachable even for NDEBUG builds.
51 void llvm_unreachable(const char *msg=0) NORETURN;
51 /// Use the LLVM_UNREACHABLE macro instead that adds location info.
52 void llvm_unreachable(const char *msg=0, const char *file=0,
53 unsigned line=0) NORETURN;
5254 }
5355
56 /// Macro that calls llvm_unreachable with location info and message in
57 /// debug mode. In NDEBUG mode it calls llvm_unreachable with no message.
5458 #ifndef NDEBUG
55 #define LLVM_UNREACHABLE(msg) llvm_unreachable(msg)
59 #define LLVM_UNREACHABLE(msg) llvm_unreachable(msg, __FILE__, __LINE__)
5660 #else
5761 #define LLVM_UNREACHABLE(msg) llvm_unreachable()
5862 #endif
6767 if (findOption(P->getPassArgument()) != getNumOptions()) {
6868 cerr << "Two passes with the same argument (-"
6969 << P->getPassArgument() << ") attempted to be registered!\n";
70 llvm_unreachable();
70 LLVM_UNREACHABLE(0);
7171 }
7272 addLiteralOption(P->getPassArgument(), P, P->getPassName());
7373 }
4343 exit(1);
4444 }
4545
46 void llvm_unreachable(const char *msg) {
46 void llvm_unreachable(const char *msg, const char *file, unsigned line) {
4747 if (msg)
4848 errs() << msg << "\n";
49 errs() << "UNREACHABLE executed";
50 if (file)
51 errs() << " at " << file << ":" << line;
52 errs() << "!\n";
4953 abort();
5054 }
5155 }