r186764 - avoid bogus warnings about "unknown" pragmas with -frewrite-includes (pr#14831)
Lubos Lunak
l.lunak at suse.cz
Sat Jul 20 07:30:02 PDT 2013
Author: llunak
Date: Sat Jul 20 09:30:01 2013
New Revision: 186764
URL: http://llvm.org/viewvc/llvm-project?rev=186764&view=rev
Log:
avoid bogus warnings about "unknown" pragmas with -frewrite-includes (pr#14831)
Added:
cfe/trunk/test/Frontend/rewrite-includes-warnings.c
Modified:
cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=186764&r1=186763&r2=186764&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Sat Jul 20 09:30:01 2013
@@ -16,6 +16,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Pragma.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
@@ -503,6 +504,13 @@ void clang::RewriteIncludesInInput(Prepr
InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS,
Opts.ShowLineMarkers);
PP.addPPCallbacks(Rewrite);
+ // Ignore all pragmas, otherwise there will be warnings about unknown pragmas
+ // (because there's nothing to handle them).
+ PP.AddPragmaHandler(new EmptyPragmaHandler());
+ // Ignore also all pragma in all namespaces created
+ // in Preprocessor::RegisterBuiltinPragmas().
+ PP.AddPragmaHandler("GCC", new EmptyPragmaHandler());
+ PP.AddPragmaHandler("clang", new EmptyPragmaHandler());
// First let the preprocessor process the entire file and call callbacks.
// Callbacks will record which #include's were actually performed.
Added: cfe/trunk/test/Frontend/rewrite-includes-warnings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/rewrite-includes-warnings.c?rev=186764&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/rewrite-includes-warnings.c (added)
+++ cfe/trunk/test/Frontend/rewrite-includes-warnings.c Sat Jul 20 09:30:01 2013
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -Wall -Wextra -E -frewrite-includes %s
+// expected-no-diagnostics
+
+#pragma GCC visibility push (default)
More information about the cfe-commits
mailing list