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());
821 bool AllowExtraModuleMapSearch =
false);
836 StringRef ModuleMapPath,
837 StringRef NormalizedCachePath);
854 bool IsSystem,
bool ImplicitlyDiscovered);
872 bool IsSystemHeaderDir);
879 bool findUsableModuleForFrameworkHeader(
890 bool OpenFile =
true,
bool CacheFailures =
true);
894 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
930 assert(n < SearchDirs.size());
944 return {*
this, AngledDirIdx};
949 return {*
this, SystemDirIdx};
952 return {*
this, SearchDirs.size()};
978 llvm::StringRef MainFile,
979 bool *IsAngled =
nullptr)
const;
991 llvm::StringRef WorkingDir,
992 llvm::StringRef MainFile,
993 bool *IsAngled =
nullptr)
const;
1001 enum ModuleMapResult {
1003 MMR_AlreadyProcessed,
1013 MMR_InvalidModuleMap
1016 ModuleMapResult parseAndLoadModuleMapFileImpl(
1017 FileEntryRef
File,
bool IsSystem,
bool ImplicitlyDiscovered,
1018 DirectoryEntryRef Dir, FileID ID = FileID(),
unsigned *Offset =
nullptr,
1019 bool DiagnosePrivMMap =
false);
1021 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
1022 bool ImplicitlyDiscovered,
1023 DirectoryEntryRef Dir,
1024 FileID ID = FileID());
1036 bool ImplicitlyDiscovered,
1049 bool ImplicitlyDiscovered,
1052 ModuleMapResult parseModuleMapFile(StringRef DirName,
bool IsSystem,
1053 bool ImplicitlyDiscovered,
1055 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir,
bool IsSystem,
1056 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.