diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-06-22 19:41:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-06-22 19:41:48 +0000 |
commit | c09ce1224dedc470fce9747e5936ff83cc6762eb (patch) | |
tree | 29ccc7c9ec50bafd116d4ac435fbebbe33ab8477 /lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | b27c7a199baaf691c724951a1bf3e6df9dcf5b6d (diff) |
Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133633 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index b46e04749b..b9c0642980 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -26,6 +26,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Config/config.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/ErrorHandling.h" #include <cstdio> using namespace clang; @@ -122,6 +123,12 @@ public: virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, const std::string &Str); virtual void PragmaMessage(SourceLocation Loc, llvm::StringRef Str); + virtual void PragmaDiagnosticPush(SourceLocation Loc, + llvm::StringRef Namespace); + virtual void PragmaDiagnosticPop(SourceLocation Loc, + llvm::StringRef Namespace); + virtual void PragmaDiagnostic(SourceLocation Loc, llvm::StringRef Namespace, + diag::Mapping Map, llvm::StringRef Str); bool HandleFirstTokOnLine(Token &Tok); bool MoveToLine(SourceLocation Loc) { @@ -361,6 +368,43 @@ void PrintPPOutputPPCallbacks::PragmaMessage(SourceLocation Loc, EmittedTokensOnThisLine = true; } +void PrintPPOutputPPCallbacks:: +PragmaDiagnosticPush(SourceLocation Loc, llvm::StringRef Namespace) { + MoveToLine(Loc); + OS << "#pragma " << Namespace << " diagnostic push"; + EmittedTokensOnThisLine = true; +} + +void PrintPPOutputPPCallbacks:: +PragmaDiagnosticPop(SourceLocation Loc, llvm::StringRef Namespace) { + MoveToLine(Loc); + OS << "#pragma " << Namespace << " diagnostic pop"; + EmittedTokensOnThisLine = true; +} + +void PrintPPOutputPPCallbacks:: +PragmaDiagnostic(SourceLocation Loc, llvm::StringRef Namespace, + diag::Mapping Map, llvm::StringRef Str) { + MoveToLine(Loc); + OS << "#pragma " << Namespace << " diagnostic "; + switch (Map) { + default: llvm_unreachable("unexpected diagnostic kind"); + case diag::MAP_WARNING: + OS << "warning"; + break; + case diag::MAP_ERROR: + OS << "error"; + break; + case diag::MAP_IGNORE: + OS << "ignored"; + break; + case diag::MAP_FATAL: + OS << "fatal"; + break; + } + OS << " \"" << Str << '"'; + EmittedTokensOnThisLine = true; +} /// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this /// is called for the first token on each new line. If this really is the start |