[cfe-commits] r111311 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/Pragma.cpp
Daniel Dunbar
daniel at zuster.org
Tue Aug 17 15:32:48 PDT 2010
Author: ddunbar
Date: Tue Aug 17 17:32:48 2010
New Revision: 111311
URL: http://llvm.org/viewvc/llvm-project?rev=111311&view=rev
Log:
Lex: Add #pragma clang __debug {llvm_fatal_error, llvm_unreachable}, for testing
those crash paths.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/Pragma.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=111311&r1=111310&r2=111311&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Aug 17 17:32:48 2010
@@ -268,6 +268,9 @@
def warn_pragma_diagnostic_unknown_warning :
ExtWarn<"unknown warning group '%0', ignored">,
InGroup<UnknownPragmas>;
+// - #pragma __debug
+def warn_pragma_debug_unexpected_command : Warning<
+ "unexpected debug command '%0'">;
def err_pragma_comment_unknown_kind : Error<"unknown kind of pragma comment">;
def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=111311&r1=111310&r2=111311&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Tue Aug 17 17:32:48 2010
@@ -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 @@
}
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"'
More information about the cfe-commits
mailing list