240 friend ConstSearchDirIterator;
241 friend SearchDirIterator;
247 llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
256 std::vector<DirectoryLookup> SearchDirs;
259 std::vector<bool> SearchDirsUsage;
260 unsigned AngledDirIdx = 0;
261 unsigned SystemDirIdx = 0;
266 llvm::StringMap<unsigned, llvm::BumpPtrAllocator> SearchDirHeaderMapIndex;
269 unsigned FirstNonHeaderMapSearchDirIdx = 0;
277 std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes;
280 std::string ContextHash;
283 std::string SpecificModuleCachePath;
287 size_t NormalizedModuleCachePathLen = 0;
291 mutable std::vector<HeaderFileInfo> FileInfo;
294 struct LookupFileCacheInfo {
296 const Module *RequestingModule =
nullptr;
301 ConstSearchDirIterator StartIt =
nullptr;
304 ConstSearchDirIterator HitIt =
nullptr;
308 const char *MappedName =
nullptr;
311 LookupFileCacheInfo() =
default;
313 void reset(
const Module *NewRequestingModule,
314 ConstSearchDirIterator NewStartIt) {
315 RequestingModule = NewRequestingModule;
316 StartIt = NewStartIt;
317 MappedName =
nullptr;
320 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
324 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
329 using IncludeAliasMap =
330 llvm::StringMap<std::string, llvm::BumpPtrAllocator>;
331 std::unique_ptr<IncludeAliasMap> IncludeAliases;
334 std::vector<std::pair<FileEntryRef, std::unique_ptr<HeaderMap>>> HeaderMaps;
337 mutable ModuleMap ModMap;
339 struct ModuleMapDirectoryState {
349 llvm::StringMap<llvm::SmallVector<StringRef, 1>> HeaderToModules{};
351 llvm::SmallVector<std::pair<std::string, StringRef>, 2>
352 UmbrellaDirModules{};
354 llvm::SmallVector<StringRef, 2> UmbrellaHeaderModules{};
358 llvm::DenseMap<const DirectoryEntry *, ModuleMapDirectoryState>
363 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
367 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMaps;
370 llvm::DenseMap<const FileEntry *, llvm::SmallString<64>> IncludeNames;
374 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
379 ExternalPreprocessorSource *ExternalLookup =
nullptr;
382 ExternalHeaderFileInfoSource *ExternalSource =
nullptr;
386 void indexInitialHeaderMaps();
392 void buildModuleMapIndex(DirectoryEntryRef Dir,
393 ModuleMapDirectoryState &MMState);
395 void processModuleMapForIndex(
const modulemap::ModuleMapFile &MMF,
396 DirectoryEntryRef MMDir, StringRef PathPrefix,
397 ModuleMapDirectoryState &MMState);
399 void processExternModuleDeclForIndex(
const modulemap::ExternModuleDecl &EMD,
400 DirectoryEntryRef MMDir,
401 StringRef PathPrefix,
402 ModuleMapDirectoryState &MMState);
404 void processModuleDeclForIndex(
const modulemap::ModuleDecl &MD,
405 StringRef ModuleName, DirectoryEntryRef MMDir,
406 StringRef PathPrefix,
407 ModuleMapDirectoryState &MMState);
409 void addToModuleMapIndex(StringRef RelPath, StringRef ModuleName,
410 StringRef PathPrefix,
411 ModuleMapDirectoryState &MMState);
414 HeaderSearch(
const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
415 DiagnosticsEngine &Diags,
const LangOptions &LangOpts,
416 const TargetInfo *
Target);
429 void SetSearchPaths(std::vector<DirectoryLookup> dirs,
unsigned angledDirIdx,
430 unsigned systemDirIdx,
431 llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);
438 SearchDirs.push_back(dir);
439 SearchDirsUsage.push_back(
false);
444 SystemHeaderPrefixes.assign(P.begin(), P.end());
456 IncludeAliases.reset(
new IncludeAliasMap);
457 (*IncludeAliases)[Source] = std::string(Dest);
465 assert(IncludeAliases &&
"Trying to map headers when there's no map");
468 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
469 if (Iter != IncludeAliases->end())
480 return SpecificModuleCachePath;
499 ExternalLookup = EPS;
503 return ExternalLookup;
514 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
559 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
562 bool *IsMapped,
bool *IsFrameworkFound,
bool SkipCache =
false,
563 bool BuildSystemModule =
false,
bool OpenFile =
true,
564 bool CacheFailures =
true);
580 return FrameworkMap[FWName];
592 bool isImport,
bool ModulesEnabled,
Module *M,
593 bool &IsFirstIncludeOfFile);
617 bool isCompilingModuleHeader);
680 bool FileMapOnly =
false);
702 StringRef ModuleMapPath);
720 bool AllowSearch =
true,
721 bool AllowExtraModuleMapSearch =
false);
747 bool AllowTextual =
false,
748 bool AllowExcluded =
false)
const;
777 bool ImplicitlyDiscovered,
779 unsigned *Offset =
nullptr,
780 StringRef OriginalModuleMapFile = StringRef());
808 bool AllowExtraModuleMapSearch =
false);
822 std::string getCachedModuleFileNameImpl(StringRef ModuleName,
823 StringRef ModuleMapPath,
824 StringRef CachePath);
841 bool IsSystem,
bool ImplicitlyDiscovered);
854 bool IsSystemHeaderDir);
861 bool findUsableModuleForFrameworkHeader(
872 bool OpenFile =
true,
bool CacheFailures =
true);
876 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
913 assert(n < SearchDirs.size());
927 return {*
this, AngledDirIdx};
932 return {*
this, SystemDirIdx};
935 return {*
this, SearchDirs.size()};
961 llvm::StringRef MainFile,
962 bool *IsAngled =
nullptr)
const;
974 llvm::StringRef WorkingDir,
975 llvm::StringRef MainFile,
976 bool *IsAngled =
nullptr)
const;
984 enum ModuleMapResult {
986 MMR_AlreadyProcessed,
999 ModuleMapResult parseAndLoadModuleMapFileImpl(
1000 FileEntryRef
File,
bool IsSystem,
bool ImplicitlyDiscovered,
1001 DirectoryEntryRef Dir, FileID ID = FileID(),
unsigned *Offset =
nullptr,
1002 bool DiagnosePrivMMap =
false);
1004 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
1005 bool ImplicitlyDiscovered,
1006 DirectoryEntryRef Dir,
1007 FileID ID = FileID());
1019 bool ImplicitlyDiscovered,
1032 bool ImplicitlyDiscovered,
1035 ModuleMapResult parseModuleMapFile(StringRef DirName,
bool IsSystem,
1036 bool ImplicitlyDiscovered,
1038 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir,
bool IsSystem,
1039 bool ImplicitlyDiscovered,
A reference to a DirectoryEntry that includes the name of the directory as it was accessed by the Fil...
Cached information about one directory (either on disk or in the virtual file system).
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Cached information about one file (either on disk or in the virtual file system).
This structure is used to record entries in our framework cache.
bool IsUserSpecifiedSystemFramework
Whether this framework has been "user-specified" to be treated as if it were a system framework (even...
OptionalDirectoryEntryRef Directory
The directory entry which should be used for the cached framework.