[clang-tools-extra] e9a902c - Revert "Revert "Revert "[clang][pp] adds '#pragma include_instead'"""

Christopher Di Bella via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 22 09:37:49 PDT 2022


Author: Christopher Di Bella
Date: 2022-04-22T16:37:20Z
New Revision: e9a902c7f755a378e197c4b246a32859c0ee162d

URL: https://github.com/llvm/llvm-project/commit/e9a902c7f755a378e197c4b246a32859c0ee162d
DIFF: https://github.com/llvm/llvm-project/commit/e9a902c7f755a378e197c4b246a32859c0ee162d.diff

LOG: Revert "Revert "Revert "[clang][pp] adds '#pragma include_instead'"""

> Includes regression test for problem noted by @hans.
> is reverts commit 973de71.
>
> Differential Revision: https://reviews.llvm.org/D106898

Feature implemented as-is is fairly expensive and hasn't been used by
libc++. A potential reimplementation is possible if libc++ become
interested in this feature again.

Differential Revision: https://reviews.llvm.org/D123885

Added: 
    

Modified: 
    clang-tools-extra/clangd/Selection.cpp
    clang-tools-extra/pseudo/lib/Lex.cpp
    clang/include/clang/Basic/DiagnosticLexKinds.td
    clang/include/clang/Basic/SourceManager.h
    clang/include/clang/Lex/HeaderSearch.h
    clang/include/clang/Lex/Lexer.h
    clang/include/clang/Lex/Preprocessor.h
    clang/include/clang/Lex/PreprocessorLexer.h
    clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
    clang/lib/Lex/Lexer.cpp
    clang/lib/Lex/PPDirectives.cpp
    clang/lib/Lex/PPLexerChange.cpp
    clang/lib/Lex/Pragma.cpp

Removed: 
    clang/test/PCH/ms-pch-macro-include_instead-regression.c
    clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
    clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
    clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
    clang/test/Preprocessor/Inputs/include_instead/private-x.h
    clang/test/Preprocessor/Inputs/include_instead/private1.h
    clang/test/Preprocessor/Inputs/include_instead/private2.h
    clang/test/Preprocessor/Inputs/include_instead/private3.h
    clang/test/Preprocessor/Inputs/include_instead/public-after.h
    clang/test/Preprocessor/Inputs/include_instead/public-before.h
    clang/test/Preprocessor/Inputs/include_instead/public-empty.h
    clang/test/Preprocessor/include_instead.cpp
    clang/test/Preprocessor/include_instead_file_not_found.cpp


################################################################################
diff  --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp
index ba2f253eb0757..fa3e6ff22a00a 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
+#include <set>
 #include <string>
 
 namespace clang {

diff  --git a/clang-tools-extra/pseudo/lib/Lex.cpp b/clang-tools-extra/pseudo/lib/Lex.cpp
index e99bf3a63e5e1..72eff3c12f25c 100644
--- a/clang-tools-extra/pseudo/lib/Lex.cpp
+++ b/clang-tools-extra/pseudo/lib/Lex.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang-pseudo/Token.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 0f424b02c812a..543ce8a3649d1 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -315,12 +315,6 @@ def pp_pragma_sysheader_in_main_file : Warning<
   "#pragma system_header ignored in main file">,
   InGroup<DiagGroup<"pragma-system-header-outside-header">>;
 
-def err_pragma_include_instead_not_sysheader : Error<
-  "'#pragma clang include_instead' cannot be used outside of system headers">;
-def err_pragma_include_instead_system_reserved : Error<
-  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' "
-  "or '%3'|one of %2}1 instead">;
-
 def err_illegal_use_of_flt_eval_macro : Error<
   "'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing "
   "'#pragma clang fp eval_method'">;

diff  --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index cc29c24f5a35f..3f3f1bb65c2c1 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -36,6 +36,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/FileEntry.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"

diff  --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 3a170d2d3fa8d..e88e600ba2b97 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -20,9 +20,6 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
@@ -119,14 +116,6 @@ struct HeaderFileInfo {
   /// of the framework.
   StringRef Framework;
 
-  /// List of aliases that this header is known as.
-  /// Most headers should only have at most one alias, but a handful
-  /// have two.
-  llvm::SetVector<llvm::SmallString<32>,
-                  llvm::SmallVector<llvm::SmallString<32>, 2>,
-                  llvm::SmallSet<llvm::SmallString<32>, 2>>
-      Aliases;
-
   HeaderFileInfo()
       : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
         External(false), isModuleHeader(false), isCompilingModuleHeader(false),
@@ -528,10 +517,6 @@ class HeaderSearch {
     getFileInfo(File).DirInfo = SrcMgr::C_System;
   }
 
-  void AddFileAlias(const FileEntry *File, StringRef Alias) {
-    getFileInfo(File).Aliases.insert(Alias);
-  }
-
   /// Mark the specified file as part of a module.
   void MarkFileModuleHeader(const FileEntry *FE,
                             ModuleMap::ModuleHeaderRole Role,

diff  --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h
index c64a5756ac419..76612184bdffa 100644
--- a/clang/include/clang/Lex/Lexer.h
+++ b/clang/include/clang/Lex/Lexer.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LEX_LEXER_H
 #define LLVM_CLANG_LEX_LEXER_H
 
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/PreprocessorLexer.h"
@@ -752,7 +753,7 @@ class Lexer : public PreprocessorLexer {
   /// Read a universal character name.
   ///
   /// \param StartPtr The position in the source buffer after the initial '\'.
-  ///                 If the UCN is syntactically well-formed (but not 
+  ///                 If the UCN is syntactically well-formed (but not
   ///                 necessarily valid), this parameter will be updated to
   ///                 point to the character after the UCN.
   /// \param SlashLoc The position in the source buffer of the '\'.

diff  --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 02b94872cd8ae..3c74b48d19bec 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -23,6 +23,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/ModuleLoader.h"
@@ -2054,8 +2055,7 @@ class Preprocessor {
   /// This either returns the EOF token and returns true, or
   /// pops a level off the include stack and returns false, at which point the
   /// client should call lex again.
-  bool HandleEndOfFile(Token &Result, SourceLocation Loc,
-                       bool isEndOfMacro = false);
+  bool HandleEndOfFile(Token &Result, bool isEndOfMacro = false);
 
   /// Callback invoked when the current TokenLexer hits the end of its
   /// token stream.
@@ -2512,14 +2512,12 @@ class Preprocessor {
 
   // Pragmas.
   void HandlePragmaDirective(PragmaIntroducer Introducer);
-  void ResolvePragmaIncludeInstead(SourceLocation Location) const;
 
 public:
   void HandlePragmaOnce(Token &OnceTok);
   void HandlePragmaMark(Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
-  void HandlePragmaIncludeInstead(Token &Tok);
   void HandlePragmaDependency(Token &DependencyTok);
   void HandlePragmaPushMacro(Token &Tok);
   void HandlePragmaPopMacro(Token &Tok);

diff  --git a/clang/include/clang/Lex/PreprocessorLexer.h b/clang/include/clang/Lex/PreprocessorLexer.h
index 356b8c4098fd8..eebaad7d50db3 100644
--- a/clang/include/clang/Lex/PreprocessorLexer.h
+++ b/clang/include/clang/Lex/PreprocessorLexer.h
@@ -14,13 +14,12 @@
 #ifndef LLVM_CLANG_LEX_PREPROCESSORLEXER_H
 #define LLVM_CLANG_LEX_PREPROCESSORLEXER_H
 
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MultipleIncludeOpt.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
 #include <cassert>
 
 namespace clang {
@@ -76,13 +75,6 @@ class PreprocessorLexer {
   /// we are currently in.
   SmallVector<PPConditionalInfo, 4> ConditionalStack;
 
-  struct IncludeInfo {
-    const FileEntry *File;
-    SourceLocation Location;
-  };
-  // A complete history of all the files included by the current file.
-  llvm::StringMap<IncludeInfo> IncludeHistory;
-
   PreprocessorLexer() : FID() {}
   PreprocessorLexer(Preprocessor *pp, FileID fid);
   virtual ~PreprocessorLexer() = default;
@@ -184,15 +176,6 @@ class PreprocessorLexer {
     ConditionalStack.clear();
     ConditionalStack.append(CL.begin(), CL.end());
   }
-
-  void addInclude(StringRef Filename, const FileEntry &File,
-                  SourceLocation Location) {
-    IncludeHistory.insert({Filename, {&File, Location}});
-  }
-
-  const llvm::StringMap<IncludeInfo> &getIncludeHistory() const {
-    return IncludeHistory;
-  }
 };
 
 } // namespace clang

diff  --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 1eb6b835e2d01..bbf6cf5be0fef 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -24,6 +24,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MemoryBuffer.h"

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 6fc78cfa8ad95..a85b1186359e4 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2902,11 +2902,11 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
     ConditionalStack.pop_back();
   }
 
-  SourceLocation EndLoc = getSourceLocation(BufferEnd);
   // C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
   // a pedwarn.
   if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')) {
     DiagnosticsEngine &Diags = PP->getDiagnostics();
+    SourceLocation EndLoc = getSourceLocation(BufferEnd);
     unsigned DiagID;
 
     if (LangOpts.CPlusPlus11) {
@@ -2929,7 +2929,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
   BufferPtr = CurPtr;
 
   // Finally, let the preprocessor handle this.
-  return PP->HandleEndOfFile(Result, EndLoc, isPragmaLexer());
+  return PP->HandleEndOfFile(Result, isPragmaLexer());
 }
 
 /// isNextPPTokenLParen - Return 1 if the next unexpanded token lexed from

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 0ac3bec5148ab..2d942aacbf1db 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2048,10 +2048,6 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
       IsFrameworkFound, IsImportDecl, IsMapped, LookupFrom, LookupFromFile,
       LookupFilename, RelativePath, SearchPath, SuggestedModule, isAngled);
 
-  // Record the header's filename for later use.
-  if (File)
-    CurLexer->addInclude(OriginalFilename, File->getFileEntry(), FilenameLoc);
-
   if (usingPCHWithThroughHeader() && SkippingUntilPCHThroughHeader) {
     if (File && isPCHThroughHeader(&File->getFileEntry()))
       SkippingUntilPCHThroughHeader = false;

diff  --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index c61908089f526..e6a7eb6a03506 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Basic/FileManager.h"
-#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/LexDiagnostic.h"
@@ -303,46 +302,10 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
   }
 }
 
-void Preprocessor::ResolvePragmaIncludeInstead(
-    const SourceLocation Location) const {
-  assert(Location.isValid());
-  if (CurLexer == nullptr)
-    return;
-
-  if (SourceMgr.isInSystemHeader(Location))
-    return;
-
-  for (const auto &Include : CurLexer->getIncludeHistory()) {
-    StringRef Filename = Include.getKey();
-    const PreprocessorLexer::IncludeInfo &Info = Include.getValue();
-    ArrayRef<SmallString<32>> Aliases =
-        HeaderInfo.getFileInfo(Info.File).Aliases.getArrayRef();
-
-    if (Aliases.empty())
-      continue;
-
-    switch (Aliases.size()) {
-    case 1:
-      Diag(Info.Location, diag::err_pragma_include_instead_system_reserved)
-          << Filename << 0 << Aliases[0];
-      continue;
-    case 2:
-      Diag(Info.Location, diag::err_pragma_include_instead_system_reserved)
-          << Filename << 1 << Aliases[0] << Aliases[1];
-      continue;
-    default: {
-      Diag(Info.Location, diag::err_pragma_include_instead_system_reserved)
-          << Filename << 2 << ("{'" + llvm::join(Aliases, "', '") + "'}");
-    }
-    }
-  }
-}
-
 /// HandleEndOfFile - This callback is invoked when the lexer hits the end of
 /// the current file.  This either returns the EOF token or pops a level off
 /// the include stack and keeps going.
-bool Preprocessor::HandleEndOfFile(Token &Result, SourceLocation EndLoc,
-                                   bool isEndOfMacro) {
+bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
   assert(!CurTokenLexer &&
          "Ending a file when currently in a macro!");
 
@@ -412,9 +375,6 @@ bool Preprocessor::HandleEndOfFile(Token &Result, SourceLocation EndLoc,
     }
   }
 
-  if (EndLoc.isValid())
-    ResolvePragmaIncludeInstead(EndLoc);
-
   // Complain about reaching a true EOF within arc_cf_code_audited.
   // We don't want to complain about reaching the end of a macro
   // instantiation or a _Pragma.
@@ -612,7 +572,7 @@ bool Preprocessor::HandleEndOfTokenLexer(Token &Result) {
     TokenLexerCache[NumCachedTokenLexers++] = std::move(CurTokenLexer);
 
   // Handle this like a #include file being popped off the stack.
-  return HandleEndOfFile(Result, {}, true);
+  return HandleEndOfFile(Result, true);
 }
 
 /// RemoveTopOfLexerStack - Pop the current lexer/macro exp off the top of the

diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index eb370e8a0ecd6..5a1b999505426 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -14,7 +14,6 @@
 #include "clang/Lex/Pragma.h"
 #include "clang/Basic/CLWarnings.h"
 #include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/DiagnosticLex.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
@@ -37,12 +36,10 @@
 #include "clang/Lex/TokenLexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Timer.h"
@@ -503,87 +500,42 @@ void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
                         SrcMgr::C_System);
 }
 
-static llvm::Optional<Token> LexHeader(Preprocessor &PP,
-                                       Optional<FileEntryRef> &File,
-                                       bool SuppressIncludeNotFoundError) {
+/// HandlePragmaDependency - Handle \#pragma GCC dependency "foo" blah.
+void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
   Token FilenameTok;
-  if (PP.LexHeaderName(FilenameTok, /*AllowConcatenation*/ false))
-    return llvm::None;
+  if (LexHeaderName(FilenameTok, /*AllowConcatenation*/false))
+    return;
 
   // If the next token wasn't a header-name, diagnose the error.
   if (FilenameTok.isNot(tok::header_name)) {
-    PP.Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
-    return llvm::None;
+    Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+    return;
   }
 
   // Reserve a buffer to get the spelling.
   SmallString<128> FilenameBuffer;
   bool Invalid = false;
-  StringRef Filename = PP.getSpelling(FilenameTok, FilenameBuffer, &Invalid);
+  StringRef Filename = getSpelling(FilenameTok, FilenameBuffer, &Invalid);
   if (Invalid)
-    return llvm::None;
+    return;
 
   bool isAngled =
-      PP.GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename);
+    GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename);
   // If GetIncludeFilenameSpelling set the start ptr to null, there was an
   // error.
   if (Filename.empty())
-    return llvm::None;
+    return;
 
   // Search include directories for this file.
-  File = PP.LookupFile(FilenameTok.getLocation(), Filename, isAngled, nullptr,
-                       nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
-                       nullptr);
+  Optional<FileEntryRef> File =
+      LookupFile(FilenameTok.getLocation(), Filename, isAngled, nullptr,
+                 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
   if (!File) {
     if (!SuppressIncludeNotFoundError)
-      PP.Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
-    return llvm::None;
-  }
-
-  return FilenameTok;
-}
-
-/// HandlePragmaIncludeInstead - Handle \#pragma clang include_instead(header).
-void Preprocessor::HandlePragmaIncludeInstead(Token &Tok) {
-  // Get the current file lexer we're looking at.  Ignore _Pragma 'files' etc.
-  PreprocessorLexer *TheLexer = getCurrentFileLexer();
-
-  if (!SourceMgr.isInSystemHeader(Tok.getLocation())) {
-    Diag(Tok, diag::err_pragma_include_instead_not_sysheader);
+      Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
     return;
   }
 
-  Lex(Tok);
-  if (Tok.isNot(tok::l_paren)) {
-    Diag(Tok, diag::err_expected) << "(";
-    return;
-  }
-
-  Optional<FileEntryRef> File;
-  llvm::Optional<Token> FilenameTok =
-      LexHeader(*this, File, SuppressIncludeNotFoundError);
-  if (!FilenameTok)
-    return;
-
-  Lex(Tok);
-  if (Tok.isNot(tok::r_paren)) {
-    Diag(Tok, diag::err_expected) << ")";
-    return;
-  }
-
-  SmallString<128> FilenameBuffer;
-  StringRef Filename = getSpelling(*FilenameTok, FilenameBuffer);
-  HeaderInfo.AddFileAlias(TheLexer->getFileEntry(), Filename);
-}
-
-/// HandlePragmaDependency - Handle \#pragma GCC dependency "foo" blah.
-void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
-  Optional<FileEntryRef> File;
-  llvm::Optional<Token> FilenameTok =
-      LexHeader(*this, File, SuppressIncludeNotFoundError);
-  if (!FilenameTok)
-    return;
-
   const FileEntry *CurFile = getCurrentFileLexer()->getFileEntry();
 
   // If this file is older than the file it depends on, emit a diagnostic.
@@ -599,7 +551,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
     // Remove the trailing ' ' if present.
     if (!Message.empty())
       Message.erase(Message.end()-1);
-    Diag(*FilenameTok, diag::pp_out_of_date_dependency) << Message;
+    Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
   }
 }
 
@@ -1074,18 +1026,6 @@ struct PragmaSystemHeaderHandler : public PragmaHandler {
   }
 };
 
-/// PragmaIncludeInsteadHandler - "\#pragma clang include_instead(header)" marks
-/// the current file as non-includable if the including header is not a system
-/// header.
-struct PragmaIncludeInsteadHandler : public PragmaHandler {
-  PragmaIncludeInsteadHandler() : PragmaHandler("include_instead") {}
-
-  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
-                    Token &IIToken) override {
-    PP.HandlePragmaIncludeInstead(IIToken);
-  }
-};
-
 struct PragmaDependencyHandler : public PragmaHandler {
   PragmaDependencyHandler() : PragmaHandler("dependency") {}
 
@@ -2147,7 +2087,6 @@ void Preprocessor::RegisterBuiltinPragmas() {
   // #pragma clang ...
   AddPragmaHandler("clang", new PragmaPoisonHandler());
   AddPragmaHandler("clang", new PragmaSystemHeaderHandler());
-  AddPragmaHandler("clang", new PragmaIncludeInsteadHandler());
   AddPragmaHandler("clang", new PragmaDebugHandler());
   AddPragmaHandler("clang", new PragmaDependencyHandler());
   AddPragmaHandler("clang", new PragmaDiagnosticHandler("clang"));

diff  --git a/clang/test/PCH/ms-pch-macro-include_instead-regression.c b/clang/test/PCH/ms-pch-macro-include_instead-regression.c
deleted file mode 100644
index 1fac344a67b79..0000000000000
--- a/clang/test/PCH/ms-pch-macro-include_instead-regression.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Enabling MS extensions should allow us to add BAR definitions.
-// RUN: %clang_cc1 -DMSEXT -fms-extensions -DBAZ="\"Inputs/pch-through1.h\"" -emit-pch -o %t1.pch
-// RUN: %clang_cc1 -DMSEXT -fms-extensions -include-pch %t1.pch -verify %s
-
-#include BAZ
-// expected-no-diagnostics

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h b/clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
deleted file mode 100644
index 564570f9df730..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma GCC system_header
-
-#pragma clang include_instead <include_instead/public-before.h>
-// expected-error at -1{{expected (}}
-
-#pragma clang include_instead(<include_instead/public-after.h>]
-// expected-error at -1{{expected )}}

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/file-not-found.h b/clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
deleted file mode 100644
index 4c39d8b89e899..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma GCC system_header
-#pragma clang include_instead(<include_instead/does_not_exist.h>)
-// expected-error at -1{{'include_instead/does_not_exist.h' file not found}}

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/non-system-header.h b/clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
deleted file mode 100644
index 052cb168ee333..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma clang include_instead(<include_instead/public1.h>)
-// expected-error at -1{{'#pragma clang include_instead' cannot be used outside of system headers}}

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/private-x.h b/clang/test/Preprocessor/Inputs/include_instead/private-x.h
deleted file mode 100644
index 5fb1a3b1ebac4..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/private-x.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <include_instead/private1.h>
-
-#pragma GCC system_header
-#pragma clang include_instead(<include_instead/public-gcc-system-header-before-includes.h>)

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/private1.h b/clang/test/Preprocessor/Inputs/include_instead/private1.h
deleted file mode 100644
index 60a8a7e921228..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/private1.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma GCC system_header
-#pragma clang include_instead(<include_instead/public-before.h>)

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/private2.h b/clang/test/Preprocessor/Inputs/include_instead/private2.h
deleted file mode 100644
index b2f6b5a83c9f4..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/private2.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#pragma GCC system_header
-
-#pragma clang include_instead(<include_instead/public-before.h>)
-#pragma clang include_instead("include_instead/public-after.h")

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/private3.h b/clang/test/Preprocessor/Inputs/include_instead/private3.h
deleted file mode 100644
index bfbecc9ec3b9e..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/private3.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma GCC system_header
-
-#pragma clang include_instead(<include_instead/public-after.h>)
-#pragma clang include_instead(<include_instead/public-empty.h>)
-#pragma clang include_instead("include_instead/public-before.h")

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/public-after.h b/clang/test/Preprocessor/Inputs/include_instead/public-after.h
deleted file mode 100644
index 89af3065e39da..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/public-after.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <include_instead/private2.h>
-#pragma GCC system_header

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/public-before.h b/clang/test/Preprocessor/Inputs/include_instead/public-before.h
deleted file mode 100644
index 85c47deff4e88..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/public-before.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma GCC system_header
-
-#include <include_instead/private1.h> // no warning expected
-#include <include_instead/private2.h> // no warning expected
-#include <include_instead/private3.h> // no warning expected

diff  --git a/clang/test/Preprocessor/Inputs/include_instead/public-empty.h b/clang/test/Preprocessor/Inputs/include_instead/public-empty.h
deleted file mode 100644
index 5379acae968b3..0000000000000
--- a/clang/test/Preprocessor/Inputs/include_instead/public-empty.h
+++ /dev/null
@@ -1 +0,0 @@
-// This file simply needs to exist.

diff  --git a/clang/test/Preprocessor/include_instead.cpp b/clang/test/Preprocessor/include_instead.cpp
deleted file mode 100644
index 6111fa8c886fa..0000000000000
--- a/clang/test/Preprocessor/include_instead.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
-
-#include <include_instead/bad-syntax.h>
-#include <include_instead/non-system-header.h>
-
-#include <include_instead/private1.h>
-// expected-error at -1{{header '<include_instead/private1.h>' is an implementation detail; #include '<include_instead/public-before.h>' instead}}
-
-#include "include_instead/private2.h"
-// expected-error at -1{{header '"include_instead/private2.h"' is an implementation detail; #include either '<include_instead/public-before.h>' or '"include_instead/public-after.h"' instead}}
-
-#include <include_instead/private3.h>
-// expected-error at -1{{header '<include_instead/private3.h>' is an implementation detail; #include one of {'<include_instead/public-after.h>', '<include_instead/public-empty.h>', '"include_instead/public-before.h"'} instead}}
-
-#include <include_instead/public-before.h>
-#include <include_instead/public-after.h>

diff  --git a/clang/test/Preprocessor/include_instead_file_not_found.cpp b/clang/test/Preprocessor/include_instead_file_not_found.cpp
deleted file mode 100644
index 5d1bc88505dd0..0000000000000
--- a/clang/test/Preprocessor/include_instead_file_not_found.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
-#include <include_instead/file-not-found.h>


        


More information about the cfe-commits mailing list