[cfe-commits] r109587 - /cfe/trunk/lib/Lex/Pragma.cpp

Daniel Dunbar daniel at zuster.org
Wed Jul 28 08:40:33 PDT 2010


Author: ddunbar
Date: Wed Jul 28 10:40:33 2010
New Revision: 109587

URL: http://llvm.org/viewvc/llvm-project?rev=109587&view=rev
Log:
Preprocessor: Add support for '#pragma clang __debug crash' and '#pragma clang
__debug overflow_stack'.
 - For testing crash reporting stuff... you'd think I could just use some C++
   code but Doug keeps fixing stuff!

Modified:
    cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=109587&r1=109586&r2=109587&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Wed Jul 28 10:40:33 2010
@@ -582,6 +582,33 @@
   }
 };
 
+struct PragmaDebugHandler : public PragmaHandler {
+  PragmaDebugHandler() : PragmaHandler("__debug") {}
+  virtual void HandlePragma(Preprocessor &PP, Token &DepToken) {
+    Token Tok;
+    PP.LexUnexpandedToken(Tok);
+    if (Tok.isNot(tok::identifier)) {
+      PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
+      return;
+    }
+    IdentifierInfo *II = Tok.getIdentifierInfo();
+
+    if (II->isStr("overflow_stack")) {
+      DebugOverflowStack();
+    } else if (II->isStr("crash")) {
+      DebugCrash();
+    }
+  }
+
+  void DebugOverflowStack() {
+    DebugOverflowStack();
+  }
+
+  void DebugCrash() {
+    abort();
+  }
+};
+
 /// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'
 /// Since clang's diagnostic supports extended functionality beyond GCC's
 /// the constructor takes a clangMode flag to tell it whether or not to allow
@@ -789,6 +816,7 @@
   // #pragma clang ...
   AddPragmaHandler("clang", new PragmaPoisonHandler());
   AddPragmaHandler("clang", new PragmaSystemHeaderHandler());
+  AddPragmaHandler("clang", new PragmaDebugHandler());
   AddPragmaHandler("clang", new PragmaDependencyHandler());
   AddPragmaHandler("clang", new PragmaDiagnosticHandler(true));
 





More information about the cfe-commits mailing list