On Monday 01 of July 2013, Eli Friedman wrote:
> On Sat, Jun 29, 2013 at 11:49 PM, Lubos Lunak <[email protected]> wrote:
> >  Hello,
> >
> >  could somebody please review and commit the atached patch for pr14831?
> > Thank
> > you.
>
> Testcase?

 Updated patch attached.

-- 
 Lubos Lunak
 [email protected]
diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp
index 9e4bb3c..3a0a2e9 100644
--- a/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp
@@ -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"
@@ -476,6 +477,13 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
   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.
diff --git a/test/Frontend/rewrite-includes-warnings.c b/test/Frontend/rewrite-includes-warnings.c
new file mode 100644
index 0000000..1fb98db
--- /dev/null
+++ b/test/Frontend/rewrite-includes-warnings.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -Wall -Wextra -E -frewrite-includes %s
+// expected-no-diagnostics
+
+#pragma GCC visibility push (default)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to