[llvm-commits] [llvm] r75631 - in /llvm/trunk: include/llvm/Support/ErrorHandling.h include/llvm/Support/PassNameParser.h lib/Support/ErrorHandling.cpp
Torok Edwin
edwintorok at gmail.com
Tue Jul 14 05:49:41 PDT 2009
Author: edwin
Date: Tue Jul 14 07:49:22 2009
New Revision: 75631
URL: http://llvm.org/viewvc/llvm-project?rev=75631&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Support/ErrorHandling.h
llvm/trunk/include/llvm/Support/PassNameParser.h
llvm/trunk/lib/Support/ErrorHandling.cpp
Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=75631&r1=75630&r2=75631&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorHandling.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorHandling.h Tue Jul 14 07:49:22 2009
@@ -49,11 +49,15 @@
/// This function calls abort(), and prints the optional message to stderr.
/// Call this instead of assert(0), so that compiler knows the path is not
/// reachable even for NDEBUG builds.
- void llvm_unreachable(const char *msg=0) NORETURN;
+ /// Use the LLVM_UNREACHABLE macro instead that adds location info.
+ void llvm_unreachable(const char *msg=0, const char *file=0,
+ unsigned line=0) NORETURN;
}
+/// Macro that calls llvm_unreachable with location info and message in
+/// debug mode. In NDEBUG mode it calls llvm_unreachable with no message.
#ifndef NDEBUG
-#define LLVM_UNREACHABLE(msg) llvm_unreachable(msg)
+#define LLVM_UNREACHABLE(msg) llvm_unreachable(msg, __FILE__, __LINE__)
#else
#define LLVM_UNREACHABLE(msg) llvm_unreachable()
#endif
Modified: llvm/trunk/include/llvm/Support/PassNameParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PassNameParser.h?rev=75631&r1=75630&r2=75631&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PassNameParser.h (original)
+++ llvm/trunk/include/llvm/Support/PassNameParser.h Tue Jul 14 07:49:22 2009
@@ -68,7 +68,7 @@
if (findOption(P->getPassArgument()) != getNumOptions()) {
cerr << "Two passes with the same argument (-"
<< P->getPassArgument() << ") attempted to be registered!\n";
- llvm_unreachable();
+ LLVM_UNREACHABLE(0);
}
addLiteralOption(P->getPassArgument(), P, P->getPassName());
}
Modified: llvm/trunk/lib/Support/ErrorHandling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=75631&r1=75630&r2=75631&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ErrorHandling.cpp (original)
+++ llvm/trunk/lib/Support/ErrorHandling.cpp Tue Jul 14 07:49:22 2009
@@ -44,9 +44,13 @@
exit(1);
}
-void llvm_unreachable(const char *msg) {
+void llvm_unreachable(const char *msg, const char *file, unsigned line) {
if (msg)
errs() << msg << "\n";
+ errs() << "UNREACHABLE executed";
+ if (file)
+ errs() << " at " << file << ":" << line;
+ errs() << "!\n";
abort();
}
}
More information about the llvm-commits
mailing list