242 friend ConstSearchDirIterator;
243 friend SearchDirIterator;
249 llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
258 std::vector<DirectoryLookup> SearchDirs;
261 std::vector<bool> SearchDirsUsage;
262 unsigned AngledDirIdx = 0;
263 unsigned SystemDirIdx = 0;
268 llvm::StringMap<unsigned, llvm::BumpPtrAllocator> SearchDirHeaderMapIndex;
271 unsigned FirstNonHeaderMapSearchDirIdx = 0;
279 std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes;
282 std::string ContextHash;
285 std::string SpecificModuleCachePath;
289 size_t NormalizedModuleCachePathLen = 0;
292 mutable llvm::MapVector<FileEntryRef, HeaderFileInfo> FileInfo;
295 struct LookupFileCacheInfo {
297 const Module *RequestingModule =
nullptr;
302 ConstSearchDirIterator StartIt =
nullptr;
305 ConstSearchDirIterator HitIt =
nullptr;
309 const char *MappedName =
nullptr;
312 LookupFileCacheInfo() =
default;
314 void reset(
const Module *NewRequestingModule,
315 ConstSearchDirIterator NewStartIt) {
316 RequestingModule = NewRequestingModule;
317 StartIt = NewStartIt;
318 MappedName =
nullptr;
321 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
327 llvm::StringMap<llvm::SmallPtrSet<const FileEntry *, 1>> ShadowCheckedHeaders;
331 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
336 using IncludeAliasMap =
337 llvm::StringMap<std::string, llvm::BumpPtrAllocator>;
338 std::unique_ptr<IncludeAliasMap> IncludeAliases;
341 std::vector<std::pair<FileEntryRef, std::unique_ptr<HeaderMap>>> HeaderMaps;
344 mutable ModuleMap ModMap;
346 struct ModuleMapDirectoryState {
356 llvm::StringMap<llvm::SmallVector<StringRef, 1>> HeaderToModules{};
358 llvm::SmallVector<std::pair<std::string, StringRef>, 2>
359 UmbrellaDirModules{};
361 llvm::SmallVector<StringRef, 2> UmbrellaHeaderModules{};
365 llvm::DenseMap<const DirectoryEntry *, ModuleMapDirectoryState>
370 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
374 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMaps;
377 llvm::DenseMap<const FileEntry *, llvm::SmallString<64>> IncludeNames;
381 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
386 ExternalPreprocessorSource *ExternalLookup =
nullptr;
389 ExternalHeaderFileInfoSource *ExternalSource =
nullptr;
393 void indexInitialHeaderMaps();
399 void buildModuleMapIndex(DirectoryEntryRef Dir,
400 ModuleMapDirectoryState &MMState);
402 void processModuleMapForIndex(
const modulemap::ModuleMapFile &MMF,
403 DirectoryEntryRef MMDir, StringRef PathPrefix,
404 ModuleMapDirectoryState &MMState);
406 void processExternModuleDeclForIndex(
const modulemap::ExternModuleDecl &EMD,
407 DirectoryEntryRef MMDir,
408 StringRef PathPrefix,
409 ModuleMapDirectoryState &MMState);
411 void processModuleDeclForIndex(
const modulemap::ModuleDecl &MD,
412 StringRef ModuleName, DirectoryEntryRef MMDir,
413 StringRef PathPrefix,
414 ModuleMapDirectoryState &MMState);
416 void addToModuleMapIndex(StringRef RelPath, StringRef ModuleName,
417 StringRef PathPrefix,
418 ModuleMapDirectoryState &MMState);
422 SmallVector<StringRef, 1>
423 findMatchingModulesInIndex(StringRef RelativePath,
424 const ModuleMapDirectoryState &MMState)
const;
427 HeaderSearch(
const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
428 DiagnosticsEngine &Diags,
const LangOptions &LangOpts,
429 const TargetInfo *
Target);
442 void SetSearchPaths(std::vector<DirectoryLookup> dirs,
unsigned angledDirIdx,
443 unsigned systemDirIdx,
444 llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);
451 SearchDirs.push_back(dir);
452 SearchDirsUsage.push_back(
false);
457 SystemHeaderPrefixes.assign(P.begin(), P.end());
469 IncludeAliases.reset(
new IncludeAliasMap);
470 (*IncludeAliases)[Source] = std::string(Dest);
478 assert(IncludeAliases &&
"Trying to map headers when there's no map");
481 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
482 if (Iter != IncludeAliases->end())
493 return SpecificModuleCachePath;
512 ExternalLookup = EPS;
516 return ExternalLookup;
527 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
572 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
575 bool *IsMapped,
bool *IsFrameworkFound,
bool SkipCache =
false,
576 bool BuildSystemModule =
false,
bool OpenFile =
true,
577 bool CacheFailures =
true);
593 return FrameworkMap[FWName];
605 bool isImport,
bool ModulesEnabled,
Module *M,
606 bool &IsFirstIncludeOfFile);
630 bool isCompilingModuleHeader);
693 bool FileMapOnly =
false);
715 StringRef ModuleMapPath);
733 bool AllowSearch =
true,
734 bool AllowExtraModuleMapSearch =
false);
760 bool AllowTextual =
false,
761 bool AllowExcluded =
false)
const;
790 bool ImplicitlyDiscovered,
792 unsigned *Offset =
nullptr,
793 StringRef OriginalModuleMapFile = StringRef());
804 bool ImplicitlyDiscovered);
824 bool AllowExtraModuleMapSearch =
false);
833 bool lookupModuleWithPrivateFallbacks(StringRef ModuleName,
835 bool AllowExtraModuleMapSearch,
855 bool lookupModuleImpl(StringRef ModuleName, StringRef SearchName,
857 bool AllowExtraModuleMapSearch,
bool Load);
872 StringRef ModuleMapPath,
873 StringRef NormalizedCachePath);
890 bool IsSystem,
bool ImplicitlyDiscovered);
894 bool ImplicitlyDiscovered,
bool Load);
898 void parseSubdirectoryModuleMaps(
DirectoryLookup &SearchDir,
bool Load);
912 bool IsSystemHeaderDir);
919 bool findUsableModuleForFrameworkHeader(
930 bool OpenFile =
true,
bool CacheFailures =
true);
934 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
970 assert(n < SearchDirs.size());
984 return {*
this, AngledDirIdx};
989 return {*
this, SystemDirIdx};
992 return {*
this, SearchDirs.size()};
1018 llvm::StringRef MainFile,
1019 bool *IsAngled =
nullptr)
const;
1031 llvm::StringRef WorkingDir,
1032 llvm::StringRef MainFile,
1033 bool *IsAngled =
nullptr)
const;
1041 enum ModuleMapResult {
1043 MMR_AlreadyProcessed,
1053 MMR_InvalidModuleMap
1057 static bool hasModuleMapError(ModuleMapResult
Result);
1060 ModuleMapResult parseAndLoadModuleMapFileImpl(
1061 FileEntryRef
File,
bool IsSystem,
bool ImplicitlyDiscovered,
1062 DirectoryEntryRef Dir, FileID ID = FileID(),
unsigned *Offset =
nullptr,
1063 bool DiagnosePrivMMap =
false);
1067 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
1068 bool ImplicitlyDiscovered,
1069 DirectoryEntryRef Dir,
1070 FileID ID = FileID());
1074 getModuleMapHomeDir(FileEntryRef
File, StringRef OriginalModuleMapFile);
1086 bool ImplicitlyDiscovered,
1099 bool ImplicitlyDiscovered,
1105 bool ImplicitlyDiscovered,
1110 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.