clang 20.0.0git
|
Encapsulates the information needed to find the file referenced by a #include or #include_next, (sub-)framework lookup, etc. More...
#include "clang/Lex/HeaderSearch.h"
Public Member Functions | |
HeaderSearch (std::shared_ptr< HeaderSearchOptions > HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target) | |
HeaderSearch (const HeaderSearch &)=delete | |
HeaderSearch & | operator= (const HeaderSearch &)=delete |
HeaderSearchOptions & | getHeaderSearchOpts () const |
Retrieve the header-search options with which this header search was initialized. | |
FileManager & | getFileMgr () const |
DiagnosticsEngine & | getDiags () const |
void | SetSearchPaths (std::vector< DirectoryLookup > dirs, unsigned angledDirIdx, unsigned systemDirIdx, llvm::DenseMap< unsigned, unsigned > searchDirToHSEntry) |
Interface for setting the file search paths. | |
void | AddSearchPath (const DirectoryLookup &dir, bool isAngled) |
Add an additional search path. | |
void | AddSystemSearchPath (const DirectoryLookup &dir) |
Add an additional system search path. | |
void | SetSystemHeaderPrefixes (ArrayRef< std::pair< std::string, bool > > P) |
Set the list of system header prefixes. | |
bool | HasIncludeAliasMap () const |
Checks whether the map exists or not. | |
void | AddIncludeAlias (StringRef Source, StringRef Dest) |
Map the source include name to the dest include name. | |
StringRef | MapHeaderToIncludeAlias (StringRef Source) |
Maps one header file name to a different header file name, for use with the include_alias pragma. | |
void | setModuleHash (StringRef Hash) |
Set the hash to use for module cache paths. | |
void | setModuleCachePath (StringRef CachePath) |
Set the path to the module cache. | |
StringRef | getModuleHash () const |
Retrieve the module hash. | |
StringRef | getModuleCachePath () const |
Retrieve the path to the module cache. | |
void | setDirectoryHasModuleMap (const DirectoryEntry *Dir) |
Consider modules when including files from this directory. | |
void | ClearFileInfo () |
Forget everything we know about headers so far. | |
void | SetExternalLookup (ExternalPreprocessorSource *EPS) |
ExternalPreprocessorSource * | getExternalLookup () const |
void | SetExternalSource (ExternalHeaderFileInfoSource *ES) |
Set the external source of header information. | |
void | setTarget (const TargetInfo &Target) |
Set the target information for the header search, if not already known. | |
OptionalFileEntryRef | LookupFile (StringRef Filename, SourceLocation IncludeLoc, bool isAngled, ConstSearchDirIterator FromDir, ConstSearchDirIterator *CurDir, ArrayRef< std::pair< OptionalFileEntryRef, DirectoryEntryRef > > Includers, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool BuildSystemModule=false, bool OpenFile=true, bool CacheFailures=true) |
Given a "foo" or <foo> reference, look up the indicated file, return null on failure. | |
OptionalFileEntryRef | LookupSubframeworkHeader (StringRef Filename, FileEntryRef ContextFileEnt, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) |
Look up a subframework for the specified #include file. | |
FrameworkCacheEntry & | LookupFrameworkCache (StringRef FWName) |
Look up the specified framework name in our framework cache. | |
bool | ShouldEnterIncludeFile (Preprocessor &PP, FileEntryRef File, bool isImport, bool ModulesEnabled, Module *M, bool &IsFirstIncludeOfFile) |
Mark the specified file as a target of a #include, #include_next, or #import directive. | |
SrcMgr::CharacteristicKind | getFileDirFlavor (FileEntryRef File) |
Return whether the specified file is a normal header, a system header, or a C++ friendly system header. | |
void | MarkFileIncludeOnce (FileEntryRef File) |
Mark the specified file as a "once only" file due to #pragma once. | |
void | MarkFileSystemHeader (FileEntryRef File) |
Mark the specified file as a system header, e.g. | |
void | MarkFileModuleHeader (FileEntryRef FE, ModuleMap::ModuleHeaderRole Role, bool isCompilingModuleHeader) |
Mark the specified file as part of a module. | |
void | SetFileControllingMacro (FileEntryRef File, const IdentifierInfo *ControllingMacro) |
Mark the specified file as having a controlling macro. | |
bool | isFileMultipleIncludeGuarded (FileEntryRef File) const |
Determine whether this file is intended to be safe from multiple inclusions, e.g., it has #pragma once or a controlling macro. | |
bool | hasFileBeenImported (FileEntryRef File) const |
Determine whether the given file is known to have ever been #imported. | |
std::vector< bool > | computeUserEntryUsage () const |
Determine which HeaderSearchOptions::UserEntries have been successfully used so far and mark their index with 'true' in the resulting bit vector. | |
std::vector< bool > | collectVFSUsageAndClear () const |
Collect which HeaderSearchOptions::VFSOverlayFiles have been meaningfully used so far and mark their index with 'true' in the resulting bit vector. | |
const HeaderMap * | CreateHeaderMap (FileEntryRef FE) |
This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' datastructure. | |
void | getHeaderMapFileNames (SmallVectorImpl< std::string > &Names) const |
Get filenames for all registered header maps. | |
std::string | getCachedModuleFileName (Module *Module) |
Retrieve the name of the cached module file that should be used to load the given module. | |
std::string | getPrebuiltModuleFileName (StringRef ModuleName, bool FileMapOnly=false) |
Retrieve the name of the prebuilt module file that should be used to load a module with the given name. | |
std::string | getPrebuiltImplicitModuleFileName (Module *Module) |
Retrieve the name of the prebuilt module file that should be used to load the given module. | |
std::string | getCachedModuleFileName (StringRef ModuleName, StringRef ModuleMapPath) |
Retrieve the name of the (to-be-)cached module file that should be used to load a module with the given name. | |
Module * | lookupModule (StringRef ModuleName, SourceLocation ImportLoc=SourceLocation(), bool AllowSearch=true, bool AllowExtraModuleMapSearch=false) |
Lookup a module Search for a module with the given name. | |
OptionalFileEntryRef | lookupModuleMapFile (DirectoryEntryRef Dir, bool IsFramework) |
Try to find a module map file in the given directory, returning nullopt if none is found. | |
bool | hasModuleMap (StringRef Filename, const DirectoryEntry *Root, bool IsSystem) |
Determine whether there is a module map that may map the header with the given file name to a (sub)module. | |
ModuleMap::KnownHeader | findModuleForHeader (FileEntryRef File, bool AllowTextual=false, bool AllowExcluded=false) const |
Retrieve the module that corresponds to the given file, if any. | |
ArrayRef< ModuleMap::KnownHeader > | findAllModulesForHeader (FileEntryRef File) const |
Retrieve all the modules corresponding to the given file. | |
ArrayRef< ModuleMap::KnownHeader > | findResolvedModulesForHeader (FileEntryRef File) const |
Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if we've not already done so. | |
bool | loadModuleMapFile (FileEntryRef File, bool IsSystem, FileID ID=FileID(), unsigned *Offset=nullptr, StringRef OriginalModuleMapFile=StringRef()) |
Read the contents of the given module map file. | |
void | collectAllModules (SmallVectorImpl< Module * > &Modules) |
Collect the set of all known, top-level modules. | |
void | loadTopLevelSystemModules () |
Load all known, top-level system modules. | |
ModuleMap & | getModuleMap () |
Retrieve the module map. | |
const ModuleMap & | getModuleMap () const |
Retrieve the module map. | |
unsigned | header_file_size () const |
HeaderFileInfo & | getFileInfo (FileEntryRef FE) |
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in some way. | |
const HeaderFileInfo * | getExistingFileInfo (FileEntryRef FE) const |
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in (either locally or externally). | |
const HeaderFileInfo * | getExistingLocalFileInfo (FileEntryRef FE) const |
Return the headerFileInfo structure for the specified FileEntry, if it has ever been filled in locally. | |
SearchDirIterator | search_dir_begin () |
SearchDirIterator | search_dir_end () |
SearchDirRange | search_dir_range () |
ConstSearchDirIterator | search_dir_begin () const |
ConstSearchDirIterator | search_dir_nth (size_t n) const |
ConstSearchDirIterator | search_dir_end () const |
ConstSearchDirRange | search_dir_range () const |
unsigned | search_dir_size () const |
ConstSearchDirIterator | quoted_dir_begin () const |
ConstSearchDirIterator | quoted_dir_end () const |
ConstSearchDirIterator | angled_dir_begin () const |
ConstSearchDirIterator | angled_dir_end () const |
ConstSearchDirIterator | system_dir_begin () const |
ConstSearchDirIterator | system_dir_end () const |
unsigned | searchDirIdx (const DirectoryLookup &DL) const |
Get the index of the given search directory. | |
StringRef | getUniqueFrameworkName (StringRef Framework) |
Retrieve a uniqued framework name. | |
StringRef | getIncludeNameForHeader (const FileEntry *File) const |
Retrieve the include name for the header. | |
std::string | suggestPathToFileForDiagnostics (FileEntryRef File, llvm::StringRef MainFile, bool *IsAngled=nullptr) const |
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. | |
std::string | suggestPathToFileForDiagnostics (llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile, bool *IsAngled=nullptr) const |
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. | |
void | PrintStats () |
size_t | getTotalMemory () const |
Friends | |
class | DirectoryLookup |
Encapsulates the information needed to find the file referenced by a #include or #include_next, (sub-)framework lookup, etc.
Definition at line 237 of file HeaderSearch.h.
HeaderSearch::HeaderSearch | ( | std::shared_ptr< HeaderSearchOptions > | HSOpts, |
SourceManager & | SourceMgr, | ||
DiagnosticsEngine & | Diags, | ||
const LangOptions & | LangOpts, | ||
const TargetInfo * | Target | ||
) |
Definition at line 83 of file HeaderSearch.cpp.
|
delete |
|
inline |
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.
Definition at line 402 of file HeaderSearch.h.
Referenced by clang::Preprocessor::HandlePragmaIncludeAlias().
void HeaderSearch::AddSearchPath | ( | const DirectoryLookup & | dir, |
bool | isAngled | ||
) |
Add an additional search path.
Definition at line 122 of file HeaderSearch.cpp.
|
inline |
Add an additional system search path.
Definition at line 385 of file HeaderSearch.h.
|
inline |
Definition at line 861 of file HeaderSearch.h.
Referenced by LookupFile(), and quoted_dir_end().
|
inline |
Definition at line 864 of file HeaderSearch.h.
References system_dir_begin().
|
inline |
Forget everything we know about headers so far.
Definition at line 442 of file HeaderSearch.h.
void HeaderSearch::collectAllModules | ( | SmallVectorImpl< Module * > & | Modules | ) |
Collect the set of all known, top-level modules.
Modules | Will be filled with the set of known, top-level modules. |
Definition at line 1885 of file HeaderSearch.cpp.
References clang::FileManager::getOptionalDirectoryRef(), clang::FileManager::getVirtualFileSystem(), loadModuleMapFile(), clang::ModuleMap::modules(), and search_dir_range().
Referenced by clang::SemaCodeCompletion::CodeCompleteModuleImport().
std::vector< bool > HeaderSearch::collectVFSUsageAndClear | ( | ) | const |
Collect which HeaderSearchOptions::VFSOverlayFiles have been meaningfully used so far and mark their index with 'true' in the resulting bit vector.
Note: this ignores VFSs that redirect non-affecting files such as unused modulemaps.
Definition at line 145 of file HeaderSearch.cpp.
References getHeaderSearchOpts(), and clang::FileManager::getVirtualFileSystem().
std::vector< bool > HeaderSearch::computeUserEntryUsage | ( | ) | const |
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.
Definition at line 131 of file HeaderSearch.cpp.
References E.
const HeaderMap * HeaderSearch::CreateHeaderMap | ( | FileEntryRef | FE | ) |
This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' datastructure.
CreateHeaderMap - This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' datastructure.
Definition at line 169 of file HeaderSearch.cpp.
References clang::HeaderMap::Create().
ArrayRef< ModuleMap::KnownHeader > HeaderSearch::findAllModulesForHeader | ( | FileEntryRef | File | ) | const |
Retrieve all the modules corresponding to the given file.
findModuleForHeader should typically be used instead of this.
Definition at line 1610 of file HeaderSearch.cpp.
References clang::File, clang::ModuleMap::findAllModulesForHeader(), and getExistingFileInfo().
Referenced by clang::Preprocessor::getHeaderToIncludeForDiagnostics().
ModuleMap::KnownHeader HeaderSearch::findModuleForHeader | ( | FileEntryRef | File, |
bool | AllowTextual = false , |
||
bool | AllowExcluded = false |
||
) | const |
Retrieve the module that corresponds to the given file, if any.
File | The header that we wish to map to a module. |
AllowTextual | Whether we want to find textual headers too. |
Definition at line 1599 of file HeaderSearch.cpp.
References clang::File, clang::ModuleMap::findModuleForHeader(), and getExistingFileInfo().
Referenced by clang::VerifyDiagnosticConsumer::HandleDiagnostic(), and suggestModule().
ArrayRef< ModuleMap::KnownHeader > HeaderSearch::findResolvedModulesForHeader | ( | FileEntryRef | File | ) | const |
Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if we've not already done so.
Definition at line 1620 of file HeaderSearch.cpp.
References clang::File, clang::ModuleMap::findResolvedModulesForHeader(), and getExistingFileInfo().
std::string HeaderSearch::getCachedModuleFileName | ( | Module * | Module | ) |
Retrieve the name of the cached module file that should be used to load the given module.
Module | The module whose module file name will be returned. |
Definition at line 195 of file HeaderSearch.cpp.
References getCachedModuleFileName(), getModuleMap(), clang::ModuleMap::getModuleMapFileForUniquing(), and clang::Module::Name.
Referenced by getCachedModuleFileName(), and selectModuleSource().
std::string HeaderSearch::getCachedModuleFileName | ( | StringRef | ModuleName, |
StringRef | ModuleMapPath | ||
) |
Retrieve the name of the (to-be-)cached module file that should be used to load a module with the given name.
ModuleName | The module whose module file name will be returned. |
ModuleMapPath | A path that when combined with ModuleName uniquely identifies this module. See Module::ModuleMap. |
Definition at line 254 of file HeaderSearch.cpp.
References getModuleCachePath().
|
inline |
Definition at line 374 of file HeaderSearch.h.
const HeaderFileInfo * HeaderSearch::getExistingFileInfo | ( | FileEntryRef | FE | ) | const |
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in (either locally or externally).
Definition at line 1328 of file HeaderSearch.cpp.
References clang::FileEntryRef::getUID(), clang::HeaderFileInfo::IsValid, mergeHeaderFileInfo(), and clang::HeaderFileInfo::Resolved.
Referenced by findAllModulesForHeader(), findModuleForHeader(), findResolvedModulesForHeader(), getFileDirFlavor(), hasFileBeenImported(), isFileMultipleIncludeGuarded(), LookupFile(), LookupSubframeworkHeader(), and MarkFileModuleHeader().
const HeaderFileInfo * HeaderSearch::getExistingLocalFileInfo | ( | FileEntryRef | FE | ) | const |
Return the headerFileInfo structure for the specified FileEntry, if it has ever been filled in locally.
Definition at line 1354 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::External, clang::FileEntryRef::getUID(), and clang::HeaderFileInfo::IsValid.
|
inline |
Definition at line 450 of file HeaderSearch.h.
|
inline |
Return whether the specified file is a normal header, a system header, or a C++ friendly system header.
Definition at line 539 of file HeaderSearch.h.
References clang::HeaderFileInfo::DirInfo, clang::File, and getExistingFileInfo().
Referenced by EvaluateHasIncludeCommon().
HeaderFileInfo & HeaderSearch::getFileInfo | ( | FileEntryRef | FE | ) |
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in some way.
Definition at line 1306 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::External, clang::FileEntryRef::getUID(), clang::HeaderFileInfo::IsValid, mergeHeaderFileInfo(), and clang::HeaderFileInfo::Resolved.
Referenced by clang::Preprocessor::alreadyIncluded(), LookupFile(), LookupSubframeworkHeader(), MarkFileIncludeOnce(), MarkFileModuleHeader(), MarkFileSystemHeader(), clang::Preprocessor::markIncluded(), SetFileControllingMacro(), and ShouldEnterIncludeFile().
|
inline |
Definition at line 372 of file HeaderSearch.h.
Referenced by clang::ApplyHeaderSearchOptions(), getPrebuiltImplicitModuleFileName(), getPrebuiltModuleFileName(), and clang::DirectoryLookup::LookupFile().
void HeaderSearch::getHeaderMapFileNames | ( | SmallVectorImpl< std::string > & | Names | ) | const |
Get filenames for all registered header maps.
Definition at line 189 of file HeaderSearch.cpp.
Referenced by collectHeaderMaps().
|
inline |
Retrieve the header-search options with which this header search was initialized.
Definition at line 370 of file HeaderSearch.h.
Referenced by collectVFSUsageAndClear(), clang::CompilerInstance::createPCHExternalASTSource(), clang::Sema::getDarwinSDKInfoForAvailabilityChecking(), clang::CXX20ModulesGenerator::HandleTranslationUnit(), clang::PCHGenerator::InitializeSema(), loadModuleMapFile(), and selectModuleSource().
StringRef HeaderSearch::getIncludeNameForHeader | ( | const FileEntry * | File | ) | const |
Retrieve the include name for the header.
File | The entry for a given header. |
Definition at line 1544 of file HeaderSearch.cpp.
References clang::File.
Referenced by clang::installapi::InstallAPIContext::findAndRecordFile().
|
inline |
Retrieve the path to the module cache.
Definition at line 434 of file HeaderSearch.h.
Referenced by clang::FrontendAction::Execute(), getCachedModuleFileName(), and clang::PCHValidator::ReadHeaderSearchOptions().
|
inline |
Retrieve the module hash.
Definition at line 431 of file HeaderSearch.h.
Referenced by getPrebuiltImplicitModuleFileName().
|
inline |
Retrieve the module map.
Definition at line 821 of file HeaderSearch.h.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnModuleDecl(), clang::Sema::ActOnPrivateModuleFragmentDecl(), clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), clang::ApplyHeaderSearchOptions(), clang::DependencyCollector::attachToPreprocessor(), clang::ModuleDependencyCollector::attachToPreprocessor(), clang::FrontendAction::BeginSourceFile(), compileModule(), clang::Preprocessor::EnterSubmodule(), getCachedModuleFileName(), getInputBufferForModule(), clang::Preprocessor::getModuleForLocation(), getPrebuiltImplicitModuleFileName(), clang::CompilerInstance::loadGlobalModuleIndex(), clang::CompilerInstance::loadModule(), loadModuleMapForModuleBuild(), clang::serialization::ModuleManager::lookupByModuleName(), clang::Preprocessor::LookupFile(), prepareToBuildModule(), and suggestModule().
|
inline |
Retrieve the module map.
Definition at line 824 of file HeaderSearch.h.
std::string HeaderSearch::getPrebuiltImplicitModuleFileName | ( | Module * | Module | ) |
Retrieve the name of the prebuilt module file that should be used to load the given module.
Module | The module whose module file name will be returned. |
Definition at line 236 of file HeaderSearch.cpp.
References clang::FileName, getFileMgr(), getModuleHash(), getModuleMap(), clang::ModuleMap::getModuleMapFileForUniquing(), and clang::Module::Name.
Referenced by selectModuleSource().
std::string HeaderSearch::getPrebuiltModuleFileName | ( | StringRef | ModuleName, |
bool | FileMapOnly = false |
||
) |
Retrieve the name of the prebuilt module file that should be used to load a module with the given name.
ModuleName | The module whose module file name will be returned. |
FileMapOnly | If true, then only look in the explicit module name |
Definition at line 205 of file HeaderSearch.cpp.
References getFileMgr(), and clang::Result.
Referenced by selectModuleSource().
size_t HeaderSearch::getTotalMemory | ( | ) | const |
Definition at line 1528 of file HeaderSearch.cpp.
StringRef HeaderSearch::getUniqueFrameworkName | ( | StringRef | Framework | ) |
Retrieve a uniqued framework name.
Definition at line 1540 of file HeaderSearch.cpp.
|
inline |
Determine whether the given file is known to have ever been #imported.
Definition at line 578 of file HeaderSearch.h.
References clang::File, getExistingFileInfo(), and clang::HeaderFileInfo::isImport.
Referenced by clang::tooling::isSelfContainedHeader().
|
inline |
Checks whether the map exists or not.
Definition at line 396 of file HeaderSearch.h.
bool HeaderSearch::hasModuleMap | ( | StringRef | Filename, |
const DirectoryEntry * | Root, | ||
bool | IsSystem | ||
) |
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.
Filename | The name of the file. |
Root | The "root" directory, at which we should stop looking for module maps. |
IsSystem | Whether the directories we're looking at are system header directories. |
Definition at line 1551 of file HeaderSearch.cpp.
References clang::FileName, clang::FileManager::getOptionalDirectoryRef(), and loadModuleMapFile().
Referenced by clang::Preprocessor::getHeaderToIncludeForDiagnostics().
|
inline |
Definition at line 826 of file HeaderSearch.h.
bool HeaderSearch::isFileMultipleIncludeGuarded | ( | FileEntryRef | File | ) | const |
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
Definition at line 1365 of file HeaderSearch.cpp.
References clang::File, and getExistingFileInfo().
Referenced by clang::tooling::isSelfContainedHeader().
bool HeaderSearch::loadModuleMapFile | ( | FileEntryRef | File, |
bool | IsSystem, | ||
FileID | ID = FileID() , |
||
unsigned * | Offset = nullptr , |
||
StringRef | OriginalModuleMapFile = StringRef() |
||
) |
Read the contents of the given module map file.
File | The module map file. |
IsSystem | Whether this file is in a system header directory. |
ID | If the module map file is already mapped (perhaps as part of processing a preprocessed module), the ID of the file. |
Offset | [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). |
OriginalModuleMapFile | 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). |
Definition at line 1723 of file HeaderSearch.cpp.
References clang::File, getHeaderSearchOpts(), clang::DirectoryEntryRef::getName(), clang::FileManager::getOptionalDirectoryRef(), and clang::FileManager::getVirtualFileRef().
Referenced by clang::FrontendAction::BeginSourceFile(), collectAllModules(), hasModuleMap(), loadModuleMapForModuleBuild(), and loadTopLevelSystemModules().
void HeaderSearch::loadTopLevelSystemModules | ( | ) |
Load all known, top-level system modules.
Definition at line 1934 of file HeaderSearch.cpp.
References loadModuleMapFile(), and search_dir_range().
OptionalFileEntryRef HeaderSearch::LookupFile | ( | StringRef | Filename, |
SourceLocation | IncludeLoc, | ||
bool | isAngled, | ||
ConstSearchDirIterator | FromDir, | ||
ConstSearchDirIterator * | CurDirArg, | ||
ArrayRef< std::pair< OptionalFileEntryRef, DirectoryEntryRef > > | Includers, | ||
SmallVectorImpl< char > * | SearchPath, | ||
SmallVectorImpl< char > * | RelativePath, | ||
Module * | RequestingModule, | ||
ModuleMap::KnownHeader * | SuggestedModule, | ||
bool * | IsMapped, | ||
bool * | IsFrameworkFound, | ||
bool | SkipCache = false , |
||
bool | BuildSystemModule = false , |
||
bool | OpenFile = true , |
||
bool | CacheFailures = true |
||
) |
Given a "foo" or <foo> reference, look up the indicated file, return null on failure.
LookupFile - Given a "foo" or <foo> reference, look up the indicated file, return null on failure.
IncludeLoc | Used for diagnostics if valid. |
isAngled | indicates whether the file reference is a <> reference. |
CurDir | If non-null, the file was found in the specified directory search location. This is used to implement #include_next. |
Includers | Indicates where the #including file(s) are, in case relative searches are needed. In reverse order of inclusion. |
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. |
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. |
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. |
IsMapped | If non-null, and the search involved header maps, set to true. |
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. |
isAngled indicates whether the file reference is for system #include's or not (i.e. using <> instead of ""). Includers, if non-empty, indicates where the #including file(s) are, in case a relative search is needed. Microsoft mode will pass all #including files.
Definition at line 885 of file HeaderSearch.cpp.
References angled_dir_begin(), clang::SrcMgr::C_System, clang::SrcMgr::C_User, checkMSVCHeaderSearch(), copyString(), diagnoseFrameworkInclude(), clang::HeaderFileInfo::DirInfo, false, clang::File, Filename, clang::First, getExistingFileInfo(), getFileInfo(), clang::DiagnosticsEngine::isIgnored(), Iter, search_dir_begin(), search_dir_end(), and search_dir_nth().
Referenced by clang::FrontendAction::BeginSourceFile(), and clang::Preprocessor::LookupFile().
|
inline |
Look up the specified framework name in our framework cache.
Definition at line 521 of file HeaderSearch.h.
Module * HeaderSearch::lookupModule | ( | StringRef | ModuleName, |
SourceLocation | ImportLoc = SourceLocation() , |
||
bool | AllowSearch = true , |
||
bool | AllowExtraModuleMapSearch = false |
||
) |
Lookup a module Search for a module with the given name.
ModuleName | The name of the module we're looking for. |
ImportLoc | Location of the module include/import. |
AllowSearch | 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. |
AllowExtraModuleMapSearch | Whether we allow to search modulemaps in subdirectories. |
Definition at line 293 of file HeaderSearch.cpp.
References clang::ModuleMap::findModule(), and lookupModule().
Referenced by clang::Sema::BuildModuleInclude(), clang::Preprocessor::getCurrentModule(), clang::FrontendAction::getCurrentModule(), clang::Preprocessor::getCurrentModuleImplementation(), clang::PCHGenerator::getEmittingModule(), clang::Preprocessor::getModuleForLocation(), getTopImportImplicitModule(), clang::ASTUnit::LoadFromASTFile(), clang::CompilerInstance::loadModule(), lookupModule(), and prepareToBuildModule().
OptionalFileEntryRef HeaderSearch::lookupModuleMapFile | ( | DirectoryEntryRef | Dir, |
bool | IsFramework | ||
) |
Try to find a module map file in the given directory, returning nullopt
if none is found.
Definition at line 1799 of file HeaderSearch.cpp.
References clang::DirectoryEntryRef::getName(), clang::FileManager::getOptionalFileRef(), and clang::DiagnosticsEngine::Report().
OptionalFileEntryRef HeaderSearch::LookupSubframeworkHeader | ( | StringRef | Filename, |
FileEntryRef | ContextFileEnt, | ||
SmallVectorImpl< char > * | SearchPath, | ||
SmallVectorImpl< char > * | RelativePath, | ||
Module * | RequestingModule, | ||
ModuleMap::KnownHeader * | SuggestedModule | ||
) |
Look up a subframework for the specified #include file.
LookupSubframeworkHeader - 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.
Definition at line 1153 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::DirInfo, clang::File, Filename, getExistingFileInfo(), getFileInfo(), clang::FileEntryRef::getName(), clang::FileManager::getOptionalDirectoryRef(), and clang::FileManager::getOptionalFileRef().
Referenced by clang::Preprocessor::LookupFile().
|
inline |
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.
Definition at line 412 of file HeaderSearch.h.
References Iter.
|
inline |
Mark the specified file as a "once only" file due to #pragma once.
Definition at line 547 of file HeaderSearch.h.
References clang::File, getFileInfo(), and clang::HeaderFileInfo::isPragmaOnce.
Referenced by clang::Preprocessor::HandlePragmaOnce().
void HeaderSearch::MarkFileModuleHeader | ( | FileEntryRef | FE, |
ModuleMap::ModuleHeaderRole | Role, | ||
bool | isCompilingModuleHeader | ||
) |
Mark the specified file as part of a module.
Definition at line 1374 of file HeaderSearch.cpp.
References clang::ModuleMap::ExcludedHeader, getExistingFileInfo(), getFileInfo(), and moduleMembershipNeedsMerge().
Referenced by clang::ModuleMap::addHeader().
|
inline |
Mark the specified file as a system header, e.g.
due to #pragma GCC system_header.
Definition at line 553 of file HeaderSearch.h.
References clang::SrcMgr::C_System, clang::HeaderFileInfo::DirInfo, clang::File, and getFileInfo().
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
|
delete |
void HeaderSearch::PrintStats | ( | ) |
Definition at line 91 of file HeaderSearch.cpp.
Referenced by clang::FrontendAction::EndSourceFile().
|
inline |
Definition at line 858 of file HeaderSearch.h.
Referenced by search_dir_begin().
|
inline |
Definition at line 859 of file HeaderSearch.h.
References angled_dir_begin().
|
inline |
Definition at line 840 of file HeaderSearch.h.
Referenced by LookupFile(), and search_dir_range().
|
inline |
Definition at line 846 of file HeaderSearch.h.
References quoted_dir_begin().
|
inline |
Definition at line 841 of file HeaderSearch.h.
Referenced by LookupFile(), and search_dir_range().
|
inline |
Definition at line 851 of file HeaderSearch.h.
References system_dir_end().
|
inline |
Definition at line 847 of file HeaderSearch.h.
Referenced by LookupFile().
|
inline |
Definition at line 842 of file HeaderSearch.h.
References search_dir_begin(), and search_dir_end().
Referenced by collectAllModules(), loadTopLevelSystemModules(), and suggestPathToFileForDiagnostics().
|
inline |
Definition at line 852 of file HeaderSearch.h.
References search_dir_begin(), and search_dir_end().
|
inline |
Definition at line 856 of file HeaderSearch.h.
unsigned HeaderSearch::searchDirIdx | ( | const DirectoryLookup & | DL | ) | const |
Get the index of the given search directory.
Definition at line 1536 of file HeaderSearch.cpp.
Referenced by clang::DirectoryLookup::LookupFile().
|
inline |
Consider modules when including files from this directory.
Definition at line 437 of file HeaderSearch.h.
|
inline |
Definition at line 446 of file HeaderSearch.h.
|
inline |
Set the external source of header information.
Definition at line 455 of file HeaderSearch.h.
|
inline |
Mark the specified file as having a controlling macro.
This is used by the multiple-include optimization to eliminate no-op #includes.
Definition at line 565 of file HeaderSearch.h.
References clang::File, getFileInfo(), and clang::HeaderFileInfo::LazyControllingMacro.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
inline |
Set the path to the module cache.
Definition at line 426 of file HeaderSearch.h.
|
inline |
Set the hash to use for module cache paths.
Definition at line 423 of file HeaderSearch.h.
void HeaderSearch::SetSearchPaths | ( | std::vector< DirectoryLookup > | dirs, |
unsigned | angledDirIdx, | ||
unsigned | systemDirIdx, | ||
llvm::DenseMap< unsigned, unsigned > | searchDirToHSEntry | ||
) |
Interface for setting the file search paths.
Definition at line 107 of file HeaderSearch.cpp.
|
inline |
Set the list of system header prefixes.
Definition at line 391 of file HeaderSearch.h.
References P.
void HeaderSearch::setTarget | ( | const TargetInfo & | Target | ) |
Set the target information for the header search, if not already known.
Definition at line 770 of file HeaderSearch.cpp.
References clang::ModuleMap::setTarget().
Referenced by clang::Preprocessor::Initialize().
bool HeaderSearch::ShouldEnterIncludeFile | ( | Preprocessor & | PP, |
FileEntryRef | File, | ||
bool | isImport, | ||
bool | ModulesEnabled, | ||
Module * | M, | ||
bool & | IsFirstIncludeOfFile | ||
) |
Mark the specified file as a target of a #include, #include_next, or #import directive.
M | The module to which File belongs (this should usually be the SuggestedModule returned by LookupFile/LookupSubframeworkHeader) |
Definition at line 1391 of file HeaderSearch.cpp.
References clang::Preprocessor::alreadyIncluded(), clang::File, clang::HeaderFileInfo::getControllingMacro(), getFileInfo(), clang::ModuleMap::isBuiltinHeader(), clang::HeaderFileInfo::isCompilingModuleHeader, clang::HeaderFileInfo::isImport, clang::Preprocessor::isMacroDefined(), clang::Preprocessor::isMacroDefinedInLocalModule(), clang::HeaderFileInfo::isModuleHeader, clang::HeaderFileInfo::isPragmaOnce, clang::HeaderFileInfo::isTextualModuleHeader, clang::Preprocessor::markIncluded(), and clang::ModuleMap::resolveHeaderDirectives().
std::string HeaderSearch::suggestPathToFileForDiagnostics | ( | FileEntryRef | File, |
llvm::StringRef | MainFile, | ||
bool * | IsAngled = nullptr |
||
) | const |
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.
IsAngled | If non-null, filled in to indicate whether the suggested path should be referenced as <Header.h> instead of "Header.h". |
Definition at line 1976 of file HeaderSearch.cpp.
References clang::File, and suggestPathToFileForDiagnostics().
Referenced by getHeaderNameForHeader(), and suggestPathToFileForDiagnostics().
std::string HeaderSearch::suggestPathToFileForDiagnostics | ( | llvm::StringRef | File, |
llvm::StringRef | WorkingDir, | ||
llvm::StringRef | MainFile, | ||
bool * | IsAngled = nullptr |
||
) | const |
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.
WorkingDir | If non-empty, this will be prepended to search directory paths that are relative. |
Definition at line 1982 of file HeaderSearch.cpp.
References clang::File, Filename, isFrameworkStylePath(), and search_dir_range().
|
inline |
Definition at line 866 of file HeaderSearch.h.
Referenced by angled_dir_end().
|
inline |
Definition at line 869 of file HeaderSearch.h.
Referenced by search_dir_end().
|
friend |
Definition at line 238 of file HeaderSearch.h.