forked from OSchip/llvm-project
Lex: Add #pragma clang __debug {llvm_fatal_error, llvm_unreachable}, for testing
those crash paths. llvm-svn: 111311
This commit is contained in:
parent
b613ffc1aa
commit
f2cf329ccd
|
@ -268,6 +268,9 @@ def warn_pragma_diagnostic_invalid_token :
|
|||
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">;
|
||||
|
|
|
@ -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"'
|
||||
|
|
Loading…
Reference in New Issue