r196376 - Revert r196372, "do not warn about unknown pragmas in modes that do not handle them (pr9537)"

NAKAMURA Takumi geek4civic at gmail.com
Wed Dec 4 03:12:27 PST 2013


Author: chapuni
Date: Wed Dec  4 05:12:26 2013
New Revision: 196376

URL: http://llvm.org/viewvc/llvm-project?rev=196376&view=rev
Log:
Revert r196372, "do not warn about unknown pragmas in modes that do not handle them (pr9537)"

It broke clang tests on some hosts with +Asserts. Seems "STDC" clashes.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Frontend/FrontendActions.cpp
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
    cfe/trunk/lib/Lex/Pragma.cpp
    cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=196376&r1=196375&r2=196376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Dec  4 05:12:26 2013
@@ -643,9 +643,6 @@ public:
     RemovePragmaHandler(StringRef(), Handler);
   }
 
-  /// Install empty handlers for all pragmas (making them ignored).
-  void IgnorePragmas();
-
   /// \brief Add the specified comment handler to the preprocessor.
   void addCommentHandler(CommentHandler *Handler);
 

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=196376&r1=196375&r2=196376&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Dec  4 05:12:26 2013
@@ -485,7 +485,7 @@ void PreprocessOnlyAction::ExecuteAction
   Preprocessor &PP = getCompilerInstance().getPreprocessor();
 
   // Ignore unknown pragmas.
-  PP.IgnorePragmas();
+  PP.AddPragmaHandler(new EmptyPragmaHandler());
 
   Token Tok;
   // Start parsing the specified input file.

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=196376&r1=196375&r2=196376&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Dec  4 05:12:26 2013
@@ -704,7 +704,7 @@ static int MacroIDCompare(const id_macro
 
 static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
   // Ignore unknown pragmas.
-  PP.IgnorePragmas();
+  PP.AddPragmaHandler(new EmptyPragmaHandler());
 
   // -dM mode just scans and ignores all tokens in the files, then dumps out
   // the macro table at the end.

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=196376&r1=196375&r2=196376&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Wed Dec  4 05:12:26 2013
@@ -1401,14 +1401,3 @@ void Preprocessor::RegisterBuiltinPragma
     AddPragmaHandler(new PragmaRegionHandler("endregion"));
   }
 }
-
-/// Ignore all pragmas, useful for modes such as -Eonly which would otherwise
-/// warn about those pragmas being unknown.
-void Preprocessor::IgnorePragmas() {
-  AddPragmaHandler(new EmptyPragmaHandler());
-  // Also ignore all pragmas in all namespaces created
-  // in Preprocessor::RegisterBuiltinPragmas().
-  AddPragmaHandler("GCC", new EmptyPragmaHandler());
-  AddPragmaHandler("clang", new EmptyPragmaHandler());
-  AddPragmaHandler("STDC", new EmptyPragmaHandler());
-}

Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=196376&r1=196375&r2=196376&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Wed Dec  4 05:12:26 2013
@@ -518,7 +518,13 @@ void clang::RewriteIncludesInInput(Prepr
   InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS,
                                                      Opts.ShowLineMarkers);
   PP.addPPCallbacks(Rewrite);
-  PP.IgnorePragmas();
+  // 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.





More information about the cfe-commits mailing list