diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 682242482b8962efe23cb1cf719501d02ae7bcd1..2491011aa6d9dfbd713e7de8d851e46afd4061f1 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -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);
 
diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp
index 88044f2c9a63abea5d9d6a3861894ba4b9f6e1f7..a3ab1be4a97a2782ae88b741aa72b218368b5ff4 100644
--- a/lib/Frontend/FrontendActions.cpp
+++ b/lib/Frontend/FrontendActions.cpp
@@ -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.
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 87fbd04041f2588b0e1b26a0a10e482ff218dd1c..f3393bfe51ce49fa103aee17fb1ef4d5d6551af6 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/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) {
   // 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.
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 61bd9172b43dbac6446578848fa5e94fa6a6f0fd..e4059eeb6fc0a63d17084d5be97dff7d8fc4d0c6 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -1401,14 +1401,3 @@ void Preprocessor::RegisterBuiltinPragmas() {
     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());
-}
diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp
index a3b6c49ac11182af75092596722e2282ce0618cb..176ea3f79dc13ad9d8a6e01b8f22cda5bb692f60 100644
--- a/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp
@@ -518,7 +518,13 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
   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.