takuto.ikuta updated this revision to Diff 97949.
takuto.ikuta added a comment.

Remove IncludeLoc


https://reviews.llvm.org/D32903

Files:
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===================================================================
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -234,9 +234,9 @@
           break;
       }
     }
-    
+
     // FIXME: Figure out how header maps and module maps will work together.
-    
+
     // Only deal with normal search directories.
     if (!SearchDirs[Idx].isNormalDir())
       continue;
@@ -251,7 +251,7 @@
       if (Module)
         break;
     }
-              
+
     // Search for a module map in a subdirectory with the same name as the
     // module.
     SmallString<128> NestedModuleMapDirName;
@@ -299,7 +299,7 @@
 }
 
 const FileEntry *HeaderSearch::getFileAndSuggestModule(
-    StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
+    StringRef FileName, const DirectoryEntry *Dir,
     bool IsSystemHeaderDir, Module *RequestingModule,
     ModuleMap::KnownHeader *SuggestedModule) {
   // If we have a module map that might map this header, load it and
@@ -322,7 +322,6 @@
 const FileEntry *DirectoryLookup::LookupFile(
     StringRef &Filename,
     HeaderSearch &HS,
-    SourceLocation IncludeLoc,
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
     Module *RequestingModule,
@@ -348,7 +347,7 @@
       RelativePath->append(Filename.begin(), Filename.end());
     }
 
-    return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),
+    return HS.getFileAndSuggestModule(TmpDir, getDir(),
                                       isSystemHeaderDirectory(),
                                       RequestingModule, SuggestedModule);
   }
@@ -399,11 +398,8 @@
 ///
 /// \param FileMgr The file manager to use for directory lookups.
 /// \param DirName The name of the framework directory.
-/// \param SubmodulePath Will be populated with the submodule path from the
-/// returned top-level module to the originally named framework.
 static const DirectoryEntry *
-getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
-                   SmallVectorImpl<std::string> &SubmodulePath) {
+getTopFrameworkDir(FileManager &FileMgr, StringRef DirName) {
   assert(llvm::sys::path::extension(DirName) == ".framework" &&
          "Not a framework directory");
 
@@ -437,7 +433,6 @@
     // If this is a framework directory, then we're a subframework of this
     // framework.
     if (llvm::sys::path::extension(DirName) == ".framework") {
-      SubmodulePath.push_back(llvm::sys::path::stem(DirName));
       TopFrameworkDir = Dir;
     }
   } while (true);
@@ -518,7 +513,7 @@
     RelativePath->clear();
     RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
   }
-  
+
   // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
   unsigned OrigSize = FrameworkName.size();
 
@@ -630,7 +625,7 @@
 
   if (SuggestedModule)
     *SuggestedModule = ModuleMap::KnownHeader();
-    
+
   // If 'Filename' is absolute, check to see if it exists and no searching.
   if (llvm::sys::path::is_absolute(Filename)) {
     CurDir = nullptr;
@@ -645,7 +640,7 @@
       RelativePath->append(Filename.begin(), Filename.end());
     }
     // Otherwise, just return the file.
-    return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,
+    return getFileAndSuggestModule(Filename, nullptr,
                                    /*IsSystemHeaderDir*/false,
                                    RequestingModule, SuggestedModule);
   }
@@ -682,7 +677,7 @@
           Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :
           BuildSystemModule;
       if (const FileEntry *FE = getFileAndSuggestModule(
-              TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,
+              TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,
               RequestingModule, SuggestedModule)) {
         if (!Includer) {
           assert(First && "only first includer can have no file");
@@ -776,7 +771,7 @@
     bool InUserSpecifiedSystemFramework = false;
     bool HasBeenMapped = false;
     const FileEntry *FE = SearchDirs[i].LookupFile(
-        Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
+        Filename, *this, SearchPath, RelativePath, RequestingModule,
         SuggestedModule, InUserSpecifiedSystemFramework, HasBeenMapped,
         MappedName);
     if (HasBeenMapped) {
@@ -815,7 +810,7 @@
       size_t SlashPos = Filename.find('/');
       if (SlashPos != StringRef::npos) {
         HFI.IndexHeaderMapHeader = 1;
-        HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(), 
+        HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
                                                          SlashPos));
       }
     }
@@ -991,7 +986,7 @@
 
 /// \brief Merge the header file info provided by \p OtherHFI into the current
 /// header file info (\p HFI)
-static void mergeHeaderFileInfo(HeaderFileInfo &HFI, 
+static void mergeHeaderFileInfo(HeaderFileInfo &HFI,
                                 const HeaderFileInfo &OtherHFI) {
   assert(OtherHFI.External && "expected to merge external HFI");
 
@@ -1013,7 +1008,7 @@
   if (HFI.Framework.empty())
     HFI.Framework = OtherHFI.Framework;
 }
-                                
+
 /// getFileInfo - Return the HeaderFileInfo structure for the specified
 /// FileEntry.
 HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
@@ -1195,14 +1190,14 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
-bool HeaderSearch::hasModuleMap(StringRef FileName, 
+bool HeaderSearch::hasModuleMap(StringRef FileName,
                                 const DirectoryEntry *Root,
                                 bool IsSystem) {
   if (!HSOpts->ImplicitModuleMaps)
     return false;
 
   SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
-  
+
   StringRef DirName = FileName;
   do {
     // Get the parent directory name.
@@ -1235,7 +1230,7 @@
     // If we hit the top of our search, we're done.
     if (Dir == Root)
       return false;
-        
+
     // Keep track of all of the directories we checked, so we can mark them as
     // having module maps if we eventually do find a module map.
     FixUpDirectories.push_back(Dir);
@@ -1292,10 +1287,9 @@
   // If we're supposed to suggest a module, look for one now.
   if (needModuleLookup(RequestingModule, SuggestedModule)) {
     // Find the top-level framework based on this framework.
-    SmallVector<std::string, 4> SubmodulePath;
-    const DirectoryEntry *TopFrameworkDir
-      = ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
-    
+    const DirectoryEntry *TopFrameworkDir =
+        ::getTopFrameworkDir(FileMgr, FrameworkName);
+
     // Determine the name of the top-level framework.
     StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
 
@@ -1428,16 +1422,16 @@
 }
 
 
-HeaderSearch::LoadModuleMapResult 
+HeaderSearch::LoadModuleMapResult
 HeaderSearch::loadModuleMapFile(StringRef DirName, bool IsSystem,
                                 bool IsFramework) {
   if (const DirectoryEntry *Dir = FileMgr.getDirectory(DirName))
     return loadModuleMapFile(Dir, IsSystem, IsFramework);
-  
+
   return LMM_NoDirectory;
 }
 
-HeaderSearch::LoadModuleMapResult 
+HeaderSearch::LoadModuleMapResult
 HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir, bool IsSystem,
                                 bool IsFramework) {
   auto KnownDir = DirectoryHasModuleMap.find(Dir);
@@ -1506,7 +1500,7 @@
   }
 
   // Populate the list of modules.
-  for (ModuleMap::module_iterator M = ModMap.module_begin(), 
+  for (ModuleMap::module_iterator M = ModMap.module_begin(),
                                MEnd = ModMap.module_end();
        M != MEnd; ++M) {
     Modules.push_back(M->getValue());
Index: clang/include/clang/Lex/HeaderSearch.h
===================================================================
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -25,8 +25,8 @@
 #include <vector>
 
 namespace clang {
-  
-class DiagnosticsEngine;  
+
+class DiagnosticsEngine;
 class ExternalPreprocessorSource;
 class FileEntry;
 class FileManager;
@@ -62,9 +62,9 @@
   /// \brief Whether this structure is considered to already have been
   /// "resolved", meaning that it was loaded from the external source.
   unsigned Resolved : 1;
-  
+
   /// \brief Whether this is a header inside a framework that is currently
-  /// being built. 
+  /// being built.
   ///
   /// When a framework is being built, the headers have not yet been placed
   /// into the appropriate framework subdirectories, and therefore are
@@ -74,7 +74,7 @@
 
   /// \brief Whether this file has been looked up as a header.
   unsigned IsValid : 1;
-  
+
   /// \brief The number of times the file has been included already.
   unsigned short NumIncludes;
 
@@ -98,9 +98,9 @@
   /// \brief If this header came from a framework include, this is the name
   /// of the framework.
   StringRef Framework;
-  
+
   HeaderFileInfo()
-    : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), 
+    : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
       External(false), isModuleHeader(false), isCompilingModuleHeader(false),
       Resolved(false), IndexHeaderMapHeader(false), IsValid(0),
       NumIncludes(0), ControllingMacroID(0), ControllingMacro(nullptr)  {}
@@ -113,7 +113,7 @@
   /// \brief Determine whether this is a non-default header file info, e.g.,
   /// it corresponds to an actual header we've included or tried to include.
   bool isNonDefault() const {
-    return isImport || isPragmaOnce || NumIncludes || ControllingMacro || 
+    return isImport || isPragmaOnce || NumIncludes || ControllingMacro ||
       ControllingMacroID;
   }
 };
@@ -123,15 +123,15 @@
 class ExternalHeaderFileInfoSource {
 public:
   virtual ~ExternalHeaderFileInfoSource();
-  
+
   /// \brief Retrieve the header file information for the given file entry.
   ///
   /// \returns Header file information for the given file entry, with the
-  /// \c External bit set. If the file entry is not known, return a 
+  /// \c External bit set. If the file entry is not known, return a
   /// default-constructed \c HeaderFileInfo.
   virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0;
 };
-  
+
 /// \brief Encapsulates the information needed to find the file referenced
 /// by a \#include or \#include_next, (sub-)framework lookup, etc.
 class HeaderSearch {
@@ -172,7 +172,7 @@
 
   /// \brief The path to the module cache.
   std::string ModuleCachePath;
-  
+
   /// \brief All of the preprocessor-specific data about files that are
   /// included, indexed by the FileEntry's UID.
   mutable std::vector<HeaderFileInfo> FileInfo;
@@ -216,26 +216,26 @@
 
   /// \brief The mapping between modules and headers.
   mutable ModuleMap ModMap;
-  
+
   /// \brief Describes whether a given directory has a module map in it.
   llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap;
 
   /// \brief Set of module map files we've already loaded, and a flag indicating
   /// whether they were valid or not.
   llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
 
-  /// \brief Uniqued set of framework names, which is used to track which 
+  /// \brief Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
   llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
-  
+
   /// \brief Entity used to resolve the identifier IDs of controlling
   /// macros into IdentifierInfo pointers, and keep the identifire up to date,
   /// as needed.
   ExternalPreprocessorSource *ExternalLookup;
 
   /// \brief Entity used to look up stored header file information.
   ExternalHeaderFileInfoSource *ExternalSource;
-  
+
   // Various statistics we track for performance analysis.
   unsigned NumIncluded;
   unsigned NumMultiIncludeFileOptzn;
@@ -246,7 +246,7 @@
   void operator=(const HeaderSearch&) = delete;
 
   friend class DirectoryLookup;
-  
+
 public:
   HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts,
                SourceManager &SourceMgr, DiagnosticsEngine &Diags,
@@ -256,7 +256,7 @@
   /// \brief Retrieve the header-search options with which this header search
   /// was initialized.
   HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }
-  
+
   FileManager &getFileMgr() const { return FileMgr; }
 
   /// \brief Interface for setting the file search paths.
@@ -291,7 +291,7 @@
 
   /// \brief Map the source include name to the dest include name.
   ///
-  /// The Source should include the angle brackets or quotes, the dest 
+  /// The Source should include the angle brackets or quotes, the dest
   /// should not.  This allows for distinction between <> and "" headers.
   void AddIncludeAlias(StringRef Source, StringRef Dest) {
     if (!IncludeAliases)
@@ -317,15 +317,15 @@
   void setModuleCachePath(StringRef CachePath) {
     ModuleCachePath = CachePath;
   }
-  
+
   /// \brief Retrieve the path to the module cache.
   StringRef getModuleCachePath() const { return ModuleCachePath; }
 
   /// \brief Consider modules when including files from this directory.
   void setDirectoryHasModuleMap(const DirectoryEntry* Dir) {
     DirectoryHasModuleMap[Dir] = true;
   }
-  
+
   /// \brief Forget everything we know about headers so far.
   void ClearFileInfo() {
     FileInfo.clear();
@@ -338,16 +338,16 @@
   ExternalPreprocessorSource *getExternalLookup() const {
     return ExternalLookup;
   }
-  
+
   /// \brief Set the external source of header information.
   void SetExternalSource(ExternalHeaderFileInfoSource *ES) {
     ExternalSource = ES;
   }
-  
+
   /// \brief Set the target information for the header search, if not
   /// already known.
   void setTarget(const TargetInfo &Target);
-  
+
   /// \brief Given a "foo" or \<foo> reference, look up the indicated file,
   /// return null on failure.
   ///
@@ -471,16 +471,16 @@
   /// \brief Get filenames for all registered header maps.
   void getHeaderMapFileNames(SmallVectorImpl<std::string> &Names) const;
 
-  /// \brief Retrieve the name of the module file that should be used to 
+  /// \brief Retrieve the name of the module file that should be used to
   /// load the given module.
   ///
   /// \param Module The module whose module file name will be returned.
   ///
   /// \returns The name of the module file that corresponds to this module,
   /// or an empty string if this module does not correspond to any module file.
   std::string getModuleFileName(Module *Module);
 
-  /// \brief Retrieve the name of the module file that should be used to 
+  /// \brief Retrieve the name of the module file that should be used to
   /// load a module with the given name.
   ///
   /// \param ModuleName The module whose module file name will be returned.
@@ -510,7 +510,7 @@
   /// \c nullptr if none is found.
   const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
                                        bool IsFramework);
-  
+
   void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; }
 
   /// \brief Determine whether there is a module map that may map the header
@@ -526,7 +526,7 @@
   /// header directories.
   bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root,
                     bool IsSystem);
-  
+
   /// \brief Retrieve the module that corresponds to the given file, if any.
   ///
   /// \param File The header that we wish to map to a module.
@@ -575,7 +575,7 @@
   /// frameworks.
   ///
   /// \returns The module, if found; otherwise, null.
-  Module *loadFrameworkModule(StringRef Name, 
+  Module *loadFrameworkModule(StringRef Name,
                               const DirectoryEntry *Dir,
                               bool IsSystem);
 
@@ -605,18 +605,18 @@
   /// \brief Look up the file with the specified name and determine its owning
   /// module.
   const FileEntry *
-  getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,
+  getFileAndSuggestModule(StringRef FileName,
                           const DirectoryEntry *Dir, bool IsSystemHeaderDir,
                           Module *RequestingModule,
                           ModuleMap::KnownHeader *SuggestedModule);
 
 public:
   /// \brief Retrieve the module map.
   ModuleMap &getModuleMap() { return ModMap; }
-  
+
   /// \brief Retrieve the module map.
   const ModuleMap &getModuleMap() const { return ModMap; }
-  
+
   unsigned header_file_size() const { return FileInfo.size(); }
 
   /// \brief Return the HeaderFileInfo structure for the specified FileEntry,
@@ -657,7 +657,7 @@
 
   /// \brief Retrieve a uniqued framework name.
   StringRef getUniqueFrameworkName(StringRef Framework);
-  
+
   /// \brief Suggest a path by which the specified file could be found, for
   /// use in diagnostics to suggest a #include.
   ///
@@ -667,7 +667,7 @@
                                               bool *IsSystem = nullptr);
 
   void PrintStats();
-  
+
   size_t getTotalMemory() const;
 
 private:
Index: clang/include/clang/Lex/DirectoryLookup.h
===================================================================
--- clang/include/clang/Lex/DirectoryLookup.h
+++ clang/include/clang/Lex/DirectoryLookup.h
@@ -24,7 +24,7 @@
 class FileEntry;
 class HeaderSearch;
 class Module;
-  
+
 /// DirectoryLookup - This class represents one entry in the search list that
 /// specifies the search order for directories in \#include directives.  It
 /// represents either a directory, a framework, or a headermap.
@@ -54,14 +54,14 @@
   /// LookupType - This indicates whether this DirectoryLookup object is a
   /// normal directory, a framework, or a headermap.
   unsigned LookupType : 2;
-  
+
   /// \brief Whether this is a header map used when building a framework.
   unsigned IsIndexHeaderMap : 1;
 
   /// \brief Whether we've performed an exhaustive search for module maps
   /// within the subdirectories of this directory.
   unsigned SearchedAllModuleMaps : 1;
-  
+
 public:
   /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
   /// 'dir'.
@@ -140,20 +140,17 @@
   }
 
   /// \brief Whether this header map is building a framework or not.
-  bool isIndexHeaderMap() const { 
-    return isHeaderMap() && IsIndexHeaderMap; 
+  bool isIndexHeaderMap() const {
+    return isHeaderMap() && IsIndexHeaderMap;
   }
-  
+
   /// LookupFile - Lookup the specified file in this search path, returning it
   /// if it exists or returning null if not.
   ///
   /// \param Filename The file to look up relative to the search paths.
   ///
   /// \param HS The header search instance to search with.
   ///
-  /// \param IncludeLoc the source location of the #include or #import
-  /// directive.
-  ///
   /// \param SearchPath If not NULL, will be set to the search path relative
   /// to which the file was found.
   ///
@@ -175,7 +172,6 @@
   /// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this
   /// vector and point Filename to it.
   const FileEntry *LookupFile(StringRef &Filename, HeaderSearch &HS,
-                              SourceLocation IncludeLoc,
                               SmallVectorImpl<char> *SearchPath,
                               SmallVectorImpl<char> *RelativePath,
                               Module *RequestingModule,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to