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 mutable std::vector<HeaderFileInfo> FileInfo;
290 struct LookupFileCacheInfo {
292 const Module *RequestingModule =
nullptr;
297 ConstSearchDirIterator StartIt =
nullptr;
300 ConstSearchDirIterator HitIt =
nullptr;
304 const char *MappedName =
nullptr;
307 LookupFileCacheInfo() =
default;
309 void reset(
const Module *NewRequestingModule,
310 ConstSearchDirIterator NewStartIt) {
311 RequestingModule = NewRequestingModule;
312 StartIt = NewStartIt;
313 MappedName =
nullptr;
316 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
320 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
325 using IncludeAliasMap =
326 llvm::StringMap<std::string, llvm::BumpPtrAllocator>;
327 std::unique_ptr<IncludeAliasMap> IncludeAliases;
330 std::vector<std::pair<FileEntryRef, std::unique_ptr<HeaderMap>>> HeaderMaps;
333 mutable ModuleMap ModMap;
335 struct ModuleMapDirectoryState {
345 llvm::StringMap<llvm::SmallVector<StringRef, 1>> HeaderToModules{};
347 llvm::SmallVector<std::pair<std::string, StringRef>, 2>
348 UmbrellaDirModules{};
350 llvm::SmallVector<StringRef, 2> UmbrellaHeaderModules{};
354 llvm::DenseMap<const DirectoryEntry *, ModuleMapDirectoryState>
359 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
363 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMaps;
366 llvm::DenseMap<const FileEntry *, llvm::SmallString<64>> IncludeNames;
370 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
375 ExternalPreprocessorSource *ExternalLookup =
nullptr;
378 ExternalHeaderFileInfoSource *ExternalSource =
nullptr;
382 void indexInitialHeaderMaps();
388 void buildModuleMapIndex(DirectoryEntryRef Dir,
389 ModuleMapDirectoryState &MMState);
391 void processModuleMapForIndex(
const modulemap::ModuleMapFile &MMF,
392 DirectoryEntryRef MMDir, StringRef PathPrefix,
393 ModuleMapDirectoryState &MMState);
395 void processExternModuleDeclForIndex(
const modulemap::ExternModuleDecl &EMD,
396 DirectoryEntryRef MMDir,
397 StringRef PathPrefix,
398 ModuleMapDirectoryState &MMState);
400 void processModuleDeclForIndex(
const modulemap::ModuleDecl &MD,
401 StringRef ModuleName, DirectoryEntryRef MMDir,
402 StringRef PathPrefix,
403 ModuleMapDirectoryState &MMState);
405 void addToModuleMapIndex(StringRef RelPath, StringRef ModuleName,
406 StringRef PathPrefix,
407 ModuleMapDirectoryState &MMState);
410 HeaderSearch(
const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
411 DiagnosticsEngine &Diags,
const LangOptions &LangOpts,
412 const TargetInfo *
Target);
425 void SetSearchPaths(std::vector<DirectoryLookup> dirs,
unsigned angledDirIdx,
426 unsigned systemDirIdx,
427 llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry);
434 SearchDirs.push_back(dir);
435 SearchDirsUsage.push_back(
false);
440 SystemHeaderPrefixes.assign(P.begin(), P.end());
452 IncludeAliases.reset(
new IncludeAliasMap);
453 (*IncludeAliases)[Source] = std::string(Dest);
461 assert(IncludeAliases &&
"Trying to map headers when there's no map");
464 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
465 if (Iter != IncludeAliases->end())
475 SpecificModuleCachePath = std::string(Path);
483 return SpecificModuleCachePath;
492 ExternalLookup = EPS;
496 return ExternalLookup;
507 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
552 ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
555 bool *IsMapped,
bool *IsFrameworkFound,
bool SkipCache =
false,
556 bool BuildSystemModule =
false,
bool OpenFile =
true,
557 bool CacheFailures =
true);
573 return FrameworkMap[FWName];
585 bool isImport,
bool ModulesEnabled,
Module *M,
586 bool &IsFirstIncludeOfFile);
610 bool isCompilingModuleHeader);
673 bool FileMapOnly =
false);
695 StringRef ModuleMapPath);
713 bool AllowSearch =
true,
714 bool AllowExtraModuleMapSearch =
false);
740 bool AllowTextual =
false,
741 bool AllowExcluded =
false)
const;
769 unsigned *Offset =
nullptr,
770 StringRef OriginalModuleMapFile = StringRef());
798 bool AllowExtraModuleMapSearch =
false);
812 std::string getCachedModuleFileNameImpl(StringRef ModuleName,
813 StringRef ModuleMapPath,
814 StringRef CachePath);
841 bool IsSystemHeaderDir);
848 bool findUsableModuleForFrameworkHeader(
859 bool OpenFile =
true,
bool CacheFailures =
true);
863 void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
900 assert(n < SearchDirs.size());
914 return {*
this, AngledDirIdx};
919 return {*
this, SystemDirIdx};
922 return {*
this, SearchDirs.size()};
948 llvm::StringRef MainFile,
949 bool *IsAngled =
nullptr)
const;
961 llvm::StringRef WorkingDir,
962 llvm::StringRef MainFile,
963 bool *IsAngled =
nullptr)
const;
971 enum ModuleMapResult {
973 MMR_AlreadyProcessed,
986 ModuleMapResult parseAndLoadModuleMapFileImpl(FileEntryRef
File,
988 DirectoryEntryRef Dir,
989 FileID ID = FileID(),
990 unsigned *Offset =
nullptr,
991 bool DiagnosePrivMMap =
false);
993 ModuleMapResult parseModuleMapFileImpl(FileEntryRef
File,
bool IsSystem,
994 DirectoryEntryRef Dir,
995 FileID ID = FileID());
1018 bool IsSystem,
bool IsFramework);
1020 ModuleMapResult parseModuleMapFile(StringRef DirName,
bool IsSystem,
1022 ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir,
bool IsSystem,
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.