summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/ErrorHandling.h8
-rw-r--r--include/llvm/Support/PassNameParser.h2
-rw-r--r--lib/Support/ErrorHandling.cpp6
3 files changed, 12 insertions, 4 deletions
diff --git a/include/llvm/Support/ErrorHandling.h b/include/llvm/Support/ErrorHandling.h
index 07faba7584..c14eed9885 100644
--- a/include/llvm/Support/ErrorHandling.h
+++ b/include/llvm/Support/ErrorHandling.h
@@ -49,11 +49,15 @@ namespace llvm {
/// 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
diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h
index 12c124074d..559dfd3e97 100644
--- a/include/llvm/Support/PassNameParser.h
+++ b/include/llvm/Support/PassNameParser.h
@@ -68,7 +68,7 @@ public:
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());
}
diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp
index f2e247c527..be0b3803f1 100644
--- a/lib/Support/ErrorHandling.cpp
+++ b/lib/Support/ErrorHandling.cpp
@@ -44,9 +44,13 @@ void llvm_report_error(const std::string &reason) {
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();
}
}