class HeaderSearch

Declaration

class HeaderSearch { /* full declaration omitted */ };

Description

Encapsulates the information needed to find the file referenced by a # include or # include_next, (sub-)framework lookup, etc.

Declared at: clang/include/clang/Lex/HeaderSearch.h:223

Member Variables

private std::shared_ptr<HeaderSearchOptions> HSOpts
Header-search options used to initialize this header search.
private llvm::DenseMap<unsigned int, unsigned int> SearchDirToHSEntry
Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
private clang::DiagnosticsEngine& Diags
private clang::FileManager& FileMgr
private std::vector<DirectoryLookup> SearchDirs
# include search path information. Requests for # include "x" search the directory of the # including file first, then each directory in SearchDirs consecutively. Requests for <x > search the current dir first, then each directory in SearchDirs, starting at AngledDirIdx, consecutively. If NoCurDirSearch is true, then the check for the file in the current directory is suppressed.
private std::vector<bool> SearchDirsUsage
Whether the DirectoryLookup at the corresponding index in SearchDirs has been successfully used to lookup a file.
private unsigned int AngledDirIdx = 0
private unsigned int SystemDirIdx = 0
private bool NoCurDirSearch = false
private std::vector<std::pair<std::string, bool>> SystemHeaderPrefixes
For a # include "x" or # include < x> directive, the last string in this list which is a prefix of 'x' determines whether the file is treated as a system header.
private std::string ModuleHash
The hash used for module cache paths.
private std::string ModuleCachePath
The path to the module cache.
private std::vector<HeaderFileInfo> FileInfo
All of the preprocessor-specific data about files that are included, indexed by the FileEntry's UID.
private llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache
private llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap
Collection mapping a framework or subframework name like "Carbon" to the Carbon.framework directory.
private std::unique_ptr<IncludeAliasMap> IncludeAliases
private std::vector<std::pair<const FileEntry*, std::unique_ptr<HeaderMap>>> HeaderMaps
This is a mapping from FileEntry -> HeaderMap, uniquing headermaps.
private clang::ModuleMap ModMap
The mapping between modules and headers.
private llvm::DenseMap<const DirectoryEntry*, bool> DirectoryHasModuleMap
Describes whether a given directory has a module map in it.
private llvm::DenseMap<const FileEntry*, bool> LoadedModuleMaps
Set of module map files we've already loaded, and a flag indicating whether they were valid or not.
private llvm::DenseMap<const FileEntry*, llvm::SmallString<64>> IncludeNames
private llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames
Uniqued set of framework names, which is used to track which headers were included as framework headers.
private clang::ExternalPreprocessorSource* ExternalLookup = nullptr
Entity used to resolve the identifier IDs of controlling macros into IdentifierInfo pointers, and keep the identifire up to date, as needed.
private clang::ExternalHeaderFileInfoSource* ExternalSource = nullptr
Entity used to look up stored header file information.

Method Overview

  • public void AddIncludeAlias(llvm::StringRef Source, llvm::StringRef Dest)
  • public void AddSearchPath(const clang::DirectoryLookup & dir, bool isAngled)
  • public void AddSystemSearchPath(const clang::DirectoryLookup & dir)
  • public void ClearFileInfo()
  • public const clang::HeaderMap * CreateHeaderMap(const clang::FileEntry * FE)
  • public bool HasIncludeAliasMap() const
  • public HeaderSearch(const clang::HeaderSearch &)
  • public HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts, clang::SourceManager & SourceMgr, clang::DiagnosticsEngine & Diags, const clang::LangOptions & LangOpts, const clang::TargetInfo * Target)
  • public Optional<clang::FileEntryRef> LookupFile(llvm::StringRef Filename, clang::SourceLocation IncludeLoc, bool isAngled, clang::ConstSearchDirIterator FromDir, clang::ConstSearchDirIterator * CurDir, ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers, SmallVectorImpl<char> * SearchPath, SmallVectorImpl<char> * RelativePath, clang::Module * RequestingModule, ModuleMap::KnownHeader * SuggestedModule, bool * IsMapped, bool * IsFrameworkFound, bool SkipCache = false, bool BuildSystemModule = false)
  • public clang::FrameworkCacheEntry & LookupFrameworkCache(llvm::StringRef FWName)
  • public Optional<clang::FileEntryRef> LookupSubframeworkHeader(llvm::StringRef Filename, const clang::FileEntry * ContextFileEnt, SmallVectorImpl<char> * SearchPath, SmallVectorImpl<char> * RelativePath, clang::Module * RequestingModule, ModuleMap::KnownHeader * SuggestedModule)
  • public llvm::StringRef MapHeaderToIncludeAlias(llvm::StringRef Source)
  • public void MarkFileIncludeOnce(const clang::FileEntry * File)
  • public void MarkFileModuleHeader(const clang::FileEntry * FE, ModuleMap::ModuleHeaderRole Role, bool isCompilingModuleHeader)
  • public void MarkFileSystemHeader(const clang::FileEntry * File)
  • public void PrintStats()
  • public void SetExternalLookup(clang::ExternalPreprocessorSource * EPS)
  • public void SetExternalSource(clang::ExternalHeaderFileInfoSource * ES)
  • public void SetFileControllingMacro(const clang::FileEntry * File, const clang::IdentifierInfo * ControllingMacro)
  • public void SetSearchPaths(std::vector<DirectoryLookup> dirs, unsigned int angledDirIdx, unsigned int systemDirIdx, bool noCurDirSearch, llvm::DenseMap<unsigned int, unsigned int> searchDirToHSEntry)
  • public void SetSystemHeaderPrefixes(ArrayRef<std::pair<std::string, bool>> P)
  • public bool ShouldEnterIncludeFile(clang::Preprocessor & PP, const clang::FileEntry * File, bool isImport, bool ModulesEnabled, clang::Module * M, bool & IsFirstIncludeOfFile)
  • public clang::ConstSearchDirIterator angled_dir_begin() const
  • public clang::ConstSearchDirIterator angled_dir_end() const
  • private void cacheLookupSuccess(clang::HeaderSearch::LookupFileCacheInfo & CacheLookup, clang::ConstSearchDirIterator HitIt, clang::SourceLocation IncludeLoc)
  • public void collectAllModules(SmallVectorImpl<clang::Module *> & Modules)
  • public std::vector<bool> computeUserEntryUsage() const
  • public ArrayRef<ModuleMap::KnownHeader> findAllModulesForHeader(const clang::FileEntry * File) const
  • public ModuleMap::KnownHeader findModuleForHeader(const clang::FileEntry * File, bool AllowTextual = false) const
  • private bool findUsableModuleForFrameworkHeader(const clang::FileEntry * File, llvm::StringRef FrameworkName, clang::Module * RequestingModule, ModuleMap::KnownHeader * SuggestedModule, bool IsSystemFramework)
  • private bool findUsableModuleForHeader(const clang::FileEntry * File, const clang::DirectoryEntry * Root, clang::Module * RequestingModule, ModuleMap::KnownHeader * SuggestedModule, bool IsSystemHeaderDir)
  • public std::string getCachedModuleFileName(clang::Module * Module)
  • public std::string getCachedModuleFileName(llvm::StringRef ModuleName, llvm::StringRef ModuleMapPath)
  • private std::string getCachedModuleFileNameImpl(llvm::StringRef ModuleName, llvm::StringRef ModuleMapPath, llvm::StringRef CachePath)
  • public clang::DiagnosticsEngine & getDiags() const
  • public const clang::HeaderFileInfo * getExistingFileInfo(const clang::FileEntry * FE, bool WantExternal = true) const
  • public clang::ExternalPreprocessorSource * getExternalLookup() const
  • private Optional<clang::FileEntryRef> getFileAndSuggestModule(llvm::StringRef FileName, clang::SourceLocation IncludeLoc, const clang::DirectoryEntry * Dir, bool IsSystemHeaderDir, clang::Module * RequestingModule, ModuleMap::KnownHeader * SuggestedModule)
  • public SrcMgr::CharacteristicKind getFileDirFlavor(const clang::FileEntry * File)
  • public clang::HeaderFileInfo & getFileInfo(const clang::FileEntry * FE)
  • public clang::FileManager & getFileMgr() const
  • public void getHeaderMapFileNames(SmallVectorImpl<std::string> & Names) const
  • public clang::HeaderSearchOptions & getHeaderSearchOpts() const
  • public llvm::StringRef getIncludeNameForHeader(const clang::FileEntry * File) const
  • public llvm::StringRef getModuleCachePath() const
  • public llvm::StringRef getModuleHash() const
  • public const clang::ModuleMap & getModuleMap() const
  • public clang::ModuleMap & getModuleMap()
  • public std::string getPrebuiltImplicitModuleFileName(clang::Module * Module)
  • public std::string getPrebuiltModuleFileName(llvm::StringRef ModuleName, bool FileMapOnly = false)
  • public size_t getTotalMemory() const
  • public llvm::StringRef getUniqueFrameworkName(llvm::StringRef Framework)
  • public bool hasFileBeenImported(const clang::FileEntry * File)
  • public bool hasModuleMap(llvm::StringRef Filename, const clang::DirectoryEntry * Root, bool IsSystem)
  • public unsigned int header_file_size() const
  • public bool isFileMultipleIncludeGuarded(const clang::FileEntry * File)
  • private clang::Module * loadFrameworkModule(llvm::StringRef Name, clang::DirectoryEntryRef Dir, bool IsSystem)
  • private clang::HeaderSearch::LoadModuleMapResult loadModuleMapFile(clang::DirectoryEntryRef Dir, bool IsSystem, bool IsFramework)
  • private clang::HeaderSearch::LoadModuleMapResult loadModuleMapFile(llvm::StringRef DirName, bool IsSystem, bool IsFramework)
  • public bool loadModuleMapFile(const clang::FileEntry * File, bool IsSystem, clang::FileID ID = clang::FileID(), unsigned int * Offset = nullptr, llvm::StringRef OriginalModuleMapFile = llvm::StringRef())
  • private clang::HeaderSearch::LoadModuleMapResult loadModuleMapFileImpl(const clang::FileEntry * File, bool IsSystem, clang::DirectoryEntryRef Dir, clang::FileID ID = clang::FileID(), unsigned int * Offset = nullptr)
  • private void loadSubdirectoryModuleMaps(clang::DirectoryLookup & SearchDir)
  • public void loadTopLevelSystemModules()
  • private clang::Module * lookupModule(llvm::StringRef ModuleName, llvm::StringRef SearchName, clang::SourceLocation ImportLoc, bool AllowExtraModuleMapSearch = false)
  • public clang::Module * lookupModule(llvm::StringRef ModuleName, clang::SourceLocation ImportLoc = clang::SourceLocation(), bool AllowSearch = true, bool AllowExtraModuleMapSearch = false)
  • public const clang::FileEntry * lookupModuleMapFile(const clang::DirectoryEntry * Dir, bool IsFramework)
  • private void noteLookupUsage(unsigned int HitIdx, clang::SourceLocation IncludeLoc)
  • public clang::ConstSearchDirIterator quoted_dir_begin() const
  • public clang::ConstSearchDirIterator quoted_dir_end() const
  • public unsigned int searchDirIdx(const clang::DirectoryLookup & DL) const
  • public clang::ConstSearchDirIterator search_dir_begin() const
  • public clang::SearchDirIterator search_dir_begin()
  • public clang::SearchDirIterator search_dir_end()
  • public clang::ConstSearchDirIterator search_dir_end() const
  • public clang::SearchDirRange search_dir_range()
  • public clang::ConstSearchDirRange search_dir_range() const
  • public unsigned int search_dir_size() const
  • public void setDirectoryHasModuleMap(const clang::DirectoryEntry * Dir)
  • public void setModuleCachePath(llvm::StringRef CachePath)
  • public void setModuleHash(llvm::StringRef Hash)
  • public void setTarget(const clang::TargetInfo & Target)
  • public std::string suggestPathToFileForDiagnostics(const clang::FileEntry * File, llvm::StringRef MainFile, bool * IsSystem = nullptr)
  • public std::string suggestPathToFileForDiagnostics(llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile, bool * IsSystem = nullptr)
  • public clang::ConstSearchDirIterator system_dir_begin() const
  • public clang::ConstSearchDirIterator system_dir_end() const

Methods

void AddIncludeAlias(llvm::StringRef Source,
                     llvm::StringRef Dest)

Description

Map the source include name to the dest include name. The Source should include the angle brackets or quotes, the dest should not. This allows for distinction between < > and "" headers.

Declared at: clang/include/clang/Lex/HeaderSearch.h:374

Parameters

llvm::StringRef Source
llvm::StringRef Dest

void AddSearchPath(
    const clang::DirectoryLookup& dir,
    bool isAngled)

Description

Add an additional search path.

Declared at: clang/include/clang/Lex/HeaderSearch.h:354

Parameters

const clang::DirectoryLookup& dir
bool isAngled

void AddSystemSearchPath(
    const clang::DirectoryLookup& dir)

Description

Add an additional system search path.

Declared at: clang/include/clang/Lex/HeaderSearch.h:357

Parameters

const clang::DirectoryLookup& dir

void ClearFileInfo()

Description

Forget everything we know about headers so far.

Declared at: clang/include/clang/Lex/HeaderSearch.h:414

const clang::HeaderMap* CreateHeaderMap(
    const clang::FileEntry* FE)

Description

This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' datastructure.

Declared at: clang/include/clang/Lex/HeaderSearch.h:558

Parameters

const clang::FileEntry* FE

bool HasIncludeAliasMap() const

Description

Checks whether the map exists or not.

Declared at: clang/include/clang/Lex/HeaderSearch.h:368

HeaderSearch(const clang::HeaderSearch&)

Declared at: clang/include/clang/Lex/HeaderSearch.h:337

Parameters

const clang::HeaderSearch&

HeaderSearch(
    std::shared_ptr<HeaderSearchOptions> HSOpts,
    clang::SourceManager& SourceMgr,
    clang::DiagnosticsEngine& Diags,
    const clang::LangOptions& LangOpts,
    const clang::TargetInfo* Target)

Declared at: clang/include/clang/Lex/HeaderSearch.h:334

Parameters

std::shared_ptr<HeaderSearchOptions> HSOpts
clang::SourceManager& SourceMgr
clang::DiagnosticsEngine& Diags
const clang::LangOptions& LangOpts
const clang::TargetInfo* Target

Optional<clang::FileEntryRef> LookupFile(
    llvm::StringRef Filename,
    clang::SourceLocation IncludeLoc,
    bool isAngled,
    clang::ConstSearchDirIterator FromDir,
    clang::ConstSearchDirIterator* CurDir,
    ArrayRef<std::pair<const FileEntry*,
                       const DirectoryEntry*>>
        Includers,
    SmallVectorImpl<char>* SearchPath,
    SmallVectorImpl<char>* RelativePath,
    clang::Module* RequestingModule,
    ModuleMap::KnownHeader* SuggestedModule,
    bool* IsMapped,
    bool* IsFrameworkFound,
    bool SkipCache = false,
    bool BuildSystemModule = false)

Description

Given a "foo" or < foo> reference, look up the indicated file, return null on failure.

Declared at: clang/include/clang/Lex/HeaderSearch.h:470

Parameters

llvm::StringRef Filename
clang::SourceLocation IncludeLoc
Used for diagnostics if valid.
bool isAngled
indicates whether the file reference is a < > reference.
clang::ConstSearchDirIterator FromDir
clang::ConstSearchDirIterator* CurDir
If non-null, the file was found in the specified directory search location. This is used to implement # include_next.
ArrayRef<std::pair<const FileEntry*, const DirectoryEntry*>> Includers
Indicates where the # including file(s) are, in case relative searches are needed. In reverse order of inclusion.
SmallVectorImpl<char>* SearchPath
If non-null, will be set to the search path relative to which the file was found. If the include path is absolute, SearchPath will be set to an empty string.
SmallVectorImpl<char>* RelativePath
If non-null, will be set to the path relative to SearchPath at which the file was found. This only differs from the Filename for framework includes.
clang::Module* RequestingModule
ModuleMap::KnownHeader* SuggestedModule
If non-null, and the file found is semantically part of a known module, this will be set to the module that should be imported instead of preprocessing/parsing the file found.
bool* IsMapped
If non-null, and the search involved header maps, set to true.
bool* IsFrameworkFound
If non-null, will be set to true if a framework is found in any of searched SearchDirs. Will be set to false if a framework is found only through header maps. Doesn't guarantee the requested file is found.
bool SkipCache = false
bool BuildSystemModule = false

Returns

If successful, this returns 'UsedDir', the DirectoryLookup member the file was found in, or null if not applicable.

clang::FrameworkCacheEntry& LookupFrameworkCache(
    llvm::StringRef FWName)

Description

Look up the specified framework name in our framework cache.

Declared at: clang/include/clang/Lex/HeaderSearch.h:492

Parameters

llvm::StringRef FWName

Returns

The DirectoryEntry it is in if we know, null otherwise.

Optional<clang::FileEntryRef>
LookupSubframeworkHeader(
    llvm::StringRef Filename,
    const clang::FileEntry* ContextFileEnt,
    SmallVectorImpl<char>* SearchPath,
    SmallVectorImpl<char>* RelativePath,
    clang::Module* RequestingModule,
    ModuleMap::KnownHeader* SuggestedModule)

Description

Look up a subframework for the specified # include file. For example, if # include'ing <HIToolbox /HIToolbox.h> from within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox is a subframework within Carbon.framework. If so, return the FileEntry for the designated file, otherwise return null.

Declared at: clang/include/clang/Lex/HeaderSearch.h:485

Parameters

llvm::StringRef Filename
const clang::FileEntry* ContextFileEnt
SmallVectorImpl<char>* SearchPath
SmallVectorImpl<char>* RelativePath
clang::Module* RequestingModule
ModuleMap::KnownHeader* SuggestedModule

llvm::StringRef MapHeaderToIncludeAlias(
    llvm::StringRef Source)

Description

Maps one header file name to a different header file name, for use with the include_alias pragma. Note that the source file name should include the angle brackets or quotes. Returns StringRef as null if the header cannot be mapped.

Declared at: clang/include/clang/Lex/HeaderSearch.h:384

Parameters

llvm::StringRef Source

void MarkFileIncludeOnce(
    const clang::FileEntry* File)

Description

Mark the specified file as a "once only" file due to # pragma once.

Declared at: clang/include/clang/Lex/HeaderSearch.h:513

Parameters

const clang::FileEntry* File

void MarkFileModuleHeader(
    const clang::FileEntry* FE,
    ModuleMap::ModuleHeaderRole Role,
    bool isCompilingModuleHeader)

Description

Mark the specified file as part of a module.

Declared at: clang/include/clang/Lex/HeaderSearch.h:525

Parameters

const clang::FileEntry* FE
ModuleMap::ModuleHeaderRole Role
bool isCompilingModuleHeader

void MarkFileSystemHeader(
    const clang::FileEntry* File)

Description

Mark the specified file as a system header, e.g. due to # pragma GCC system_header.

Declared at: clang/include/clang/Lex/HeaderSearch.h:520

Parameters

const clang::FileEntry* File

void PrintStats()

Declared at: clang/include/clang/Lex/HeaderSearch.h:863

void SetExternalLookup(
    clang::ExternalPreprocessorSource* EPS)

Declared at: clang/include/clang/Lex/HeaderSearch.h:418

Parameters

clang::ExternalPreprocessorSource* EPS

void SetExternalSource(
    clang::ExternalHeaderFileInfoSource* ES)

Description

Set the external source of header information.

Declared at: clang/include/clang/Lex/HeaderSearch.h:427

Parameters

clang::ExternalHeaderFileInfoSource* ES

void SetFileControllingMacro(
    const clang::FileEntry* File,
    const clang::IdentifierInfo* ControllingMacro)

Description

Mark the specified file as having a controlling macro. This is used by the multiple-include optimization to eliminate no-op # includes.

Declared at: clang/include/clang/Lex/HeaderSearch.h:533

Parameters

const clang::FileEntry* File
const clang::IdentifierInfo* ControllingMacro

void SetSearchPaths(
    std::vector<DirectoryLookup> dirs,
    unsigned int angledDirIdx,
    unsigned int systemDirIdx,
    bool noCurDirSearch,
    llvm::DenseMap<unsigned int, unsigned int>
        searchDirToHSEntry)

Description

Interface for setting the file search paths.

Declared at: clang/include/clang/Lex/HeaderSearch.h:349

Parameters

std::vector<DirectoryLookup> dirs
unsigned int angledDirIdx
unsigned int systemDirIdx
bool noCurDirSearch
llvm::DenseMap<unsigned int, unsigned int> searchDirToHSEntry

void SetSystemHeaderPrefixes(
    ArrayRef<std::pair<std::string, bool>> P)

Description

Set the list of system header prefixes.

Declared at: clang/include/clang/Lex/HeaderSearch.h:363

Parameters

ArrayRef<std::pair<std::string, bool>> P

bool ShouldEnterIncludeFile(
    clang::Preprocessor& PP,
    const clang::FileEntry* File,
    bool isImport,
    bool ModulesEnabled,
    clang::Module* M,
    bool& IsFirstIncludeOfFile)

Description

Mark the specified file as a target of a # include, # include_next, or # import directive.

Declared at: clang/include/clang/Lex/HeaderSearch.h:501

Parameters

clang::Preprocessor& PP
const clang::FileEntry* File
bool isImport
bool ModulesEnabled
clang::Module* M
bool& IsFirstIncludeOfFile

Returns

false if # including the file will have no effect or true if we should include it.

clang::ConstSearchDirIterator angled_dir_begin()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:811

clang::ConstSearchDirIterator angled_dir_end()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:814

void cacheLookupSuccess(
    clang::HeaderSearch::LookupFileCacheInfo&
        CacheLookup,
    clang::ConstSearchDirIterator HitIt,
    clang::SourceLocation IncludeLoc)

Description

Cache the result of a successful lookup at the given include location using the search path at \c HitIt.

Declared at: clang/include/clang/Lex/HeaderSearch.h:766

Parameters

clang::HeaderSearch::LookupFileCacheInfo& CacheLookup
clang::ConstSearchDirIterator HitIt
clang::SourceLocation IncludeLoc

void collectAllModules(
    SmallVectorImpl<clang::Module*>& Modules)

Description

Collect the set of all known, top-level modules.

Declared at: clang/include/clang/Lex/HeaderSearch.h:678

Parameters

SmallVectorImpl<clang::Module*>& Modules
Will be filled with the set of known, top-level modules.

std::vector<bool> computeUserEntryUsage() const

Description

Determine which HeaderSearchOptions::UserEntries have been successfully used so far and mark their index with 'true' in the resulting bit vector. Note: implicit module maps don't contribute to entry usage.

Declared at: clang/include/clang/Lex/HeaderSearch.h:554

ArrayRef<ModuleMap::KnownHeader>
findAllModulesForHeader(
    const clang::FileEntry* File) const

Description

Retrieve all the modules corresponding to the given file. \ref findModuleForHeader should typically be used instead of this.

Declared at: clang/include/clang/Lex/HeaderSearch.h:656

Parameters

const clang::FileEntry* File

ModuleMap::KnownHeader findModuleForHeader(
    const clang::FileEntry* File,
    bool AllowTextual = false) const

Description

Retrieve the module that corresponds to the given file, if any.

Declared at: clang/include/clang/Lex/HeaderSearch.h:649

Parameters

const clang::FileEntry* File
The header that we wish to map to a module.
bool AllowTextual = false
Whether we want to find textual headers too.

bool findUsableModuleForFrameworkHeader(
    const clang::FileEntry* File,
    llvm::StringRef FrameworkName,
    clang::Module* RequestingModule,
    ModuleMap::KnownHeader* SuggestedModule,
    bool IsSystemFramework)

Description

Find and suggest a usable module for the given file, which is part of the specified framework.

Declared at: clang/include/clang/Lex/HeaderSearch.h:752

Parameters

const clang::FileEntry* File
llvm::StringRef FrameworkName
clang::Module* RequestingModule
ModuleMap::KnownHeader* SuggestedModule
bool IsSystemFramework

Returns

\c true if the file can be used, \c false if we are not permitted to find this file due to requirements from \p RequestingModule.

bool findUsableModuleForHeader(
    const clang::FileEntry* File,
    const clang::DirectoryEntry* Root,
    clang::Module* RequestingModule,
    ModuleMap::KnownHeader* SuggestedModule,
    bool IsSystemHeaderDir)

Description

Find and suggest a usable module for the given file.

Declared at: clang/include/clang/Lex/HeaderSearch.h:741

Parameters

const clang::FileEntry* File
const clang::DirectoryEntry* Root
clang::Module* RequestingModule
ModuleMap::KnownHeader* SuggestedModule
bool IsSystemHeaderDir

Returns

\c true if the file can be used, \c false if we are not permitted to find this file due to requirements from \p RequestingModule.

std::string getCachedModuleFileName(
    clang::Module* Module)

Description

Retrieve the name of the cached module file that should be used to load the given module.

Declared at: clang/include/clang/Lex/HeaderSearch.h:570

Parameters

clang::Module* Module
The module whose module file name will be returned.

Returns

The name of the module file that corresponds to this module, or an empty string if this module does not correspond to any module file.

std::string getCachedModuleFileName(
    llvm::StringRef ModuleName,
    llvm::StringRef ModuleMapPath)

Description

Retrieve the name of the (to-be-)cached module file that should be used to load a module with the given name.

Declared at: clang/include/clang/Lex/HeaderSearch.h:604

Parameters

llvm::StringRef ModuleName
The module whose module file name will be returned.
llvm::StringRef ModuleMapPath
A path that when combined with \c ModuleName uniquely identifies this module. See Module::ModuleMap.

Returns

The name of the module file that corresponds to this module, or an empty string if this module does not correspond to any module file.

std::string getCachedModuleFileNameImpl(
    llvm::StringRef ModuleName,
    llvm::StringRef ModuleMapPath,
    llvm::StringRef CachePath)

Description

Retrieve the name of the (to-be-)cached module file that should be used to load a module with the given name.

Declared at: clang/include/clang/Lex/HeaderSearch.h:715

Parameters

llvm::StringRef ModuleName
The module whose module file name will be returned.
llvm::StringRef ModuleMapPath
A path that when combined with \c ModuleName uniquely identifies this module. See Module::ModuleMap.
llvm::StringRef CachePath
A path to the module cache.

Returns

The name of the module file that corresponds to this module, or an empty string if this module does not correspond to any module file.

clang::DiagnosticsEngine& getDiags() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:346

const clang::HeaderFileInfo* getExistingFileInfo(
    const clang::FileEntry* FE,
    bool WantExternal = true) const

Description

Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in.

Declared at: clang/include/clang/Lex/HeaderSearch.h:791

Parameters

const clang::FileEntry* FE
bool WantExternal = true
Whether the caller wants purely-external header file info (where \p External is true).

clang::ExternalPreprocessorSource*
getExternalLookup() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:422

Optional<clang::FileEntryRef>
getFileAndSuggestModule(
    llvm::StringRef FileName,
    clang::SourceLocation IncludeLoc,
    const clang::DirectoryEntry* Dir,
    bool IsSystemHeaderDir,
    clang::Module* RequestingModule,
    ModuleMap::KnownHeader* SuggestedModule)

Description

Look up the file with the specified name and determine its owning module.

Declared at: clang/include/clang/Lex/HeaderSearch.h:759

Parameters

llvm::StringRef FileName
clang::SourceLocation IncludeLoc
const clang::DirectoryEntry* Dir
bool IsSystemHeaderDir
clang::Module* RequestingModule
ModuleMap::KnownHeader* SuggestedModule

SrcMgr::CharacteristicKind getFileDirFlavor(
    const clang::FileEntry* File)

Description

Return whether the specified file is a normal header, a system header, or a C++ friendly system header.

Declared at: clang/include/clang/Lex/HeaderSearch.h:507

Parameters

const clang::FileEntry* File

clang::HeaderFileInfo& getFileInfo(
    const clang::FileEntry* FE)

Description

Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in some way.

Declared at: clang/include/clang/Lex/HeaderSearch.h:785

Parameters

const clang::FileEntry* FE

clang::FileManager& getFileMgr() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:344

void getHeaderMapFileNames(
    SmallVectorImpl<std::string>& Names) const

Description

Get filenames for all registered header maps.

Declared at: clang/include/clang/Lex/HeaderSearch.h:561

Parameters

SmallVectorImpl<std::string>& Names

clang::HeaderSearchOptions& getHeaderSearchOpts()
    const

Description

Retrieve the header-search options with which this header search was initialized.

Declared at: clang/include/clang/Lex/HeaderSearch.h:342

llvm::StringRef getIncludeNameForHeader(
    const clang::FileEntry* File) const

Description

Retrieve the include name for the header.

Declared at: clang/include/clang/Lex/HeaderSearch.h:834

Parameters

const clang::FileEntry* File
The entry for a given header.

Returns

The name of how the file was included when the header's location was resolved.

llvm::StringRef getModuleCachePath() const

Description

Retrieve the path to the module cache.

Declared at: clang/include/clang/Lex/HeaderSearch.h:406

llvm::StringRef getModuleHash() const

Description

Retrieve the module hash.

Declared at: clang/include/clang/Lex/HeaderSearch.h:403

const clang::ModuleMap& getModuleMap() const

Description

Retrieve the module map.

Declared at: clang/include/clang/Lex/HeaderSearch.h:779

clang::ModuleMap& getModuleMap()

Description

Retrieve the module map.

Declared at: clang/include/clang/Lex/HeaderSearch.h:776

std::string getPrebuiltImplicitModuleFileName(
    clang::Module* Module)

Description

Retrieve the name of the prebuilt module file that should be used to load the given module.

Declared at: clang/include/clang/Lex/HeaderSearch.h:592

Parameters

clang::Module* Module
The module whose module file name will be returned.

Returns

The name of the module file that corresponds to this module, or an empty string if this module does not correspond to any module file.

std::string getPrebuiltModuleFileName(
    llvm::StringRef ModuleName,
    bool FileMapOnly = false)

Declared at: clang/include/clang/Lex/HeaderSearch.h:582

Parameters

llvm::StringRef ModuleName
bool FileMapOnly = false

Returns

The name of the module file that corresponds to this module, or an empty string if this module does not correspond to any module file.

size_t getTotalMemory() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:865

llvm::StringRef getUniqueFrameworkName(
    llvm::StringRef Framework)

Description

Retrieve a uniqued framework name.

Declared at: clang/include/clang/Lex/HeaderSearch.h:827

Parameters

llvm::StringRef Framework

bool hasFileBeenImported(
    const clang::FileEntry* File)

Description

Determine whether the given file is known to have ever been # imported.

Declared at: clang/include/clang/Lex/HeaderSearch.h:546

Parameters

const clang::FileEntry* File

bool hasModuleMap(
    llvm::StringRef Filename,
    const clang::DirectoryEntry* Root,
    bool IsSystem)

Description

Determine whether there is a module map that may map the header with the given file name to a (sub)module. Always returns false if modules are disabled.

Declared at: clang/include/clang/Lex/HeaderSearch.h:642

Parameters

llvm::StringRef Filename
The name of the file.
const clang::DirectoryEntry* Root
The "root" directory, at which we should stop looking for module maps.
bool IsSystem
Whether the directories we're looking at are system header directories.

unsigned int header_file_size() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:781

bool isFileMultipleIncludeGuarded(
    const clang::FileEntry* File)

Description

Determine whether this file is intended to be safe from multiple inclusions, e.g., it has # pragma once or a controlling macro. This routine does not consider the effect of # import

Declared at: clang/include/clang/Lex/HeaderSearch.h:543

Parameters

const clang::FileEntry* File

clang::Module* loadFrameworkModule(
    llvm::StringRef Name,
    clang::DirectoryEntryRef Dir,
    bool IsSystem)

Description

Retrieve a module with the given name, which may be part of the given framework.

Declared at: clang/include/clang/Lex/HeaderSearch.h:730

Parameters

llvm::StringRef Name
The name of the module to retrieve.
clang::DirectoryEntryRef Dir
The framework directory (e.g., ModuleName.framework).
bool IsSystem
Whether the framework directory is part of the system frameworks.

Returns

The module, if found; otherwise, null.

clang::HeaderSearch::LoadModuleMapResult
loadModuleMapFile(clang::DirectoryEntryRef Dir,
                  bool IsSystem,
                  bool IsFramework)

Description

Try to load the module map file in the given directory.

Declared at: clang/include/clang/Lex/HeaderSearch.h:910

Parameters

clang::DirectoryEntryRef Dir
The directory where we will look for a module map file.
bool IsSystem
Whether this is a system header directory.
bool IsFramework
Whether this is a framework directory.

Returns

The result of attempting to load the module map file from the named directory.

clang::HeaderSearch::LoadModuleMapResult
loadModuleMapFile(llvm::StringRef DirName,
                  bool IsSystem,
                  bool IsFramework)

Description

Try to load the module map file in the given directory.

Declared at: clang/include/clang/Lex/HeaderSearch.h:899

Parameters

llvm::StringRef DirName
The name of the directory where we will look for a module map file.
bool IsSystem
Whether this is a system header directory.
bool IsFramework
Whether this is a framework directory.

Returns

The result of attempting to load the module map file from the named directory.

bool loadModuleMapFile(
    const clang::FileEntry* File,
    bool IsSystem,
    clang::FileID ID = clang::FileID(),
    unsigned int* Offset = nullptr,
    llvm::StringRef OriginalModuleMapFile =
        llvm::StringRef())

Description

Read the contents of the given module map file.

Declared at: clang/include/clang/Lex/HeaderSearch.h:671

Parameters

const clang::FileEntry* File
The module map file.
bool IsSystem
Whether this file is in a system header directory.
clang::FileID ID = clang::FileID()
If the module map file is already mapped (perhaps as part of processing a preprocessed module), the ID of the file.
unsigned int* Offset = nullptr
[inout] An offset within ID to start parsing. On exit, filled by the end of the parsed contents (either EOF or the location of an end-of-module-map pragma).
llvm::StringRef OriginalModuleMapFile = llvm::StringRef()
The original path to the module map file, used to resolve paths within the module (this is required when building the module from preprocessed source).

Returns

true if an error occurred, false otherwise.

clang::HeaderSearch::LoadModuleMapResult
loadModuleMapFileImpl(
    const clang::FileEntry* File,
    bool IsSystem,
    clang::DirectoryEntryRef Dir,
    clang::FileID ID = clang::FileID(),
    unsigned int* Offset = nullptr)

Declared at: clang/include/clang/Lex/HeaderSearch.h:884

Parameters

const clang::FileEntry* File
bool IsSystem
clang::DirectoryEntryRef Dir
clang::FileID ID = clang::FileID()
unsigned int* Offset = nullptr

void loadSubdirectoryModuleMaps(
    clang::DirectoryLookup& SearchDir)

Description

Load all of the module maps within the immediate subdirectories of the given search directory.

Declared at: clang/include/clang/Lex/HeaderSearch.h:735

Parameters

clang::DirectoryLookup& SearchDir

void loadTopLevelSystemModules()

Description

Load all known, top-level system modules.

Declared at: clang/include/clang/Lex/HeaderSearch.h:681

clang::Module* lookupModule(
    llvm::StringRef ModuleName,
    llvm::StringRef SearchName,
    clang::SourceLocation ImportLoc,
    bool AllowExtraModuleMapSearch = false)

Description

Lookup a module with the given module name and search-name.

Declared at: clang/include/clang/Lex/HeaderSearch.h:699

Parameters

llvm::StringRef ModuleName
The name of the module we're looking for.
llvm::StringRef SearchName
The "search-name" to derive filesystem paths from when looking for the module map; this is usually equal to ModuleName, but for compatibility with some buggy frameworks, additional attempts may be made to find the module under a related-but-different search-name.
clang::SourceLocation ImportLoc
Location of the module include/import.
bool AllowExtraModuleMapSearch = false
Whether we allow to search modulemaps in subdirectories.

Returns

The module named ModuleName.

clang::Module* lookupModule(
    llvm::StringRef ModuleName,
    clang::SourceLocation ImportLoc =
        clang::SourceLocation(),
    bool AllowSearch = true,
    bool AllowExtraModuleMapSearch = false)

Description

Lookup a module Search for a module with the given name.

Declared at: clang/include/clang/Lex/HeaderSearch.h:621

Parameters

llvm::StringRef ModuleName
The name of the module we're looking for.
clang::SourceLocation ImportLoc = clang::SourceLocation()
Location of the module include/import.
bool AllowSearch = true
Whether we are allowed to search in the various search directories to produce a module definition. If not, this lookup will only return an already-known module.
bool AllowExtraModuleMapSearch = false
Whether we allow to search modulemaps in subdirectories.

Returns

The module with the given name.

const clang::FileEntry* lookupModuleMapFile(
    const clang::DirectoryEntry* Dir,
    bool IsFramework)

Description

Try to find a module map file in the given directory, returning\c nullptr if none is found.

Declared at: clang/include/clang/Lex/HeaderSearch.h:628

Parameters

const clang::DirectoryEntry* Dir
bool IsFramework

void noteLookupUsage(
    unsigned int HitIdx,
    clang::SourceLocation IncludeLoc)

Description

Note that a lookup at the given include location was successful using the search path at index `HitIdx`.

Declared at: clang/include/clang/Lex/HeaderSearch.h:772

Parameters

unsigned int HitIdx
clang::SourceLocation IncludeLoc

clang::ConstSearchDirIterator quoted_dir_begin()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:808

clang::ConstSearchDirIterator quoted_dir_end()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:809

unsigned int searchDirIdx(
    const clang::DirectoryLookup& DL) const

Description

Get the index of the given search directory.

Declared at: clang/include/clang/Lex/HeaderSearch.h:824

Parameters

const clang::DirectoryLookup& DL

clang::ConstSearchDirIterator search_dir_begin()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:800

clang::SearchDirIterator search_dir_begin()

Declared at: clang/include/clang/Lex/HeaderSearch.h:794

clang::SearchDirIterator search_dir_end()

Declared at: clang/include/clang/Lex/HeaderSearch.h:795

clang::ConstSearchDirIterator search_dir_end()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:801

clang::SearchDirRange search_dir_range()

Declared at: clang/include/clang/Lex/HeaderSearch.h:796

clang::ConstSearchDirRange search_dir_range()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:802

unsigned int search_dir_size() const

Declared at: clang/include/clang/Lex/HeaderSearch.h:806

void setDirectoryHasModuleMap(
    const clang::DirectoryEntry* Dir)

Description

Consider modules when including files from this directory.

Declared at: clang/include/clang/Lex/HeaderSearch.h:409

Parameters

const clang::DirectoryEntry* Dir

void setModuleCachePath(llvm::StringRef CachePath)

Description

Set the path to the module cache.

Declared at: clang/include/clang/Lex/HeaderSearch.h:398

Parameters

llvm::StringRef CachePath

void setModuleHash(llvm::StringRef Hash)

Description

Set the hash to use for module cache paths.

Declared at: clang/include/clang/Lex/HeaderSearch.h:395

Parameters

llvm::StringRef Hash

void setTarget(const clang::TargetInfo& Target)

Description

Set the target information for the header search, if not already known.

Declared at: clang/include/clang/Lex/HeaderSearch.h:433

Parameters

const clang::TargetInfo& Target

std::string suggestPathToFileForDiagnostics(
    const clang::FileEntry* File,
    llvm::StringRef MainFile,
    bool* IsSystem = nullptr)

Description

Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. Returned path will only contain forward slashes as separators. MainFile is the absolute path of the file that we are generating the diagnostics for. It will try to shorten the path using MainFile location, if none of the include search directories were prefix of File.

Declared at: clang/include/clang/Lex/HeaderSearch.h:845

Parameters

const clang::FileEntry* File
llvm::StringRef MainFile
bool* IsSystem = nullptr
If non-null, filled in to indicate whether the suggested path is relative to a system header directory.

std::string suggestPathToFileForDiagnostics(
    llvm::StringRef File,
    llvm::StringRef WorkingDir,
    llvm::StringRef MainFile,
    bool* IsSystem = nullptr)

Description

Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. Returned path will only contain forward slashes as separators. MainFile is the absolute path of the file that we are generating the diagnostics for. It will try to shorten the path using MainFile location, if none of the include search directories were prefix of File.

Declared at: clang/include/clang/Lex/HeaderSearch.h:858

Parameters

llvm::StringRef File
llvm::StringRef WorkingDir
If non-empty, this will be prepended to search directory paths that are relative.
llvm::StringRef MainFile
bool* IsSystem = nullptr

clang::ConstSearchDirIterator system_dir_begin()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:816

clang::ConstSearchDirIterator system_dir_end()
    const

Declared at: clang/include/clang/Lex/HeaderSearch.h:819