241 friend ConstSearchDirIterator;
242 friend SearchDirIterator;
248 llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
257 std::vector<DirectoryLookup> SearchDirs;
260 std::vector<bool> SearchDirsUsage;
261 unsigned AngledDirIdx = 0;
262 unsigned SystemDirIdx = 0;
267 llvm::StringMap<unsigned, llvm::BumpPtrAllocator> SearchDirHeaderMapIndex;
270 unsigned FirstNonHeaderMapSearchDirIdx = 0;
278 std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes;
281 std::string ContextHash;
284 std::string SpecificModuleCachePath;
288 size_t NormalizedModuleCachePathLen = 0;
291 mutable llvm::MapVector<FileEntryRef, 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);
415 SmallVector<StringRef, 1>
416 findMatchingModulesInIndex(StringRef RelativePath,
417 const ModuleMapDirectoryState &MMState)
const;
420 HeaderSearch(
const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
421 DiagnosticsEngine &Diags,
const LangOptions &LangOpts,
422 const TargetInfo *
Target);
435 void SetSearchPaths(std::vector<DirectoryLookup> dirs,
unsigned angledDirIdx,
436 unsigned systemDirIdx,
437 llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);
444 SearchDirs.push_back(dir);
445 SearchDirsUsage.push_back(
false);
450 SystemHeaderPrefixes.assign(P.begin(), P.end());
462 IncludeAliases.reset(
new IncludeAliasMap);
463 (*IncludeAliases)[Source] = std::string(Dest);
471 assert(IncludeAliases &&
"Trying to map headers when there's no map");
474 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
475 if (Iter != IncludeAliases->end())
486 return SpecificModuleCachePath;
505 ExternalLookup = EPS;
509 return ExternalLookup;
520 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
565 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
568 bool *IsMapped,
bool *IsFrameworkFound,
bool SkipCache =
false,
569 bool BuildSystemModule =
false,
bool OpenFile =
true,
570 bool CacheFailures =
true);
586 return FrameworkMap[FWName];
598 bool isImport,
bool ModulesEnabled,
Module *M,
599 bool &IsFirstIncludeOfFile);
623 bool isCompilingModuleHeader);
686 bool FileMapOnly =
false);
708 StringRef ModuleMapPath);
726 bool AllowSearch =
true,
727 bool AllowExtraModuleMapSearch =
false);
753 bool AllowTextual =
false,
754 bool AllowExcluded =
false)
const;
783 bool ImplicitlyDiscovered,
785 unsigned *Offset =
nullptr,
786 StringRef OriginalModuleMapFile = StringRef());
814 bool AllowExtraModuleMapSearch =
false);
829 StringRef ModuleMapPath,
830 StringRef NormalizedCachePath);
847 bool IsSystem,
bool ImplicitlyDiscovered);
865 bool IsSystemHeaderDir);
872 bool findUsableModuleForFrameworkHeader(
883 bool OpenFile =
true,
bool CacheFailures =
true);
887 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
923 assert(n < SearchDirs.size());
937 return {*
this, AngledDirIdx};
942 return {*
this, SystemDirIdx};
945 return {*
this, SearchDirs.size()};
971 llvm::StringRef MainFile,
972 bool *IsAngled =
nullptr)
const;
984 llvm::StringRef WorkingDir,
985 llvm::StringRef MainFile,
986 bool *IsAngled =
nullptr)
const;
994 enum ModuleMapResult {
996 MMR_AlreadyProcessed,
1006 MMR_InvalidModuleMap
1009 ModuleMapResult parseAndLoadModuleMapFileImpl(
1010 FileEntryRef
File,
bool IsSystem,
bool ImplicitlyDiscovered,
1011 DirectoryEntryRef Dir, FileID ID = FileID(),
unsigned *Offset =
nullptr,
1012 bool DiagnosePrivMMap =
false);
1014 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
1015 bool ImplicitlyDiscovered,
1016 DirectoryEntryRef Dir,
1017 FileID ID = FileID());
1029 bool ImplicitlyDiscovered,
1042 bool ImplicitlyDiscovered,
1045 ModuleMapResult parseModuleMapFile(StringRef DirName,
bool IsSystem,
1046 bool ImplicitlyDiscovered,
1048 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir,
bool IsSystem,
1049 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.