From 08c9add28c1a5b3c80b910d268a2f0a9f4d72995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 7 Jan 2013 12:37:28 +0100 Subject: [PATCH] do not warn about "unknown" pragmas in -frewrite-includes (pr#14831) --- lib/Rewrite/Frontend/InclusionRewriter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp index 9d1bec9..dad15fa 100644 --- tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Rewrite/Frontend/Rewriters.h" +#include "clang/Lex/Pragma.h" #include "clang/Lex/Preprocessor.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/PreprocessorOutputOptions.h" @@ -344,6 +345,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. -- 1.7.10.4