aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:48 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:48 +0000
commit5505413ee8e4e2924f52ba81181071f3a492e7d9 (patch)
treec7702983595e9131d64da2621aa2ec71b2b5713c /lib/Lex/Pragma.cpp
parentc326b64a4d14ad89d6a5d227d2460050149d5461 (diff)
Lex: Add #pragma clang __debug {llvm_fatal_error, llvm_unreachable}, for testing
those crash paths. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Pragma.cpp')
-rw-r--r--lib/Lex/Pragma.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index eec1d1d6ee..0ef87b96d3 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -20,6 +20,7 @@
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
using namespace clang;
@@ -697,20 +698,25 @@ struct PragmaDebugHandler : public PragmaHandler {
}
IdentifierInfo *II = Tok.getIdentifierInfo();
- if (II->isStr("overflow_stack")) {
- DebugOverflowStack();
+ if (II->isStr("assert")) {
+ assert(0 && "This is an assertion!");
} else if (II->isStr("crash")) {
- DebugCrash();
+ *(volatile int*) 0x11 = 0;
+ } else if (II->isStr("llvm_fatal_error")) {
+ llvm::report_fatal_error("#pragma clang __debug llvm_fatal_error");
+ } else if (II->isStr("llvm_unreachable")) {
+ llvm_unreachable("#pragma clang __debug llvm_unreachable");
+ } else if (II->isStr("overflow_stack")) {
+ DebugOverflowStack();
+ } else {
+ PP.Diag(Tok, diag::warn_pragma_debug_unexpected_command)
+ << II->getName();
}
}
void DebugOverflowStack() {
DebugOverflowStack();
}
-
- void DebugCrash() {
- *(volatile int*) 0x11 = 0;
- }
};
/// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'