summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-09-13 22:00:30 +0000
committerReid Kleckner <reid@kleckner.net>2013-09-13 22:00:30 +0000
commit881dff36831f30d6b4792e398bc5a28775ac2757 (patch)
tree67a0e1c0dcbbe32d88b2363b6a55a804a2b9fb6e /clang/lib/Frontend/PrintPreprocessedOutput.cpp
parentec9bb694bd2e9cb950b9de06140fc6441d9835f0 (diff)
downloadbcm5719-llvm-881dff36831f30d6b4792e398bc5a28775ac2757.tar.gz
bcm5719-llvm-881dff36831f30d6b4792e398bc5a28775ac2757.zip
Lex and ignore Microsoft's #pragma warning(...)
Summary: This fixes PR17145 and avoids unknown pragma warnings. This change does not attempt to map MSVC warning numbers to clang warning flags. Perhaps in the future we will implement a mapping for some common subset of Microsoft warnings, but for now we don't. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1652 llvm-svn: 190726
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index e0ec08fb90a..3e45fc79f40 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -152,6 +152,10 @@ public:
StringRef Namespace);
virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
diag::Mapping Map, StringRef Str);
+ virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec,
+ ArrayRef<int> Ids);
+ virtual void PragmaWarningPush(SourceLocation Loc, int Level);
+ virtual void PragmaWarningPop(SourceLocation Loc);
bool HandleFirstTokOnLine(Token &Tok);
@@ -507,6 +511,36 @@ PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
setEmittedDirectiveOnThisLine();
}
+void PrintPPOutputPPCallbacks::PragmaWarning(SourceLocation Loc,
+ StringRef WarningSpec,
+ ArrayRef<int> Ids) {
+ startNewLineIfNeeded();
+ MoveToLine(Loc);
+ OS << "#pragma warning(" << WarningSpec << ':';
+ for (ArrayRef<int>::iterator I = Ids.begin(), E = Ids.end(); I != E; ++I)
+ OS << ' ' << *I;
+ OS << ')';
+ setEmittedDirectiveOnThisLine();
+}
+
+void PrintPPOutputPPCallbacks::PragmaWarningPush(SourceLocation Loc,
+ int Level) {
+ startNewLineIfNeeded();
+ MoveToLine(Loc);
+ OS << "#pragma warning(push";
+ if (Level)
+ OS << ", " << Level;
+ OS << ')';
+ setEmittedDirectiveOnThisLine();
+}
+
+void PrintPPOutputPPCallbacks::PragmaWarningPop(SourceLocation Loc) {
+ startNewLineIfNeeded();
+ MoveToLine(Loc);
+ OS << "#pragma warning(pop)";
+ setEmittedDirectiveOnThisLine();
+}
+
/// 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
/// of a new logical line, handle it and return true, otherwise return false.
OpenPOWER on IntegriCloud