浏览代码

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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196376 91177308-0d34-0410-b5e6-96231b3b80d8
NAKAMURA Takumi 11 年之前
父节点
当前提交
ac808362b2

+ 0 - 3
include/clang/Lex/Preprocessor.h

@@ -643,9 +643,6 @@ public:
     RemovePragmaHandler(StringRef(), Handler);
     RemovePragmaHandler(StringRef(), Handler);
   }
   }
 
 
-  /// Install empty handlers for all pragmas (making them ignored).
-  void IgnorePragmas();
-
   /// \brief Add the specified comment handler to the preprocessor.
   /// \brief Add the specified comment handler to the preprocessor.
   void addCommentHandler(CommentHandler *Handler);
   void addCommentHandler(CommentHandler *Handler);
 
 

+ 1 - 1
lib/Frontend/FrontendActions.cpp

@@ -485,7 +485,7 @@ void PreprocessOnlyAction::ExecuteAction() {
   Preprocessor &PP = getCompilerInstance().getPreprocessor();
   Preprocessor &PP = getCompilerInstance().getPreprocessor();
 
 
   // Ignore unknown pragmas.
   // Ignore unknown pragmas.
-  PP.IgnorePragmas();
+  PP.AddPragmaHandler(new EmptyPragmaHandler());
 
 
   Token Tok;
   Token Tok;
   // Start parsing the specified input file.
   // Start parsing the specified input file.

+ 1 - 1
lib/Frontend/PrintPreprocessedOutput.cpp

@@ -704,7 +704,7 @@ static int MacroIDCompare(const id_macro_pair *LHS, const id_macro_pair *RHS) {
 
 
 static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
 static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
   // Ignore unknown pragmas.
   // Ignore unknown pragmas.
-  PP.IgnorePragmas();
+  PP.AddPragmaHandler(new EmptyPragmaHandler());
 
 
   // -dM mode just scans and ignores all tokens in the files, then dumps out
   // -dM mode just scans and ignores all tokens in the files, then dumps out
   // the macro table at the end.
   // the macro table at the end.

+ 0 - 11
lib/Lex/Pragma.cpp

@@ -1401,14 +1401,3 @@ void Preprocessor::RegisterBuiltinPragmas() {
     AddPragmaHandler(new PragmaRegionHandler("endregion"));
     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());
-}

+ 7 - 1
lib/Rewrite/Frontend/InclusionRewriter.cpp

@@ -518,7 +518,13 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
   InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS,
   InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS,
                                                      Opts.ShowLineMarkers);
                                                      Opts.ShowLineMarkers);
   PP.addPPCallbacks(Rewrite);
   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.
   // First let the preprocessor process the entire file and call callbacks.
   // Callbacks will record which #include's were actually performed.
   // Callbacks will record which #include's were actually performed.