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);
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,
924 assert(n < SearchDirs.size());
938 return {*
this, AngledDirIdx};
943 return {*
this, SystemDirIdx};
946 return {*
this, SearchDirs.size()};
972 llvm::StringRef MainFile,
973 bool *IsAngled =
nullptr)
const;
985 llvm::StringRef WorkingDir,
986 llvm::StringRef MainFile,
987 bool *IsAngled =
nullptr)
const;
995 enum ModuleMapResult {
997 MMR_AlreadyProcessed,
1007 MMR_InvalidModuleMap
1010 ModuleMapResult parseAndLoadModuleMapFileImpl(
1011 FileEntryRef
File,
bool IsSystem,
bool ImplicitlyDiscovered,
1012 DirectoryEntryRef Dir, FileID ID = FileID(),
unsigned *Offset =
nullptr,
1013 bool DiagnosePrivMMap =
false);
1015 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
1016 bool ImplicitlyDiscovered,
1017 DirectoryEntryRef Dir,
1018 FileID ID = FileID());
1030 bool ImplicitlyDiscovered,
1043 bool ImplicitlyDiscovered,
1046 ModuleMapResult parseModuleMapFile(StringRef DirName,
bool IsSystem,
1047 bool ImplicitlyDiscovered,
1049 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir,
bool IsSystem,
1050 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.