14 #ifndef LLVM_CLANG_LEX_HEADERSEARCH_H
15 #define LLVM_CLANG_LEX_HEADERSEARCH_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/ADT/StringSet.h"
23 #include "llvm/Support/Allocator.h"
29 class DiagnosticsEngine;
30 class ExternalPreprocessorSource;
33 class HeaderSearchOptions;
153 struct FrameworkCacheEntry {
160 bool IsUserSpecifiedSystemFramework;
174 std::vector<DirectoryLookup> SearchDirs;
175 unsigned AngledDirIdx;
176 unsigned SystemDirIdx;
185 std::vector<std::pair<std::string, bool> > SystemHeaderPrefixes;
188 std::string ModuleCachePath;
192 std::vector<HeaderFileInfo> FileInfo;
195 struct LookupFileCacheInfo {
204 const char *MappedName;
207 LookupFileCacheInfo(): StartIdx(0), HitIdx(0), MappedName(
nullptr) {}
209 void reset(
unsigned StartIdx) {
210 this->StartIdx = StartIdx;
211 this->MappedName =
nullptr;
214 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
218 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
223 typedef llvm::StringMap<std::string, llvm::BumpPtrAllocator>
225 std::unique_ptr<IncludeAliasMap> IncludeAliases;
229 std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps;
235 llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap;
239 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
243 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
254 unsigned NumIncluded;
255 unsigned NumMultiIncludeFileOptzn;
256 unsigned NumFrameworkLookups, NumSubFrameworkLookups;
280 unsigned angledDirIdx,
unsigned systemDirIdx,
281 bool noCurDirSearch) {
282 assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() &&
283 "Directory indicies are unordered");
285 AngledDirIdx = angledDirIdx;
286 SystemDirIdx = systemDirIdx;
287 NoCurDirSearch = noCurDirSearch;
293 unsigned idx = isAngled ? SystemDirIdx : AngledDirIdx;
294 SearchDirs.insert(SearchDirs.begin() + idx, dir);
302 SystemHeaderPrefixes.assign(
P.begin(),
P.end());
314 IncludeAliases.reset(
new IncludeAliasMap);
315 (*IncludeAliases)[Source] = Dest;
323 assert(IncludeAliases &&
"Trying to map headers when there's no map");
326 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
327 if (Iter != IncludeAliases->end())
334 ModuleCachePath = CachePath;
342 DirectoryHasModuleMap[Dir] =
true;
351 ExternalLookup = EPS;
355 return ExternalLookup;
397 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,
417 return FrameworkMap[FWName];
426 bool isImport,
Module *CorrespondingModule);
451 bool IsCompiledModuleHeader);
570 Module *loadFrameworkModule(StringRef Name,
580 return const_cast<HeaderSearch*
>(
this)->getFileInfo(FE);
600 return SearchDirs.begin();
603 return SearchDirs.begin() + AngledDirIdx;
607 return SearchDirs.begin() + AngledDirIdx;
610 return SearchDirs.begin() + SystemDirIdx;
614 return SearchDirs.begin() + SystemDirIdx;
630 enum LoadModuleMapResult {
642 LoadModuleMapResult loadModuleMapFileImpl(
const FileEntry *File,
644 const DirectoryEntry *Dir);
667 bool IsSystem,
bool IsFramework);
670 HeaderFileInfo &getFileInfo(
const FileEntry *FE);
Implements support for file system lookup, file system caching, and directory search management...
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Describes a module or submodule.
Concrete class used by the front-end to report problems and issues.
ModuleHeaderRole
Flags describing the role of a module header.
Exposes information about the current target.
Abstract interface for external sources of preprocessor information.
The result type of a method or function.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
Cached information about one file (either on disk or in the virtual file system). ...
Cached information about one directory (either on disk or in the virtual file system).
This class handles loading and caching of source files into memory.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.