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;
139 struct FrameworkCacheEntry {
146 bool IsUserSpecifiedSystemFramework;
150 std::shared_ptr<HeaderSearchOptions> HSOpts;
160 std::vector<DirectoryLookup> SearchDirs;
161 unsigned AngledDirIdx;
162 unsigned SystemDirIdx;
171 std::vector<std::pair<std::string, bool> > SystemHeaderPrefixes;
174 std::string ModuleCachePath;
178 mutable std::vector<HeaderFileInfo> FileInfo;
181 struct LookupFileCacheInfo {
190 const char *MappedName;
193 LookupFileCacheInfo(): StartIdx(0), HitIdx(0), MappedName(
nullptr) {}
195 void reset(
unsigned StartIdx) {
196 this->StartIdx = StartIdx;
197 this->MappedName =
nullptr;
200 llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
204 llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
209 typedef llvm::StringMap<std::string, llvm::BumpPtrAllocator>
211 std::unique_ptr<IncludeAliasMap> IncludeAliases;
215 std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps;
221 llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap;
225 llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
229 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
240 unsigned NumIncluded;
241 unsigned NumMultiIncludeFileOptzn;
242 unsigned NumFrameworkLookups, NumSubFrameworkLookups;
251 HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts,
264 unsigned angledDirIdx,
unsigned systemDirIdx,
265 bool noCurDirSearch) {
266 assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() &&
267 "Directory indicies are unordered");
269 AngledDirIdx = angledDirIdx;
270 SystemDirIdx = systemDirIdx;
271 NoCurDirSearch = noCurDirSearch;
277 unsigned idx = isAngled ? SystemDirIdx : AngledDirIdx;
278 SearchDirs.insert(SearchDirs.begin() + idx, dir);
286 SystemHeaderPrefixes.assign(
P.begin(),
P.end());
298 IncludeAliases.reset(
new IncludeAliasMap);
299 (*IncludeAliases)[Source] = Dest;
307 assert(IncludeAliases &&
"Trying to map headers when there's no map");
310 IncludeAliasMap::const_iterator Iter = IncludeAliases->find(Source);
311 if (Iter != IncludeAliases->end())
318 ModuleCachePath = CachePath;
326 DirectoryHasModuleMap[Dir] =
true;
335 ExternalLookup = EPS;
339 return ExternalLookup;
384 ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,
387 bool *IsMapped,
bool SkipCache =
false,
bool BuildSystemModule =
false);
403 return FrameworkMap[FWName];
412 bool isImport,
bool ModulesEnabled,
413 Module *CorrespondingModule);
438 bool IsCompiledModuleHeader);
496 bool UsePrebuiltPath);
535 bool AllowTextual =
false)
const;
552 StringRef OriginalModuleMapFile = StringRef());
599 bool findUsableModuleForHeader(
const FileEntry *File,
603 bool IsSystemHeaderDir);
610 bool findUsableModuleForFrameworkHeader(
611 const FileEntry *File, StringRef FrameworkDir,
Module *RequestingModule,
640 bool WantExternal =
true)
const;
649 return SearchDirs.begin();
652 return SearchDirs.begin() + AngledDirIdx;
656 return SearchDirs.begin() + AngledDirIdx;
659 return SearchDirs.begin() + SystemDirIdx;
663 return SearchDirs.begin() + SystemDirIdx;
676 bool *IsSystem =
nullptr);
684 enum LoadModuleMapResult {
696 LoadModuleMapResult loadModuleMapFileImpl(
const FileEntry *File,
698 const DirectoryEntry *Dir,
699 FileID
ID = FileID(),
700 unsigned *
Offset =
nullptr);
723 bool IsSystem,
bool IsFramework);
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...
One of these records is kept for each identifier that is lexed.
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.
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
Encodes a location in the source.
Cached information about one file (either on disk or in the virtual file system). ...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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.