clang
12.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 Types | |
using | search_dir_iterator = std::vector< DirectoryLookup >::const_iterator |
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. More... | |
FileManager & | getFileMgr () const |
DiagnosticsEngine & | getDiags () const |
void | SetSearchPaths (const std::vector< DirectoryLookup > &dirs, unsigned angledDirIdx, unsigned systemDirIdx, bool noCurDirSearch) |
Interface for setting the file search paths. More... | |
void | AddSearchPath (const DirectoryLookup &dir, bool isAngled) |
Add an additional search path. More... | |
void | SetSystemHeaderPrefixes (ArrayRef< std::pair< std::string, bool >> P) |
Set the list of system header prefixes. More... | |
bool | HasIncludeAliasMap () const |
Checks whether the map exists or not. More... | |
void | AddIncludeAlias (StringRef Source, StringRef Dest) |
Map the source include name to the dest include name. More... | |
StringRef | MapHeaderToIncludeAlias (StringRef Source) |
Maps one header file name to a different header file name, for use with the include_alias pragma. More... | |
void | setModuleHash (StringRef Hash) |
Set the hash to use for module cache paths. More... | |
void | setModuleCachePath (StringRef CachePath) |
Set the path to the module cache. More... | |
StringRef | getModuleHash () const |
Retrieve the module hash. More... | |
StringRef | getModuleCachePath () const |
Retrieve the path to the module cache. More... | |
void | setDirectoryHasModuleMap (const DirectoryEntry *Dir) |
Consider modules when including files from this directory. More... | |
void | ClearFileInfo () |
Forget everything we know about headers so far. More... | |
void | SetExternalLookup (ExternalPreprocessorSource *EPS) |
ExternalPreprocessorSource * | getExternalLookup () const |
void | SetExternalSource (ExternalHeaderFileInfoSource *ES) |
Set the external source of header information. More... | |
void | setTarget (const TargetInfo &Target) |
Set the target information for the header search, if not already known. More... | |
Optional< FileEntryRef > | LookupFile (StringRef Filename, SourceLocation IncludeLoc, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, ArrayRef< std::pair< const FileEntry *, const DirectoryEntry * >> Includers, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool *IsFrameworkFound, bool SkipCache=false, bool BuildSystemModule=false) |
Given a "foo" or <foo> reference, look up the indicated file, return null on failure. More... | |
Optional< FileEntryRef > | LookupSubframeworkHeader (StringRef Filename, const FileEntry *ContextFileEnt, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) |
Look up a subframework for the specified #include file. More... | |
FrameworkCacheEntry & | LookupFrameworkCache (StringRef FWName) |
Look up the specified framework name in our framework cache. More... | |
bool | ShouldEnterIncludeFile (Preprocessor &PP, const FileEntry *File, bool isImport, bool ModulesEnabled, Module *M) |
Mark the specified file as a target of a #include, #include_next, or #import directive. More... | |
SrcMgr::CharacteristicKind | getFileDirFlavor (const FileEntry *File) |
Return whether the specified file is a normal header, a system header, or a C++ friendly system header. More... | |
void | MarkFileIncludeOnce (const FileEntry *File) |
Mark the specified file as a "once only" file, e.g. More... | |
void | MarkFileSystemHeader (const FileEntry *File) |
Mark the specified file as a system header, e.g. More... | |
void | MarkFileModuleHeader (const FileEntry *FE, ModuleMap::ModuleHeaderRole Role, bool isCompilingModuleHeader) |
Mark the specified file as part of a module. More... | |
void | IncrementIncludeCount (const FileEntry *File) |
Increment the count for the number of times the specified FileEntry has been entered. More... | |
void | SetFileControllingMacro (const FileEntry *File, const IdentifierInfo *ControllingMacro) |
Mark the specified file as having a controlling macro. More... | |
bool | FirstTimeLexingFile (const FileEntry *File) |
Return true if this is the first time encountering this header. More... | |
bool | isFileMultipleIncludeGuarded (const FileEntry *File) |
Determine whether this file is intended to be safe from multiple inclusions, e.g., it has #pragma once or a controlling macro. More... | |
bool | hasFileBeenImported (const FileEntry *File) |
Determine whether the given file is known to have ever been #imported (or if it has been #included and we've encountered a #pragma once). More... | |
const HeaderMap * | CreateHeaderMap (const FileEntry *FE) |
This method returns a HeaderMap for the specified FileEntry, uniquing them through the 'HeaderMaps' datastructure. More... | |
void | getHeaderMapFileNames (SmallVectorImpl< std::string > &Names) const |
Get filenames for all registered header maps. More... | |
std::string | getCachedModuleFileName (Module *Module) |
Retrieve the name of the cached module file that should be used to load the given module. More... | |
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. More... | |
std::string | getPrebuiltImplicitModuleFileName (Module *Module) |
Retrieve the name of the prebuilt module file that should be used to load the given module. More... | |
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. More... | |
Module * | lookupModule (StringRef ModuleName, bool AllowSearch=true, bool AllowExtraModuleMapSearch=false) |
Lookup a module Search for a module with the given name. More... | |
const FileEntry * | lookupModuleMapFile (const DirectoryEntry *Dir, bool IsFramework) |
Try to find a module map file in the given directory, returning nullptr if none is found. More... | |
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. More... | |
ModuleMap::KnownHeader | findModuleForHeader (const FileEntry *File, bool AllowTextual=false) const |
Retrieve the module that corresponds to the given file, if any. More... | |
ArrayRef< ModuleMap::KnownHeader > | findAllModulesForHeader (const FileEntry *File) const |
Retrieve all the modules corresponding to the given file. More... | |
bool | loadModuleMapFile (const FileEntry *File, bool IsSystem, FileID ID=FileID(), unsigned *Offset=nullptr, StringRef OriginalModuleMapFile=StringRef()) |
Read the contents of the given module map file. More... | |
void | collectAllModules (SmallVectorImpl< Module * > &Modules) |
Collect the set of all known, top-level modules. More... | |
void | loadTopLevelSystemModules () |
Load all known, top-level system modules. More... | |
ModuleMap & | getModuleMap () |
Retrieve the module map. More... | |
const ModuleMap & | getModuleMap () const |
Retrieve the module map. More... | |
unsigned | header_file_size () const |
HeaderFileInfo & | getFileInfo (const FileEntry *FE) |
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in some way. More... | |
const HeaderFileInfo * | getExistingFileInfo (const FileEntry *FE, bool WantExternal=true) const |
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in. More... | |
search_dir_iterator | search_dir_begin () const |
search_dir_iterator | search_dir_end () const |
unsigned | search_dir_size () const |
search_dir_iterator | quoted_dir_begin () const |
search_dir_iterator | quoted_dir_end () const |
search_dir_iterator | angled_dir_begin () const |
search_dir_iterator | angled_dir_end () const |
search_dir_iterator | system_dir_begin () const |
search_dir_iterator | system_dir_end () const |
StringRef | getUniqueFrameworkName (StringRef Framework) |
Retrieve a uniqued framework name. More... | |
std::string | suggestPathToFileForDiagnostics (const FileEntry *File, llvm::StringRef MainFile, bool *IsSystem=nullptr) |
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. More... | |
std::string | suggestPathToFileForDiagnostics (llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile, bool *IsSystem=nullptr) |
Suggest a path by which the specified file could be found, for use in diagnostics to suggest a #include. More... | |
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 158 of file HeaderSearch.h.
using clang::HeaderSearch::search_dir_iterator = std::vector<DirectoryLookup>::const_iterator |
Definition at line 718 of file HeaderSearch.h.
HeaderSearch::HeaderSearch | ( | std::shared_ptr< HeaderSearchOptions > | HSOpts, |
SourceManager & | SourceMgr, | ||
DiagnosticsEngine & | Diags, | ||
const LangOptions & | LangOpts, | ||
const TargetInfo * | Target | ||
) |
Definition at line 81 of file HeaderSearch.cpp.
References clang::Target.
|
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 305 of file HeaderSearch.h.
Referenced by clang::Preprocessor::HandlePragmaIncludeAlias().
|
inline |
Add an additional search path.
Definition at line 285 of file HeaderSearch.h.
|
inline |
Definition at line 732 of file HeaderSearch.h.
|
inline |
Definition at line 736 of file HeaderSearch.h.
|
inline |
Forget everything we know about headers so far.
Definition at line 345 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 1681 of file HeaderSearch.cpp.
References getName().
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 113 of file HeaderSearch.cpp.
References clang::HeaderMap::Create().
ArrayRef< ModuleMap::KnownHeader > HeaderSearch::findAllModulesForHeader | ( | const FileEntry * | File | ) | const |
Retrieve all the modules corresponding to the given file.
findModuleForHeader should typically be used instead of this.
Definition at line 1423 of file HeaderSearch.cpp.
References clang::File, clang::ModuleMap::findAllModulesForHeader(), and getExistingFileInfo().
Referenced by clang::Preprocessor::getHeaderToIncludeForDiagnostics().
ModuleMap::KnownHeader HeaderSearch::findModuleForHeader | ( | const FileEntry * | File, |
bool | AllowTextual = 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 1412 of file HeaderSearch.cpp.
References clang::File, clang::ModuleMap::findModuleForHeader(), and getExistingFileInfo().
Referenced by clang::VerifyDiagnosticConsumer::HandleDiagnostic(), and suggestModule().
Return true if this is the first time encountering this header.
Definition at line 477 of file HeaderSearch.h.
References clang::File.
Referenced by clang::Preprocessor::HandleEndOfFile().
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 139 of file HeaderSearch.cpp.
References getModuleMap(), clang::ModuleMap::getModuleMapFileForUniquing(), and clang::Module::Name.
Referenced by 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 185 of file HeaderSearch.cpp.
References getModuleCachePath().
|
inline |
Definition at line 269 of file HeaderSearch.h.
const HeaderFileInfo * HeaderSearch::getExistingFileInfo | ( | const FileEntry * | FE, |
bool | WantExternal = true |
||
) | const |
Return the HeaderFileInfo structure for the specified FileEntry, if it has ever been filled in.
WantExternal | Whether the caller wants purely-external header file info (where External is true). |
Definition at line 1206 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::External, clang::ExternalHeaderFileInfoSource::GetHeaderFileInfo(), clang::FileEntry::getUID(), clang::HeaderFileInfo::IsValid, mergeHeaderFileInfo(), and clang::HeaderFileInfo::Resolved.
Referenced by findAllModulesForHeader(), findModuleForHeader(), isFileMultipleIncludeGuarded(), and MarkFileModuleHeader().
|
inline |
Definition at line 353 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 438 of file HeaderSearch.h.
References clang::File.
Referenced by EvaluateHasIncludeCommon().
HeaderFileInfo & HeaderSearch::getFileInfo | ( | const FileEntry * | FE | ) |
Return the HeaderFileInfo structure for the specified FileEntry, in preparation for updating it in some way.
getFileInfo - Return the HeaderFileInfo structure for the specified FileEntry.
Definition at line 1183 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::External, clang::ExternalHeaderFileInfoSource::GetHeaderFileInfo(), clang::FileEntry::getUID(), clang::HeaderFileInfo::IsValid, mergeHeaderFileInfo(), and clang::HeaderFileInfo::Resolved.
Referenced by LookupFile(), LookupSubframeworkHeader(), MarkFileModuleHeader(), and ShouldEnterIncludeFile().
|
inline |
Definition at line 267 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 133 of file HeaderSearch.cpp.
Referenced by collectHeaderMaps().
|
inline |
Retrieve the header-search options with which this header search was initialized.
Definition at line 265 of file HeaderSearch.h.
Referenced by loadModuleMapFile(), and selectModuleSource().
|
inline |
Retrieve the path to the module cache.
Definition at line 337 of file HeaderSearch.h.
Referenced by clang::FrontendAction::Execute(), and getCachedModuleFileName().
|
inline |
Retrieve the module hash.
Definition at line 334 of file HeaderSearch.h.
Referenced by getPrebuiltImplicitModuleFileName().
|
inline |
Retrieve the module map.
Definition at line 699 of file HeaderSearch.h.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::ApplyHeaderSearchOptions(), clang::DependencyCollector::attachToPreprocessor(), clang::ModuleDependencyCollector::attachToPreprocessor(), compileModule(), clang::Preprocessor::EnterSubmodule(), getCachedModuleFileName(), getInputBufferForModule(), clang::Preprocessor::getModuleForLocation(), getPrebuiltImplicitModuleFileName(), clang::CompilerInstance::loadGlobalModuleIndex(), clang::CompilerInstance::loadModule(), clang::CompilerInstance::loadModuleFile(), clang::Preprocessor::LookupFile(), prepareToBuildModule(), and suggestModule().
|
inline |
Retrieve the module map.
Definition at line 702 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 167 of file HeaderSearch.cpp.
References clang::FileManager::getFile(), 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 145 of file HeaderSearch.cpp.
References getFileMgr(), clang::if(), and clang::Result.
Referenced by selectModuleSource().
size_t HeaderSearch::getTotalMemory | ( | ) | const |
Definition at line 1352 of file HeaderSearch.cpp.
StringRef HeaderSearch::getUniqueFrameworkName | ( | StringRef | Framework | ) |
Retrieve a uniqued framework name.
Definition at line 1360 of file HeaderSearch.cpp.
Referenced by LookupFile().
Determine whether the given file is known to have ever been #imported (or if it has been #included and we've encountered a #pragma once).
Definition at line 490 of file HeaderSearch.h.
References clang::File, and clang::HeaderFileInfo::isImport.
|
inline |
Checks whether the map exists or not.
Definition at line 299 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 1364 of file HeaderSearch.cpp.
References clang::FileManager::getDirectory(), and loadModuleMapFile().
Referenced by clang::Preprocessor::getHeaderToIncludeForDiagnostics().
|
inline |
Definition at line 704 of file HeaderSearch.h.
|
inline |
Increment the count for the number of times the specified FileEntry has been entered.
Definition at line 463 of file HeaderSearch.h.
References clang::File.
Referenced by clang::Preprocessor::EnterMainSourceFile().
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 1241 of file HeaderSearch.cpp.
References clang::File, and getExistingFileInfo().
Referenced by clang::Preprocessor::getHeaderToIncludeForDiagnostics().
bool HeaderSearch::loadModuleMapFile | ( | const FileEntry * | 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 1517 of file HeaderSearch.cpp.
References clang::File, clang::FileManager::getDirectory(), getHeaderSearchOpts(), clang::DirectoryEntry::getName(), clang::FileManager::getVirtualFile(), and Offset.
Referenced by hasModuleMap(), loadModuleMapForModuleBuild(), and loadTopLevelSystemModules().
void HeaderSearch::loadTopLevelSystemModules | ( | ) |
Load all known, top-level system modules.
Definition at line 1736 of file HeaderSearch.cpp.
References loadModuleMapFile().
Optional< FileEntryRef > HeaderSearch::LookupFile | ( | StringRef | Filename, |
SourceLocation | IncludeLoc, | ||
bool | isAngled, | ||
const DirectoryLookup * | FromDir, | ||
const DirectoryLookup *& | CurDir, | ||
ArrayRef< std::pair< const FileEntry *, const DirectoryEntry * >> | Includers, | ||
SmallVectorImpl< char > * | SearchPath, | ||
SmallVectorImpl< char > * | RelativePath, | ||
Module * | RequestingModule, | ||
ModuleMap::KnownHeader * | SuggestedModule, | ||
bool * | IsMapped, | ||
bool * | IsFrameworkFound, | ||
bool | SkipCache = false , |
||
bool | BuildSystemModule = false |
||
) |
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 754 of file HeaderSearch.cpp.
References clang::SrcMgr::C_System, clang::SrcMgr::C_User, checkMSVCHeaderSearch(), copyString(), diagnoseFrameworkInclude(), clang::HeaderFileInfo::DirInfo, false, clang::File, Filename, clang::First, clang::HeaderFileInfo::Framework, clang::DirectoryLookup::getDirCharacteristic(), getFileInfo(), getUniqueFrameworkName(), clang::HeaderFileInfo::IndexHeaderMapHeader, clang::DiagnosticsEngine::isIgnored(), clang::DirectoryLookup::isIndexHeaderMap(), and clang::None.
Referenced by clang::Preprocessor::LookupFile().
|
inline |
Look up the specified framework name in our framework cache.
Definition at line 423 of file HeaderSearch.h.
Module * HeaderSearch::lookupModule | ( | StringRef | ModuleName, |
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. |
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 232 of file HeaderSearch.cpp.
References clang::ModuleMap::findModule().
Referenced by clang::FrontendAction::getCurrentModule(), clang::Preprocessor::getCurrentModule(), clang::Preprocessor::getModuleForLocation(), getTopImportImplicitModule(), clang::PCHGenerator::HandleTranslationUnit(), and prepareToBuildModule().
const FileEntry * HeaderSearch::lookupModuleMapFile | ( | const DirectoryEntry * | Dir, |
bool | IsFramework | ||
) |
Try to find a module map file in the given directory, returning nullptr
if none is found.
Definition at line 1595 of file HeaderSearch.cpp.
References clang::FileManager::getFile(), and clang::DirectoryEntry::getName().
Optional< FileEntryRef > HeaderSearch::LookupSubframeworkHeader | ( | StringRef | Filename, |
const FileEntry * | 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 1044 of file HeaderSearch.cpp.
References clang::HeaderFileInfo::DirInfo, clang::File, Filename, clang::FileManager::getDirectory(), getFileInfo(), clang::FileEntry::getName(), clang::FileManager::getOptionalFileRef(), and clang::None.
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 315 of file HeaderSearch.h.
|
inline |
Mark the specified file as a "once only" file, e.g.
due to #pragma once.
Definition at line 444 of file HeaderSearch.h.
References clang::File, clang::HeaderFileInfo::isImport, and clang::HeaderFileInfo::isPragmaOnce.
Referenced by clang::Preprocessor::HandlePragmaOnce().
void HeaderSearch::MarkFileModuleHeader | ( | const FileEntry * | FE, |
ModuleMap::ModuleHeaderRole | Role, | ||
bool | isCompilingModuleHeader | ||
) |
Mark the specified file as part of a module.
Definition at line 1251 of file HeaderSearch.cpp.
References getExistingFileInfo(), getFileInfo(), and clang::ModuleMap::TextualHeader.
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 452 of file HeaderSearch.h.
References clang::SrcMgr::C_System, and clang::File.
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
|
delete |
void HeaderSearch::PrintStats | ( | ) |
Definition at line 89 of file HeaderSearch.cpp.
Referenced by clang::FrontendAction::EndSourceFile().
|
inline |
Definition at line 724 of file HeaderSearch.h.
|
inline |
Definition at line 728 of file HeaderSearch.h.
|
inline |
Definition at line 720 of file HeaderSearch.h.
|
inline |
Definition at line 721 of file HeaderSearch.h.
|
inline |
Definition at line 722 of file HeaderSearch.h.
|
inline |
Consider modules when including files from this directory.
Definition at line 340 of file HeaderSearch.h.
|
inline |
Definition at line 349 of file HeaderSearch.h.
|
inline |
Set the external source of header information.
Definition at line 358 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 471 of file HeaderSearch.h.
References clang::File.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
inline |
Set the path to the module cache.
Definition at line 329 of file HeaderSearch.h.
|
inline |
Set the hash to use for module cache paths.
Definition at line 326 of file HeaderSearch.h.
|
inline |
Interface for setting the file search paths.
Definition at line 272 of file HeaderSearch.h.
|
inline |
Set the list of system header prefixes.
Definition at line 294 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 652 of file HeaderSearch.cpp.
References clang::ModuleMap::setTarget(), and clang::Target.
Referenced by clang::Preprocessor::Initialize().
bool HeaderSearch::ShouldEnterIncludeFile | ( | Preprocessor & | PP, |
const FileEntry * | File, | ||
bool | isImport, | ||
bool | ModulesEnabled, | ||
Module * | M | ||
) |
Mark the specified file as a target of a #include, #include_next, or #import directive.
Definition at line 1270 of file HeaderSearch.cpp.
References 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::NumIncludes, and clang::ModuleMap::resolveHeaderDirectives().
std::string HeaderSearch::suggestPathToFileForDiagnostics | ( | const FileEntry * | File, |
llvm::StringRef | MainFile, | ||
bool * | IsSystem = nullptr |
||
) |
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.
IsSystem | If non-null, filled in to indicate whether the suggested path is relative to a system header directory. |
Definition at line 1778 of file HeaderSearch.cpp.
References clang::File.
Referenced by getHeaderNameForHeader().
std::string HeaderSearch::suggestPathToFileForDiagnostics | ( | llvm::StringRef | File, |
llvm::StringRef | WorkingDir, | ||
llvm::StringRef | MainFile, | ||
bool * | IsSystem = nullptr |
||
) |
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 1787 of file HeaderSearch.cpp.
References clang::File, and clang::interp::NE().
|
inline |
Definition at line 740 of file HeaderSearch.h.
|
inline |
Definition at line 744 of file HeaderSearch.h.
|
friend |
Definition at line 159 of file HeaderSearch.h.