clang 20.0.0git
|
This class handles loading and caching of source files into memory. More...
#include "clang/Basic/SourceManager.h"
Classes | |
struct | MemoryBufferSizes |
Public Types | |
using | fileinfo_iterator = llvm::DenseMap< FileEntryRef, SrcMgr::ContentCache * >::const_iterator |
Public Member Functions | |
SourceManager (DiagnosticsEngine &Diag, FileManager &FileMgr, bool UserFilesAreVolatile=false) | |
SourceManager (const SourceManager &)=delete | |
SourceManager & | operator= (const SourceManager &)=delete |
~SourceManager () | |
void | clearIDTables () |
void | initializeForReplay (const SourceManager &Old) |
Initialize this source manager suitably to replay the compilation described by Old . | |
DiagnosticsEngine & | getDiagnostics () const |
FileManager & | getFileManager () const |
void | setOverridenFilesKeepOriginalName (bool value) |
Set true if the SourceManager should report the original file name for contents of files that were overridden by other files. | |
bool | userFilesAreVolatile () const |
True if non-system source files should be treated as volatile (likely to change while trying to use them). | |
ModuleBuildStack | getModuleBuildStack () const |
Retrieve the module build stack. | |
void | setModuleBuildStack (ModuleBuildStack stack) |
Set the module build stack. | |
void | pushModuleBuildStack (StringRef moduleName, FullSourceLoc importLoc) |
Push an entry to the module build stack. | |
FileID | getMainFileID () const |
Returns the FileID of the main source file. | |
void | setMainFileID (FileID FID) |
Set the file ID for the main source file. | |
bool | isMainFile (const FileEntry &SourceFile) |
Returns true when the given FileEntry corresponds to the main file. | |
void | setPreambleFileID (FileID Preamble) |
Set the file ID for the precompiled preamble. | |
FileID | getPreambleFileID () const |
Get the file ID for the precompiled preamble if there is one. | |
FileID | createFileID (FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0) |
Create a new FileID that represents the specified file being #included from the specified IncludePosition. | |
FileID | createFileID (std::unique_ptr< llvm::MemoryBuffer > Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
Create a new FileID that represents the specified memory buffer. | |
FileID | createFileID (const llvm::MemoryBufferRef &Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
Create a new FileID that represents the specified memory buffer. | |
FileID | getOrCreateFileID (FileEntryRef SourceFile, SrcMgr::CharacteristicKind FileCharacter) |
Get the FileID for SourceFile if it exists. | |
SourceLocation | createMacroArgExpansionLoc (SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length) |
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body. | |
SourceLocation | createExpansionLoc (SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0) |
Creates an expansion SLocEntry for a macro use. | |
SourceLocation | createTokenSplitLoc (SourceLocation SpellingLoc, SourceLocation TokenStart, SourceLocation TokenEnd) |
Return a new SourceLocation that encodes that the token starting at TokenStart ends prematurely at TokenEnd . | |
std::optional< llvm::MemoryBufferRef > | getMemoryBufferForFileOrNone (FileEntryRef File) |
Retrieve the memory buffer associated with the given file. | |
llvm::MemoryBufferRef | getMemoryBufferForFileOrFake (FileEntryRef File) |
Retrieve the memory buffer associated with the given file. | |
void | overrideFileContents (FileEntryRef SourceFile, const llvm::MemoryBufferRef &Buffer) |
Override the contents of the given source file by providing an already-allocated buffer. | |
void | overrideFileContents (FileEntryRef SourceFile, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
Override the contents of the given source file by providing an already-allocated buffer. | |
void | overrideFileContents (const FileEntry *SourceFile, FileEntryRef NewFile) |
Override the given source file with another one. | |
bool | isFileOverridden (const FileEntry *File) const |
Returns true if the file contents have been overridden. | |
OptionalFileEntryRef | bypassFileContentsOverride (FileEntryRef File) |
Bypass the overridden contents of a file. | |
void | setFileIsTransient (FileEntryRef SourceFile) |
Specify that a file is transient. | |
void | setAllFilesAreTransient (bool Transient) |
Specify that all files that are read during this compilation are transient. | |
std::optional< llvm::MemoryBufferRef > | getBufferOrNone (FileID FID, SourceLocation Loc=SourceLocation()) const |
Return the buffer for the specified FileID. | |
llvm::MemoryBufferRef | getBufferOrFake (FileID FID, SourceLocation Loc=SourceLocation()) const |
Return the buffer for the specified FileID. | |
const FileEntry * | getFileEntryForID (FileID FID) const |
Returns the FileEntry record for the provided FileID. | |
OptionalFileEntryRef | getFileEntryRefForID (FileID FID) const |
Returns the FileEntryRef for the provided FileID. | |
std::optional< StringRef > | getNonBuiltinFilenameForID (FileID FID) const |
Returns the filename for the provided FileID, unless it's a built-in buffer that's not represented by a filename. | |
const FileEntry * | getFileEntryForSLocEntry (const SrcMgr::SLocEntry &SLocEntry) const |
Returns the FileEntry record for the provided SLocEntry. | |
StringRef | getBufferData (FileID FID, bool *Invalid=nullptr) const |
Return a StringRef to the source buffer data for the specified FileID. | |
std::optional< StringRef > | getBufferDataOrNone (FileID FID) const |
Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if invalid. | |
std::optional< StringRef > | getBufferDataIfLoaded (FileID FID) const |
Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if it's not yet loaded. | |
unsigned | getNumCreatedFIDsForFileID (FileID FID) const |
Get the number of FileIDs (files and macros) that were created during preprocessing of FID , including it. | |
void | setNumCreatedFIDsForFileID (FileID FID, unsigned NumFIDs, bool Force=false) |
Set the number of FileIDs (files and macros) that were created during preprocessing of FID , including it. | |
FileID | getFileID (SourceLocation SpellingLoc) const |
Return the FileID for a SourceLocation. | |
StringRef | getFilename (SourceLocation SpellingLoc) const |
Return the filename of the file containing a SourceLocation. | |
SourceLocation | getLocForStartOfFile (FileID FID) const |
Return the source location corresponding to the first byte of the specified file. | |
SourceLocation | getLocForEndOfFile (FileID FID) const |
Return the source location corresponding to the last byte of the specified file. | |
SourceLocation | getIncludeLoc (FileID FID) const |
Returns the include location if FID is a #include'd file otherwise it returns an invalid location. | |
std::pair< SourceLocation, StringRef > | getModuleImportLoc (SourceLocation Loc) const |
SourceLocation | getExpansionLoc (SourceLocation Loc) const |
Given a SourceLocation object Loc , return the expansion location referenced by the ID. | |
SourceLocation | getFileLoc (SourceLocation Loc) const |
Given Loc , if it is a macro location return the expansion location or the spelling location, depending on if it comes from a macro argument or not. | |
CharSourceRange | getImmediateExpansionRange (SourceLocation Loc) const |
Return the start/end of the expansion information for an expansion location. | |
CharSourceRange | getExpansionRange (SourceLocation Loc) const |
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file. | |
CharSourceRange | getExpansionRange (SourceRange Range) const |
Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. | |
CharSourceRange | getExpansionRange (CharSourceRange Range) const |
Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. | |
SourceLocation | getSpellingLoc (SourceLocation Loc) const |
Given a SourceLocation object, return the spelling location referenced by the ID. | |
SourceLocation | getImmediateSpellingLoc (SourceLocation Loc) const |
Given a SourceLocation object, return the spelling location referenced by the ID. | |
SourceLocation | getComposedLoc (FileID FID, unsigned Offset) const |
Form a SourceLocation from a FileID and Offset pair. | |
std::pair< FileID, unsigned > | getDecomposedLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. | |
std::pair< FileID, unsigned > | getDecomposedExpansionLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. | |
std::pair< FileID, unsigned > | getDecomposedSpellingLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. | |
std::pair< FileID, unsigned > | getDecomposedIncludedLoc (FileID FID) const |
Returns the "included/expanded in" decomposed location of the given FileID. | |
unsigned | getFileOffset (SourceLocation SpellingLoc) const |
Returns the offset from the start of the file that the specified SourceLocation represents. | |
bool | isMacroArgExpansion (SourceLocation Loc, SourceLocation *StartLoc=nullptr) const |
Tests whether the given source location represents a macro argument's expansion into the function-like macro definition. | |
bool | isMacroBodyExpansion (SourceLocation Loc) const |
Tests whether the given source location represents the expansion of a macro body. | |
bool | isAtStartOfImmediateMacroExpansion (SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const |
Returns true if the given MacroID location points at the beginning of the immediate macro expansion. | |
bool | isAtEndOfImmediateMacroExpansion (SourceLocation Loc, SourceLocation *MacroEnd=nullptr) const |
Returns true if the given MacroID location points at the character end of the immediate macro expansion. | |
bool | isInSLocAddrSpace (SourceLocation Loc, SourceLocation Start, unsigned Length, SourceLocation::UIntTy *RelativeOffset=nullptr) const |
Returns true if Loc is inside the [Start , +Length ) chunk of the source location address space. | |
bool | isInSameSLocAddrSpace (SourceLocation LHS, SourceLocation RHS, SourceLocation::IntTy *RelativeOffset) const |
Return true if both LHS and RHS are in the local source location address space or the loaded one. | |
const char * | getCharacterData (SourceLocation SL, bool *Invalid=nullptr) const |
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer. | |
unsigned | getColumnNumber (FileID FID, unsigned FilePos, bool *Invalid=nullptr) const |
Return the column # for the specified file position. | |
unsigned | getSpellingColumnNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
unsigned | getExpansionColumnNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
unsigned | getPresumedColumnNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
unsigned | getLineNumber (FileID FID, unsigned FilePos, bool *Invalid=nullptr) const |
Given a SourceLocation, return the spelling line number for the position indicated. | |
unsigned | getSpellingLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
unsigned | getExpansionLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
unsigned | getPresumedLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
StringRef | getBufferName (SourceLocation Loc, bool *Invalid=nullptr) const |
Return the filename or buffer identifier of the buffer the location is in. | |
SrcMgr::CharacteristicKind | getFileCharacteristic (SourceLocation Loc) const |
Return the file characteristic of the specified source location, indicating whether this is a normal file, a system header, or an "implicit extern C" system header. | |
PresumedLoc | getPresumedLoc (SourceLocation Loc, bool UseLineDirectives=true) const |
Returns the "presumed" location of a SourceLocation specifies. | |
bool | isInMainFile (SourceLocation Loc) const |
Returns whether the PresumedLoc for a given SourceLocation is in the main file. | |
bool | isWrittenInSameFile (SourceLocation Loc1, SourceLocation Loc2) const |
Returns true if the spelling locations for both SourceLocations are part of the same file buffer. | |
bool | isWrittenInMainFile (SourceLocation Loc) const |
Returns true if the spelling location for the given location is in the main file buffer. | |
bool | isWrittenInBuiltinFile (SourceLocation Loc) const |
Returns whether Loc is located in a <built-in> file. | |
bool | isWrittenInCommandLineFile (SourceLocation Loc) const |
Returns whether Loc is located in a <command line> file. | |
bool | isWrittenInScratchSpace (SourceLocation Loc) const |
Returns whether Loc is located in a <scratch space> file. | |
bool | isInSystemHeader (SourceLocation Loc) const |
Returns if a SourceLocation is in a system header. | |
bool | isInExternCSystemHeader (SourceLocation Loc) const |
Returns if a SourceLocation is in an "extern C" system header. | |
bool | isInSystemMacro (SourceLocation loc) const |
Returns whether Loc is expanded from a macro in a system header. | |
unsigned | getFileIDSize (FileID FID) const |
The size of the SLocEntry that FID represents. | |
bool | isInFileID (SourceLocation Loc, FileID FID, unsigned *RelativeOffset=nullptr) const |
Given a specific FileID, returns true if Loc is inside that FileID chunk and sets relative offset (offset of Loc from beginning of FileID) to relativeOffset . | |
unsigned | getLineTableFilenameID (StringRef Str) |
Return the uniqued ID for the specified filename. | |
void | AddLineNote (SourceLocation Loc, unsigned LineNo, int FilenameID, bool IsFileEntry, bool IsFileExit, SrcMgr::CharacteristicKind FileKind) |
Add a line note to the line table for the FileID and offset specified by Loc. | |
bool | hasLineTable () const |
Determine if the source manager has a line table. | |
LineTableInfo & | getLineTable () |
Retrieve the stored line table. | |
size_t | getContentCacheSize () const |
Return the total amount of physical memory allocated by the ContentCache allocator. | |
MemoryBufferSizes | getMemoryBufferSizes () const |
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory. | |
size_t | getDataStructureSizes () const |
Return the amount of memory used for various side tables and data structures in the SourceManager. | |
SourceLocation | translateFileLineCol (const FileEntry *SourceFile, unsigned Line, unsigned Col) const |
Get the source location for the given file:line:col triplet. | |
FileID | translateFile (const FileEntry *SourceFile) const |
Get the FileID for the given file. | |
FileID | translateFile (FileEntryRef SourceFile) const |
SourceLocation | translateLineCol (FileID FID, unsigned Line, unsigned Col) const |
Get the source location in FID for the given line:col. | |
SourceLocation | getMacroArgExpandedLocation (SourceLocation Loc) const |
If Loc points inside a function macro argument, the returned location will be the macro location in which the argument was expanded. | |
bool | isBeforeInTranslationUnit (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the translation unit. | |
std::pair< bool, bool > | isInTheSameTranslationUnit (std::pair< FileID, unsigned > &LOffs, std::pair< FileID, unsigned > &ROffs) const |
Determines whether the two decomposed source location is in the same translation unit. | |
FileID | getUniqueLoadedASTFileID (SourceLocation Loc) const |
bool | isInTheSameTranslationUnitImpl (const std::pair< FileID, unsigned > &LOffs, const std::pair< FileID, unsigned > &ROffs) const |
Determines whether the two decomposed source location is in the same TU. | |
bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the "source location
address space". | |
bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation::UIntTy RHS) const |
Determines the order of a source location and a source location offset in the "source location address space". | |
bool | isPointWithin (SourceLocation Location, SourceLocation Start, SourceLocation End) const |
Return true if the Point is within Start and End. | |
fileinfo_iterator | fileinfo_begin () const |
fileinfo_iterator | fileinfo_end () const |
bool | hasFileInfo (const FileEntry *File) const |
void | PrintStats () const |
Print statistics to stderr. | |
void | dump () const |
void | noteSLocAddressSpaceUsage (DiagnosticsEngine &Diag, std::optional< unsigned > MaxNotes=32) const |
unsigned | local_sloc_entry_size () const |
Get the number of local SLocEntries we have. | |
const SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index) const |
Get a local SLocEntry. This is exposed for indexing. | |
SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index) |
Get a local SLocEntry. This is exposed for indexing. | |
unsigned | loaded_sloc_entry_size () const |
Get the number of loaded SLocEntries we have. | |
const SrcMgr::SLocEntry & | getLoadedSLocEntry (unsigned Index, bool *Invalid=nullptr) const |
Get a loaded SLocEntry. This is exposed for indexing. | |
SrcMgr::SLocEntry & | getLoadedSLocEntry (unsigned Index, bool *Invalid=nullptr) |
Get a loaded SLocEntry. This is exposed for indexing. | |
const SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=nullptr) const |
SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=nullptr) |
SourceLocation::UIntTy | getNextLocalOffset () const |
void | setExternalSLocEntrySource (ExternalSLocEntrySource *Source) |
std::pair< int, SourceLocation::UIntTy > | AllocateLoadedSLocEntries (unsigned NumSLocEntries, SourceLocation::UIntTy TotalSize) |
Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external source. | |
bool | isLoadedSourceLocation (SourceLocation Loc) const |
Returns true if Loc came from a PCH/Module. | |
bool | isLocalSourceLocation (SourceLocation Loc) const |
Returns true if Loc did not come from a PCH/Module. | |
bool | isLoadedFileID (FileID FID) const |
Returns true if FID came from a PCH/Module. | |
bool | isLocalFileID (FileID FID) const |
Returns true if FID did not come from a PCH/Module. | |
SourceLocation | getImmediateMacroCallerLoc (SourceLocation Loc) const |
Gets the location of the immediate macro caller, one level up the stack toward the initial macro typed into the source. | |
SourceLocation | getTopMacroCallerLoc (SourceLocation Loc) const |
Friends | |
class | ASTReader |
class | ASTWriter |
This class handles loading and caching of source files into memory.
This object owns the MemoryBuffer objects for all of the loaded files and assigns unique FileID's for each unique #include chain.
The SourceManager can be queried for information about SourceLocation objects, turning them into either spelling or expansion locations. Spelling locations represent where the bytes corresponding to a token came from and expansion locations represent where the location is in the user's view. In the case of a macro expansion, for example, the spelling location indicates where the expanded token came from and the expansion location specifies where it was expanded.
Definition at line 663 of file SourceManager.h.
using clang::SourceManager::fileinfo_iterator = llvm::DenseMap<FileEntryRef, SrcMgr::ContentCache *>::const_iterator |
Definition at line 1719 of file SourceManager.h.
SourceManager::SourceManager | ( | DiagnosticsEngine & | Diag, |
FileManager & | FileMgr, | ||
bool | UserFilesAreVolatile = false |
||
) |
Definition at line 318 of file SourceManager.cpp.
References clearIDTables(), and clang::DiagnosticsEngine::setSourceManager().
|
explicitdelete |
SourceManager::~SourceManager | ( | ) |
Definition at line 325 of file SourceManager.cpp.
References E.
void SourceManager::AddLineNote | ( | SourceLocation | Loc, |
unsigned | LineNo, | ||
int | FilenameID, | ||
bool | IsFileEntry, | ||
bool | IsFileExit, | ||
SrcMgr::CharacteristicKind | FileKind | ||
) |
Add a line note to the line table for the FileID and offset specified by Loc.
AddLineNote - Add a line note to the line table for the FileID and offset specified by Loc.
If FilenameID is -1, it is considered to be unspecified.
Definition at line 280 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getFile(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), Loc, and clang::SrcMgr::FileInfo::setHasLineDirectives().
Referenced by clang::Preprocessor::HandlePragmaSystemHeader(), and ReadOriginalFileName().
std::pair< int, SourceLocation::UIntTy > SourceManager::AllocateLoadedSLocEntries | ( | unsigned | NumSLocEntries, |
SourceLocation::UIntTy | TotalSize | ||
) |
Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external source.
NumSLocEntries will be allocated, which occupy a total of TotalSize space in the global source view. The lowest ID and the base offset of the entries will be returned.
Definition at line 465 of file SourceManager.cpp.
References int.
OptionalFileEntryRef SourceManager::bypassFileContentsOverride | ( | FileEntryRef | File | ) |
Bypass the overridden contents of a file.
This creates a new FileEntry and initializes the content cache for it. Returns std::nullopt if there is no such file in the filesystem.
This should be called before parsing has begun.
Definition at line 728 of file SourceManager.cpp.
References clang::File, clang::FileManager::getBypassFile(), and isFileOverridden().
void SourceManager::clearIDTables | ( | ) |
Definition at line 343 of file SourceManager.cpp.
References createExpansionLoc().
Referenced by clang::CompilerInstance::ExecuteAction(), and SourceManager().
SourceLocation SourceManager::createExpansionLoc | ( | SourceLocation | SpellingLoc, |
SourceLocation | ExpansionLocStart, | ||
SourceLocation | ExpansionLocEnd, | ||
unsigned | Length, | ||
bool | ExpansionIsTokenRange = true , |
||
int | LoadedID = 0 , |
||
SourceLocation::UIntTy | LoadedOffset = 0 |
||
) |
Creates an expansion SLocEntry for a macro use.
Returns its start.
The macro body begins at SpellingLoc
with length Length
. The macro use spans [ExpansionLocStart, ExpansionLocEnd].
Definition at line 646 of file SourceManager.cpp.
References clang::SrcMgr::ExpansionInfo::create().
Referenced by clearIDTables(), clang::Preprocessor::CreateString(), and clang::ASTImporter::Import().
FileID SourceManager::createFileID | ( | const llvm::MemoryBufferRef & | Buffer, |
SrcMgr::CharacteristicKind | FileCharacter = SrcMgr::C_User , |
||
int | LoadedID = 0 , |
||
SourceLocation::UIntTy | LoadedOffset = 0 , |
||
SourceLocation | IncludeLoc = SourceLocation() |
||
) |
Create a new FileID that represents the specified memory buffer.
This does not take ownership of the MemoryBuffer. The memory buffer must outlive the SourceManager.
Definition at line 581 of file SourceManager.cpp.
References createFileID().
FileID SourceManager::createFileID | ( | FileEntryRef | SourceFile, |
SourceLocation | IncludePos, | ||
SrcMgr::CharacteristicKind | FileCharacter, | ||
int | LoadedID = 0 , |
||
SourceLocation::UIntTy | LoadedOffset = 0 |
||
) |
Create a new FileID that represents the specified file being #included from the specified IncludePosition.
Definition at line 546 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::ContentsEntry, clang::SrcMgr::ContentCache::getBufferOrNone(), getFileManager(), clang::FileEntryRef::getName(), clang::FileEntryRef::isNamedPipe(), and clang::SrcMgr::isSystem().
Referenced by clang::tooling::applyAllReplacements(), clang::FrontendAction::BeginSourceFile(), ConvertBackendLocation(), createFileID(), clang::Preprocessor::EnterMainSourceFile(), getOrCreateFileID(), clang::ASTImporter::Import(), clang::CompilerInstance::InitializeSourceManager(), clang::SourceMgrAdapter::mapLocation(), and clang::ModuleMap::parseModuleMapFile().
FileID SourceManager::createFileID | ( | std::unique_ptr< llvm::MemoryBuffer > | Buffer, |
SrcMgr::CharacteristicKind | FileCharacter = SrcMgr::C_User , |
||
int | LoadedID = 0 , |
||
SourceLocation::UIntTy | LoadedOffset = 0 , |
||
SourceLocation | IncludeLoc = SourceLocation() |
||
) |
Create a new FileID that represents the specified memory buffer.
This does no caching of the buffer and takes ownership of the MemoryBuffer, so only pass a MemoryBuffer to this once.
Definition at line 567 of file SourceManager.cpp.
SourceLocation SourceManager::createMacroArgExpansionLoc | ( | SourceLocation | SpellingLoc, |
SourceLocation | ExpansionLoc, | ||
unsigned | Length | ||
) |
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.
Returns the start of the expansion.
The macro argument was written at SpellingLoc
with length Length
. ExpansionLoc
is the parameter name in the (expanded) macro body.
Definition at line 639 of file SourceManager.cpp.
References clang::SrcMgr::ExpansionInfo::createForMacroArg().
Referenced by clang::ASTImporter::Import().
SourceLocation SourceManager::createTokenSplitLoc | ( | SourceLocation | SpellingLoc, |
SourceLocation | TokenStart, | ||
SourceLocation | TokenEnd | ||
) |
Return a new SourceLocation that encodes that the token starting at TokenStart
ends prematurely at TokenEnd
.
Definition at line 656 of file SourceManager.cpp.
References clang::SrcMgr::ExpansionInfo::createForTokenSplit(), and getFileID().
LLVM_DUMP_METHOD void SourceManager::dump | ( | ) | const |
Definition at line 2188 of file SourceManager.cpp.
References int.
|
inline |
Definition at line 1722 of file SourceManager.h.
Referenced by clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata().
|
inline |
Definition at line 1723 of file SourceManager.h.
Referenced by clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata().
Return a StringRef to the source buffer data for the specified FileID.
FID | The file ID whose contents will be returned. |
Invalid | If non-NULL, will be set true if an error occurred. |
Definition at line 752 of file SourceManager.cpp.
References getBufferDataOrNone(), and clang::Invalid.
Referenced by clang::FullSourceLoc::getBufferData(), clang::Rewriter::getEditBuffer(), clang::ASTContext::getRawCommentForDeclNoCacheImpl(), clang::comments::Lexer::getSpelling(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), clang::RawComment::RawComment(), and clang::Rewriter::ReplaceText().
std::optional< StringRef > SourceManager::getBufferDataIfLoaded | ( | FileID | FID | ) | const |
Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if it's not yet loaded.
FID | The file ID whose contents will be returned. |
Definition at line 760 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBufferDataIfLoaded().
std::optional< StringRef > SourceManager::getBufferDataOrNone | ( | FileID | FID | ) | const |
Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if invalid.
FID | The file ID whose contents will be returned. |
Definition at line 766 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBufferOrNone(), and getFileManager().
Referenced by getBufferData().
StringRef SourceManager::getBufferName | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Return the filename or buffer identifier of the buffer the location is in.
Note that this name does not respect #line directives. Use getPresumedLoc for normal clients.
Definition at line 1454 of file SourceManager.cpp.
References clang::Invalid, isInvalid(), and Loc.
Referenced by clang::Preprocessor::CheckMacroName(), and clang::Preprocessor::EnterSourceFile().
|
inline |
Return the buffer for the specified FileID.
If there is an error opening this buffer the first time, this manufactures a temporary buffer and returns it.
Definition at line 1063 of file SourceManager.h.
References getBufferOrNone(), and Loc.
Referenced by clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::html::AddLineNumbers(), and clang::html::EscapeText().
|
inline |
Return the buffer for the specified FileID.
If there is an error opening this buffer the first time, return std::nullopt.
Definition at line 1051 of file SourceManager.h.
References getFileManager(), and Loc.
Referenced by clang::Preprocessor::EnterSourceFile(), getBufferOrFake(), getColumnNumber(), and clang::ModuleMap::parseModuleMapFile().
const char * SourceManager::getCharacterData | ( | SourceLocation | SL, |
bool * | Invalid = nullptr |
||
) | const |
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.
getCharacterData - Return a pointer to the start of the specified location in the appropriate MemoryBuffer.
Invalid | If non-NULL, will be set true if an error occurs. |
Definition at line 1109 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBufferOrNone(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedSpellingLoc(), clang::SrcMgr::SLocEntry::getFile(), getFileManager(), getSLocEntry(), clang::Invalid, and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Preprocessor::DumpToken(), fixItNullability(), clang::FullSourceLoc::getCharacterData(), clang::Rewriter::getRewrittenText(), clang::Lexer::getSpelling(), and isSameWidthConstantConversion().
unsigned SourceManager::getColumnNumber | ( | FileID | FID, |
unsigned | FilePos, | ||
bool * | Invalid = nullptr |
||
) | const |
Return the column # for the specified file position.
getColumnNumber - Return the column # for the specified file position.
This is significantly cheaper to compute than the line number. This returns zero if the column number isn't known. This may only be called on a file sloc, so you must choose a spelling or expansion location before calling this method.
this is significantly cheaper to compute than the line number.
Definition at line 1135 of file SourceManager.cpp.
References clang::SrcMgr::LineOffsetMapping::begin(), getBufferOrNone(), clang::Invalid, clang::SrcMgr::LineOffsetMapping::size(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by clang::FullSourceLoc::getColumnNumber(), getExpansionColumnNumber(), and getSpellingColumnNumber().
|
inline |
Form a SourceLocation from a FileID and Offset pair.
Definition at line 1258 of file SourceManager.h.
Referenced by clang::ASTImporter::Import().
|
inline |
Return the total amount of physical memory allocated by the ContentCache allocator.
Definition at line 1607 of file SourceManager.h.
size_t SourceManager::getDataStructureSizes | ( | ) | const |
Return the amount of memory used for various side tables and data structures in the SourceManager.
Definition at line 2354 of file SourceManager.cpp.
|
inline |
Decompose the specified location into a raw FileID + Offset pair.
If the location is an expansion record, walk through it until we find the final location expanded.
Definition at line 1285 of file SourceManager.h.
References E, getFileID(), and Loc.
Referenced by clang::FullSourceLoc::getDecomposedExpansionLoc(), and getExpansionColumnNumber().
Returns the "included/expanded in" decomposed location of the given FileID.
Definition at line 1907 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), clang::Invalid, clang::SrcMgr::SLocEntry::isExpansion(), clang::FileID::isInvalid(), and clang::SourceLocation::isValid().
|
inline |
Decompose the specified location into a raw FileID + Offset pair.
The first element is the FileID, the second is the offset from the start of the buffer of the location.
Definition at line 1272 of file SourceManager.h.
References getFileID(), and Loc.
Referenced by clang::RawCommentList::addComment(), clang::ASTContext::attachCommentsToJustParsedDecls(), clang::RawCommentList::getCommentEndOffset(), clang::FullSourceLoc::getDecomposedLoc(), getFileOffset(), getImmediateSpellingLoc(), getRangeSize(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::ASTContext::getRawCommentForDeclNoCacheImpl(), clang::comments::Lexer::getSpelling(), clang::ASTImporter::Import(), isAtStartOfImmediateMacroExpansion(), loadModuleMapForModuleBuild(), clang::Sema::notePreviousDefinition(), clang::ModuleMap::parseModuleMapFile(), clang::RawComment::RawComment(), and clang::ASTReader::ReadComments().
|
inline |
Decompose the specified location into a raw FileID + Offset pair.
If the location is an expansion record, walk through it until we find its spelling record.
Definition at line 1303 of file SourceManager.h.
References E, getFileID(), and Loc.
Referenced by getCharacterData(), and getSpellingColumnNumber().
|
inline |
Definition at line 852 of file SourceManager.h.
Referenced by clang::api_notes::APINotesManager::getCurrentModuleAPINotes(), clang::ASTContext::getDiagnostics(), and clang::Rewriter::overwriteChangedFiles().
unsigned SourceManager::getExpansionColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1196 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedExpansionLoc(), clang::Invalid, isInvalid(), and Loc.
Referenced by clang::FullSourceLoc::getExpansionColumnNumber().
unsigned SourceManager::getExpansionLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1403 of file SourceManager.cpp.
References clang::Invalid, isInvalid(), and Loc.
Referenced by clang::FullSourceLoc::getExpansionLineNumber(), clang::Sema::InstantiateClass(), and clang::Sema::InstantiateFunctionDefinition().
|
inline |
Given a SourceLocation object Loc
, return the expansion location referenced by the ID.
Definition at line 1194 of file SourceManager.h.
References Loc.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnUsingDirective(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER_REGEX(), clang::api_notes::APINotesManager::findAPINotes(), getDeclLocsForCommentSearch(), clang::FullSourceLoc::getExpansionLoc(), getIssueHash(), clang::Preprocessor::getModuleForLocation(), getNullabilityCompletenessCheckFileID(), clang::diff::SyntaxTree::getSourceRangeOffsets(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), handleObjCOwnershipTypeAttr(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::Sema::InstantiateClass(), clang::Sema::InstantiateFunctionDefinition(), and clang::CodeGen::CGDebugInfo::setLocation().
|
inline |
Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file.
Definition at line 1230 of file SourceManager.h.
References clang::CharSourceRange::getEnd(), getExpansionRange(), Range, and clang::CharSourceRange::setTokenRange().
CharSourceRange SourceManager::getExpansionRange | ( | SourceLocation | Loc | ) | const |
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file.
getExpansionRange - Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file.
Definition at line 993 of file SourceManager.cpp.
References clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), getImmediateExpansionRange(), clang::SourceLocation::isFileID(), clang::CharSourceRange::isTokenRange(), Loc, clang::CharSourceRange::setBegin(), clang::CharSourceRange::setEnd(), and clang::CharSourceRange::setTokenRange().
Referenced by clang::SourceLocExpr::EvaluateInContext(), and getExpansionRange().
|
inline |
Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file.
Definition at line 1221 of file SourceManager.h.
References Begin, clang::CharSourceRange::getBegin(), getExpansionRange(), and Range.
SrcMgr::CharacteristicKind SourceManager::getFileCharacteristic | ( | SourceLocation | Loc | ) | const |
Return the file characteristic of the specified source location, indicating whether this is a normal file, a system header, or an "implicit extern C" system header.
getFileCharacteristic - return the file characteristic of the specified source location, indicating whether this is a normal file, a system header, or an "implicit extern C" system header.
This state can be modified with flags on GNU linemarker directives like:
which changes all source locations in the current file after that to be considered to be from a system header.
This state can be modified with flags on GNU linemarker directives like:
which changes all source locations in the current file after that to be considered to be from a system header.
Definition at line 1425 of file SourceManager.cpp.
References clang::SrcMgr::C_User, clang::LineEntry::FileKind, clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getFileCharacteristic(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SourceLocation::isValid(), and Loc.
Referenced by compileModule(), clang::Preprocessor::HandleEndOfFile(), isInExternCSystemHeader(), and isInSystemHeader().
Returns the FileEntry record for the provided FileID.
Definition at line 1070 of file SourceManager.h.
References getFileEntryRefForID().
Referenced by clang::ModuleMap::createModuleForImplementationUnit(), clang::Sema::diagnoseMissingImport(), clang::Preprocessor::EnterSourceFile(), clang::FullSourceLoc::getFileEntry(), clang::Preprocessor::HandleEndOfFile(), isMainFile(), clang::Preprocessor::isPCHThroughHeader(), clang::Sema::notePreviousDefinition(), and clang::Preprocessor::SetCodeCompletionPoint().
|
inline |
Returns the FileEntry record for the provided SLocEntry.
Definition at line 1091 of file SourceManager.h.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::ContentCache::OrigEntry.
|
inline |
Returns the FileEntryRef for the provided FileID.
Definition at line 1077 of file SourceManager.h.
Referenced by clang::arcmt::MigrationProcess::applyTransform(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER_REGEX(), clang::PrecompiledPreamble::Build(), compileModule(), clang::ModuleMap::createModuleForInterfaceUnit(), clang::syntax::TokenBuffer::dumpForTests(), clang::tooling::dependencies::ModuleDepCollectorPP::EndOfMainFile(), clang::Preprocessor::EnterMainSourceFile(), clang::Preprocessor::EnterSourceFile(), clang::api_notes::APINotesManager::findAPINotes(), clang::ModuleMap::getContainingModuleMapFile(), clang::PreprocessorLexer::getFileEntry(), getFileEntryForID(), clang::FullSourceLoc::getFileEntryRef(), getFilename(), clang::ASTUnit::getMainFileName(), clang::Preprocessor::getModuleForLocation(), clang::ModuleMap::getModuleMapFileForUniquing(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::Preprocessor::LookupFile(), clang::Sema::notePreviousDefinition(), clang::Rewriter::overwriteChangedFiles(), prepareToBuildModule(), and PrintUnexpected().
|
inline |
Return the FileID for a SourceLocation.
This is a very hot method that is used for all SourceManager queries that start with a SourceLocation object. It is responsible for finding the entry in SLocEntryTable which contains the specified location.
Definition at line 1145 of file SourceManager.h.
References getFileID().
Referenced by clang::Sema::ActOnAnnotModuleEnd(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER_REGEX(), checkConfigMacro(), compileModule(), createTokenSplitLoc(), clang::Sema::diagnoseMissingImport(), DiagnoseNullConversion(), EvaluateDefined(), clang::api_notes::APINotesManager::findAPINotes(), clang::tooling::findSelectedASTNodes(), clang::FullSourceLoc::getBufferData(), clang::ModuleMap::getContainingModuleMapFileID(), getDecomposedExpansionLoc(), getDecomposedLoc(), getDecomposedSpellingLoc(), clang::FullSourceLoc::getFileID(), getFileID(), getFilename(), getImmediateExpansionRange(), clang::Preprocessor::getModuleForLocation(), getModuleImportLoc(), getNullabilityCompletenessCheckFileID(), clang::ScratchBuffer::getToken(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::Preprocessor::HandleDirective(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::ASTImporter::Import(), isAtEndOfImmediateMacroExpansion(), isMacroArgExpansion(), isMacroBodyExpansion(), isWrittenInMainFile(), isWrittenInSameFile(), PrintUnexpected(), shouldIgnoreMacro(), clang::syntax::TokenBuffer::spelledForExpanded(), and clang::syntax::TokenBuffer::spelledTokenContaining().
The size of the SLocEntry that FID
represents.
Definition at line 1570 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getOffset(), and clang::Invalid.
Referenced by getLocForEndOfFile(), and clang::ASTImporter::Import().
|
inline |
Given Loc
, if it is a macro location return the expansion location or the spelling location, depending on if it comes from a macro argument or not.
Definition at line 1204 of file SourceManager.h.
References Loc.
Referenced by clang::NoSanitizeList::containsLocation(), clang::FullSourceLoc::getFileLoc(), clang::ProfileList::isLocationExcluded(), and clang::XRayFunctionFilter::shouldImbueLocation().
|
inline |
Definition at line 854 of file SourceManager.h.
Referenced by clang::PrecompiledPreamble::Build(), clang::ModuleMap::canonicalizeModuleMapPath(), clang::SemaCodeCompletion::CodeCompleteIncludedFile(), createFileID(), clang::api_notes::APINotesManager::findAPINotes(), clang::BackendConsumer::getBestLocationFromDebugLoc(), getBufferDataOrNone(), getBufferOrNone(), getCharacterData(), clang::api_notes::APINotesManager::getCurrentModuleAPINotes(), getMemoryBufferForFileOrNone(), clang::ASTImporter::Import(), clang::ModuleMap::isHeaderUnavailableInModule(), clang::Rewriter::overwriteChangedFiles(), and clang::ASTWriter::PreparePathForOutput().
StringRef SourceManager::getFilename | ( | SourceLocation | SpellingLoc | ) | const |
Return the filename of the file containing a SourceLocation.
Definition at line 970 of file SourceManager.cpp.
References getFileEntryRefForID(), and getFileID().
Referenced by clang::NoSanitizeList::containsLocation(), clang::tooling::DiagnosticMessage::DiagnosticMessage(), clang::tooling::FileByteRange::FileByteRange(), clang::Sema::InstantiateClass(), clang::Sema::InstantiateFunctionDefinition(), clang::ProfileList::isLocationExcluded(), clang::Sema::notePreviousDefinition(), PrintExpected(), and clang::XRayFunctionFilter::shouldImbueLocation().
|
inline |
Returns the offset from the start of the file that the specified SourceLocation represents.
This is not very meaningful for a macro ID.
Definition at line 1323 of file SourceManager.h.
References getDecomposedLoc().
Referenced by clang::tooling::DiagnosticMessage::DiagnosticMessage(), clang::tooling::FileByteRange::FileByteRange(), clang::FullSourceLoc::getFileOffset(), and clang::diff::SyntaxTree::getSourceRangeOffsets().
CharSourceRange SourceManager::getImmediateExpansionRange | ( | SourceLocation | Loc | ) | const |
Return the start/end of the expansion information for an expansion location.
getImmediateExpansionRange - Loc is required to be an expansion location.
Loc
is required to be an expansion location.Return the start/end of the expansion information.
Definition at line 979 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocRange(), getFileID(), getSLocEntry(), clang::SourceLocation::isMacroID(), and Loc.
Referenced by checkAllAtProps(), CheckMoveOnConstruction(), clang::Sema::DiagnoseAbsenceOfOverrideControl(), DiagnoseNullConversion(), getExpansionRange(), GetFullTypeForDeclarator(), getImmediateMacroCallerLoc(), and handleObjCOwnershipTypeAttr().
|
inline |
Gets the location of the immediate macro caller, one level up the stack toward the initial macro typed into the source.
Definition at line 1824 of file SourceManager.h.
References clang::CharSourceRange::getBegin(), getImmediateExpansionRange(), getImmediateSpellingLoc(), isMacroArgExpansion(), and Loc.
Referenced by clang::FullSourceLoc::getImmediateMacroCallerLoc(), and isInSystemMacro().
SourceLocation SourceManager::getImmediateSpellingLoc | ( | SourceLocation | Loc | ) | const |
Given a SourceLocation object, return the spelling location referenced by the ID.
getImmediateSpellingLoc - Given a SourceLocation object, return the spelling location referenced by the ID.
This is the first level down towards the place where the characters that make up the lexed token can be found. This should not generally be used by clients.
Definition at line 962 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), clang::SourceLocation::isFileID(), and Loc.
Referenced by getImmediateMacroCallerLoc(), and getTopMacroCallerLoc().
|
inline |
Returns the include location if FID
is a #include'd file otherwise it returns an invalid location.
Definition at line 1171 of file SourceManager.h.
Referenced by clang::Sema::ActOnAnnotModuleEnd(), compileModule(), clang::Preprocessor::HandleEndOfFile(), and clang::Sema::notePreviousDefinition().
unsigned SourceManager::getLineNumber | ( | FileID | FID, |
unsigned | FilePos, | ||
bool * | Invalid = nullptr |
||
) | const |
Given a SourceLocation, return the spelling line number for the position indicated.
getLineNumber - Given a SourceLocation, return the spelling line number for the position indicated.
This requires building and caching a table of line offsets for the MemoryBuffer, so this is not cheap: use only when about to emit a diagnostic.
Definition at line 1300 of file SourceManager.cpp.
References clang::SrcMgr::LineOffsetMapping::begin(), Diag(), clang::SrcMgr::LineOffsetMapping::end(), clang::SrcMgr::LineOffsetMapping::get(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by clang::RawCommentList::getCommentBeginLine(), clang::FullSourceLoc::getLineNumber(), clang::ASTContext::getRawCommentForDeclNoCacheImpl(), clang::Rewriter::IncreaseIndentation(), and clang::Rewriter::InsertText().
LineTableInfo & SourceManager::getLineTable | ( | ) |
Retrieve the stored line table.
Definition at line 308 of file SourceManager.cpp.
unsigned SourceManager::getLineTableFilenameID | ( | StringRef | Str | ) |
Return the uniqued ID for the specified filename.
getLineTableFilenameID - Return the uniqued ID for the specified filename.
Definition at line 273 of file SourceManager.cpp.
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
|
inline |
Get a loaded SLocEntry. This is exposed for indexing.
Definition at line 1762 of file SourceManager.h.
References clang::Invalid.
|
inline |
Get a loaded SLocEntry. This is exposed for indexing.
Definition at line 1755 of file SourceManager.h.
References getLoadedSLocEntry(), and clang::Invalid.
Referenced by getLoadedSLocEntry().
|
inline |
Get a local SLocEntry. This is exposed for indexing.
Definition at line 1746 of file SourceManager.h.
|
inline |
Get a local SLocEntry. This is exposed for indexing.
Definition at line 1741 of file SourceManager.h.
References getLocalSLocEntry().
Referenced by getLocalSLocEntry().
|
inline |
Return the source location corresponding to the last byte of the specified file.
Definition at line 1162 of file SourceManager.h.
References getFileIDSize().
Referenced by clang::ASTUnit::getEndOfPreambleFileID().
|
inline |
Return the source location corresponding to the first byte of the specified file.
Definition at line 1154 of file SourceManager.h.
Referenced by clang::Sema::ActOnModuleDecl(), clang::html::AddHeaderFooterInternalBuiltinCSS(), ConvertBackendLocation(), clang::Preprocessor::EnterSourceFile(), clang::ASTUnit::getStartOfMainFileID(), clang::Preprocessor::HandleEndOfFile(), clang::ASTImporter::Import(), clang::SourceMgrAdapter::mapLocation(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), and clang::ModuleMap::parseModuleMapFile().
SourceLocation SourceManager::getMacroArgExpandedLocation | ( | SourceLocation | Loc | ) | const |
If Loc
points inside a function macro argument, the returned location will be the macro location in which the argument was expanded.
If.
If a macro argument is used multiple times, the expanded location will be at the first expansion of the argument. e.g. MY_MACRO(foo); ^ Passing a file location pointing at 'foo', will yield a macro location where 'foo' was expanded into.
Definition at line 1873 of file SourceManager.cpp.
References clang::SourceLocation::getLocWithOffset(), clang::SourceLocation::isFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), and Loc.
|
inline |
Returns the FileID of the main source file.
Definition at line 888 of file SourceManager.h.
Referenced by clang::Sema::ActOnModuleDecl(), clang::PrecompiledPreamble::Build(), clang::ModuleMap::createModuleForImplementationUnit(), clang::ModuleMap::createModuleForInterfaceUnit(), clang::tooling::dependencies::ModuleDepCollectorPP::EndOfMainFile(), clang::Preprocessor::EnterMainSourceFile(), clang::ASTUnit::getMainFileName(), clang::ASTUnit::getStartOfMainFileID(), clang::ASTImporter::Import(), clang::CompilerInstance::InitializeSourceManager(), clang::ASTUnit::isInMainFileID(), isWrittenInMainFile(), clang::Preprocessor::LookupFile(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), prepareToBuildModule(), ReadOriginalFileName(), and clang::Preprocessor::SetCodeCompletionPoint().
|
inline |
Retrieve the memory buffer associated with the given file.
Returns a fake buffer if there isn't a real one.
Definition at line 979 of file SourceManager.h.
References clang::File, and getMemoryBufferForFileOrNone().
Referenced by clang::PrecompiledPreamble::Build().
std::optional< llvm::MemoryBufferRef > SourceManager::getMemoryBufferForFileOrNone | ( | FileEntryRef | File | ) |
Retrieve the memory buffer associated with the given file.
Returns std::nullopt if the buffer is not valid.
Definition at line 697 of file SourceManager.cpp.
References clang::File, clang::SrcMgr::ContentCache::getBufferOrNone(), and getFileManager().
Referenced by getMemoryBufferForFileOrFake(), and clang::Preprocessor::SetCodeCompletionPoint().
SourceManager::MemoryBufferSizes SourceManager::getMemoryBufferSizes | ( | ) | const |
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory.
Definition at line 2336 of file SourceManager.cpp.
|
inline |
Retrieve the module build stack.
Definition at line 868 of file SourceManager.h.
Referenced by prepareToBuildModule().
|
inline |
Definition at line 1181 of file SourceManager.h.
References getFileID(), clang::ExternalSLocEntrySource::getModuleImportLoc(), and Loc.
Referenced by clang::FullSourceLoc::getModuleImportLoc().
|
inline |
Definition at line 1783 of file SourceManager.h.
std::optional< StringRef > SourceManager::getNonBuiltinFilenameForID | ( | FileID | FID | ) | const |
Returns the filename for the provided FileID, unless it's a built-in buffer that's not represented by a filename.
Returns std::nullopt for non-files and built-in files.
Definition at line 745 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::OrigEntry.
Get the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 1118 of file SourceManager.h.
FileID SourceManager::getOrCreateFileID | ( | FileEntryRef | SourceFile, |
SrcMgr::CharacteristicKind | FileCharacter | ||
) |
Get the FileID for SourceFile
if it exists.
Otherwise, create a new FileID for the SourceFile
.
Definition at line 593 of file SourceManager.cpp.
References createFileID(), and translateFile().
Referenced by clang::SourceMgrAdapter::mapLocation(), and prepareToBuildModule().
|
inline |
Get the file ID for the precompiled preamble if there is one.
Definition at line 907 of file SourceManager.h.
Referenced by clang::ASTUnit::getEndOfPreambleFileID(), clang::ASTUnit::isInPreambleFileID(), clang::ASTUnit::mapLocationFromPreamble(), and clang::ASTUnit::mapLocationToPreamble().
unsigned SourceManager::getPresumedColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1203 of file SourceManager.cpp.
References clang::PresumedLoc::getColumn(), getPresumedLoc(), clang::Invalid, isInvalid(), and Loc.
Referenced by clang::Sema::DiagnoseEmptyLoopBody().
unsigned SourceManager::getPresumedLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1409 of file SourceManager.cpp.
References clang::PresumedLoc::getLine(), clang::Invalid, isInvalid(), and Loc.
Referenced by clang::comments::Sema::actOnHTMLEndTag(), CheckLists(), clang::comments::Parser::parseHTMLStartTag(), PrintExpected(), PrintUnexpected(), and ShouldDiagnoseEmptyStmtBody().
PresumedLoc SourceManager::getPresumedLoc | ( | SourceLocation | Loc, |
bool | UseLineDirectives = true |
||
) | const |
Returns the "presumed" location of a SourceLocation specifies.
getPresumedLoc - This method returns the "presumed" location of a SourceLocation specifies.
A "presumed location" can be modified by #line or GNU line marker directives. This provides a view on the data that a user should see in diagnostics, for example.
Note that a presumed location is always given as the expansion point of an expansion location, not at the spelling location.
Loc
is invalid or the file containing Loc
has changed on disk), returns an invalid presumed location.A "presumed location" can be modified by #line or GNU line marker directives. This provides a view on the data that a user should see in diagnostics, for example.
Note that a presumed location is always given as the expansion point of an expansion location, not at the spelling location.
Definition at line 1471 of file SourceManager.cpp.
References clang::C, Diag(), Filename, clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), clang::SourceLocation::isInvalid(), and Loc.
Referenced by clang::CodeGen::CGDebugInfo::AddStringLiteralDebugInfo(), clang::DoPrintPreprocessedInput(), clang::TextNodeDumper::dumpLocation(), emitMappingInformation(), clang::CodeGen::CGOpenMPRuntime::emitUpdateLocation(), clang::SourceLocExpr::EvaluateInContext(), clang::RawComment::getFormattedLines(), clang::AnalysisDeclContext::getFunctionName(), getIdentStringFromSourceLocation(), getPresumedColumnNumber(), clang::FullSourceLoc::getPresumedLoc(), clang::Preprocessor::HandlePragmaSystemHeader(), isWrittenInBuiltinFile(), isWrittenInCommandLineFile(), and isWrittenInScratchSpace().
|
inline |
Definition at line 1775 of file SourceManager.h.
References clang::Invalid.
|
inline |
Definition at line 1770 of file SourceManager.h.
References getSLocEntry(), and clang::Invalid.
Referenced by EvaluateDefined(), getCharacterData(), getImmediateExpansionRange(), getImmediateSpellingLoc(), getNullabilityCompletenessCheckFileID(), getSLocEntry(), clang::ScratchBuffer::getToken(), clang::ASTImporter::Import(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), isAtEndOfImmediateMacroExpansion(), isAtStartOfImmediateMacroExpansion(), isInFileID(), isMacroArgExpansion(), and isMacroBodyExpansion().
unsigned SourceManager::getSpellingColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1189 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedSpellingLoc(), clang::Invalid, isInvalid(), and Loc.
Referenced by clang::format::ContinuationIndenter::addTokenToState(), clang::RawComment::getFormattedLines(), and clang::FullSourceLoc::getSpellingColumnNumber().
unsigned SourceManager::getSpellingLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1397 of file SourceManager.cpp.
References clang::Invalid, isInvalid(), and Loc.
Referenced by clang::format::UnwrappedLineFormatter::format(), clang::FullSourceLoc::getSpellingLineNumber(), and ShouldDiagnoseEmptyStmtBody().
|
inline |
Given a SourceLocation object, return the spelling location referenced by the ID.
This is the place where the characters that make up the lexed token can be found.
Definition at line 1242 of file SourceManager.h.
References Loc.
Referenced by clang::Sema::DiagnoseAbsenceOfOverrideControl(), clang::TextNodeDumper::dumpLocation(), getDeclLocsForCommentSearch(), getRangeSize(), clang::FullSourceLoc::getSpellingLoc(), isInSystemMacro(), clang::diff::isNodeExcluded(), clang::Sema::notePreviousDefinition(), and shouldIgnoreDueToReservedName().
SourceLocation SourceManager::getTopMacroCallerLoc | ( | SourceLocation | Loc | ) | const |
Definition at line 985 of file SourceManager.cpp.
References getImmediateSpellingLoc(), isMacroArgExpansion(), and Loc.
Referenced by DiagnoseNullConversion().
FileID SourceManager::getUniqueLoadedASTFileID | ( | SourceLocation | Loc | ) | const |
Loc | a source location in a loaded AST (of a PCH/Module file). |
Loc
is at. Definition at line 1935 of file SourceManager.cpp.
References Loc.
Definition at line 1724 of file SourceManager.h.
References clang::File.
|
inline |
Determine if the source manager has a line table.
Definition at line 1596 of file SourceManager.h.
void SourceManager::initializeForReplay | ( | const SourceManager & | Old | ) |
Initialize this source manager suitably to replay the compilation described by Old
.
Requires that Old
outlive *this
.
Definition at line 369 of file SourceManager.cpp.
References clang::Cache, clang::FileID::isInvalid(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::FrontendAction::BeginSourceFile().
bool SourceManager::isAtEndOfImmediateMacroExpansion | ( | SourceLocation | Loc, |
SourceLocation * | MacroEnd = nullptr |
||
) | const |
Returns true if the given MacroID location points at the character end of the immediate macro expansion.
MacroEnd | If non-null and function returns true, it is set to the character end location of the immediate macro expansion. |
Definition at line 1067 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocEnd(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getFileID(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isExpansion(), isInFileID(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), clang::SourceLocation::isValid(), and Loc.
bool SourceManager::isAtStartOfImmediateMacroExpansion | ( | SourceLocation | Loc, |
SourceLocation * | MacroBegin = nullptr |
||
) | const |
Returns true if the given MacroID location points at the beginning of the immediate macro expansion.
MacroBegin | If non-null and function returns true, it is set to the begin location of the immediate macro expansion. |
Definition at line 1032 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isExpansion(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), clang::SourceLocation::isValid(), and Loc.
Referenced by CheckMoveOnConstruction().
|
inline |
Determines the order of 2 source locations in the "source location address space".
Definition at line 1691 of file SourceManager.h.
References isBeforeInSLocAddrSpace().
Referenced by isBeforeInSLocAddrSpace().
|
inline |
Determines the order of a source location and a source location offset in the "source location address space".
Note that we always consider source locations loaded from
Definition at line 1699 of file SourceManager.h.
bool SourceManager::isBeforeInTranslationUnit | ( | SourceLocation | LHS, |
SourceLocation | RHS | ||
) | const |
Determines the order of 2 source locations in the translation unit.
Definition at line 2023 of file SourceManager.cpp.
References clang::SourceLocation::isValid().
Referenced by clang::PreprocessingRecord::addPreprocessedEntity(), clang::format::AffectedRangeManager::affectsCharSourceRange(), diagnoseRepeatedUseOfWeak(), clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(), clang::DeclSpec::Finish(), clang::Preprocessor::getLastMacroWithSpelling(), clang::syntax::TreeBuilder::getRange(), clang::FullSourceLoc::isBeforeInTranslationUnitThan(), isPointWithin(), clang::Preprocessor::isSafeBufferOptOut(), clang::format::WhitespaceManager::Change::IsBeforeInFile::operator()(), clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(), and clang::LexicallyOrderedRecursiveASTVisitor< Derived >::TraverseDeclContextHelper().
Returns true if the file contents have been overridden.
Definition at line 1016 of file SourceManager.h.
References clang::File.
Referenced by bypassFileContentsOverride().
|
inline |
Returns if a SourceLocation is in an "extern C" system header.
Definition at line 1540 of file SourceManager.h.
References clang::SrcMgr::C_ExternCSystem, getFileCharacteristic(), and Loc.
|
inline |
Given a specific FileID, returns true if Loc
is inside that FileID chunk and sets relative offset (offset of Loc
from beginning of FileID) to relativeOffset
.
Definition at line 1568 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and Loc.
Referenced by isAtEndOfImmediateMacroExpansion(), clang::ASTUnit::isInMainFileID(), clang::ASTUnit::isInPreambleFileID(), clang::ASTUnit::mapLocationFromPreamble(), and clang::ASTUnit::mapLocationToPreamble().
bool SourceManager::isInMainFile | ( | SourceLocation | Loc | ) | const |
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
This computes the "presumed" location for a SourceLocation, then checks whether it came from a file other than the main file. This is different from isWrittenInMainFile() because it takes line marker directives into account.
Definition at line 1547 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SourceLocation::isInvalid(), and Loc.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnUsingDirective(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER(), CheckUnreachable(), diagnoseUseOfInternalDeclInInlineFunction(), clang::Preprocessor::getModuleForLocation(), clang::Preprocessor::HandlePragmaHdrstop(), isMainFileLoc(), and clang::diff::isNodeExcluded().
|
inline |
Return true if both LHS
and RHS
are in the local source location address space or the loaded one.
If it's true and RelativeOffset
is non-null, it will be set to the offset of RHS
relative to LHS
.
Definition at line 1393 of file SourceManager.h.
|
inline |
Returns true if Loc
is inside the [Start
, +Length
) chunk of the source location address space.
If it's true and RelativeOffset
is non-null, it will be set to the relative offset of Loc
inside the chunk.
Definition at line 1369 of file SourceManager.h.
References Loc.
|
inline |
Returns if a SourceLocation is in a system header.
Definition at line 1533 of file SourceManager.h.
References getFileCharacteristic(), and Loc.
Referenced by clang::SemaObjC::ActOnAtEnd(), clang::Sema::ActOnCXXTryBlock(), clang::Sema::ActOnLabelStmt(), clang::ASTContext::addComment(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER(), clang::Sema::BuildCXXThrow(), CheckConstexprFunctionBody(), clang::Sema::CheckEquivalentExceptionSpec(), clang::SemaObjC::checkInitMethod(), clang::Sema::checkLiteralOperatorId(), clang::Preprocessor::CheckMacroName(), CheckSimplerImplicitMovesMSVCWorkaround(), DiagnoseBadConversion(), DiagReservedModuleName(), DoEmitAvailabilityWarning(), EmitDiagForCXXThrowInNonThrowingFunc(), clang::Preprocessor::getHeaderToIncludeForDiagnostics(), clang::ento::MemRegionManager::getVarRegion(), handleInitPriorityAttr(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), isForbiddenTypeAllowed(), clang::FullSourceLoc::isInSystemHeader(), clang::extractapi::impl::ExtractAPIVisitorBase< Derived >::isInSystemHeader(), isInSystemMacro(), clang::Sema::isLibstdcxxEagerExceptionSpecHack(), isLibstdcxxPointerReturnFalseHack(), isStandardNewDelete(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::Sema::makeUnavailableInSystemHeader(), clang::SemaCUDA::maybeAddHostDeviceAttrs(), clang::Sema::MergeTypedefNameDecl(), clang::SemaObjC::ParseObjCSelectorExpression(), and shouldIgnoreDueToReservedName().
|
inline |
Returns whether Loc
is expanded from a macro in a system header.
Definition at line 1545 of file SourceManager.h.
References getImmediateMacroCallerLoc(), getSpellingLoc(), isInSystemHeader(), isInSystemMacro(), clang::SourceLocation::isMacroID(), and isWrittenInScratchSpace().
Referenced by AnalyzeBitFieldAssignment(), AnalyzeCompoundAssignment(), clang::Sema::CheckImplicitConversion(), diagnoseSubtractionOnNullPointer(), clang::Sema::DiagnoseUnusedExprResult(), clang::Sema::diagnoseZeroToNullptrConversion(), handleStandardNoReturnAttr(), and isInSystemMacro().
std::pair< bool, bool > SourceManager::isInTheSameTranslationUnit | ( | std::pair< FileID, unsigned > & | LOffs, |
std::pair< FileID, unsigned > & | ROffs | ||
) | const |
Determines whether the two decomposed source location is in the same translation unit.
As a byproduct, it also calculates the order of the source locations in case they are in the same TU.
LOffs
is before ROffs
. Definition at line 2045 of file SourceManager.cpp.
References clang::InBeforeInTUCacheEntry::getCachedResult(), clang::InBeforeInTUCacheEntry::isCacheValid(), MoveUpTranslationUnitIncludeHierarchy(), and clang::InBeforeInTUCacheEntry::setCommonLoc().
bool SourceManager::isInTheSameTranslationUnitImpl | ( | const std::pair< FileID, unsigned > & | LOffs, |
const std::pair< FileID, unsigned > & | ROffs | ||
) | const |
Determines whether the two decomposed source location is in the same TU.
Definition at line 1953 of file SourceManager.cpp.
Returns true if FID
came from a PCH/Module.
Definition at line 1812 of file SourceManager.h.
Referenced by clang::Preprocessor::EnterMainSourceFile(), clang::ASTUnit::findFileRegionDecls(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), and isLocalFileID().
|
inline |
Returns true if Loc
came from a PCH/Module.
Definition at line 1802 of file SourceManager.h.
References Loc.
Referenced by clang::ASTWriter::getRawSourceLocationEncoding(), and clang::ASTReader::ReadSourceLocation().
Returns true if FID
did not come from a PCH/Module.
Definition at line 1818 of file SourceManager.h.
References isLoadedFileID().
|
inline |
Returns true if Loc
did not come from a PCH/Module.
Definition at line 1807 of file SourceManager.h.
References Loc.
Referenced by clang::Preprocessor::isSafeBufferOptOut().
bool SourceManager::isMacroArgExpansion | ( | SourceLocation | Loc, |
SourceLocation * | StartLoc = nullptr |
||
) | const |
Tests whether the given source location represents a macro argument's expansion into the function-like macro definition.
StartLoc | If non-null and function returns true, it is set to the start location of the macro argument expansion. |
Such source locations only appear inside of the expansion locations representing where a particular function-like macro was expanded.
Definition at line 1011 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and Loc.
Referenced by clang::edit::EditedSource::canInsertInOffset(), getImmediateMacroCallerLoc(), getTopMacroCallerLoc(), clang::FullSourceLoc::isMacroArgExpansion(), and clang::syntax::TokenBuffer::spelledForExpanded().
bool SourceManager::isMacroBodyExpansion | ( | SourceLocation | Loc | ) | const |
Tests whether the given source location represents the expansion of a macro body.
This is equivalent to testing whether the location is part of a macro expansion but not the expansion of an argument to a function-like macro.
Definition at line 1024 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroBodyExpansion(), clang::SourceLocation::isMacroID(), and Loc.
Referenced by DiagnoseUnusedComparison(), and clang::Sema::DiagnoseUnusedExprResult().
Returns true when the given FileEntry corresponds to the main file.
The main file should be set prior to calling this function.
Definition at line 362 of file SourceManager.cpp.
References getFileEntryForID(), clang::FileEntry::getUID(), and clang::FileID::isValid().
|
inline |
Return true if the Point is within Start and End.
Definition at line 1711 of file SourceManager.h.
References isBeforeInTranslationUnit().
|
inline |
Returns whether Loc
is located in a <built-in> file.
Definition at line 1506 of file SourceManager.h.
References Filename, clang::PresumedLoc::getFilename(), getPresumedLoc(), clang::PresumedLoc::isInvalid(), and Loc.
Referenced by clang::ASTImporter::Import(), and isLanguageDefinedBuiltin().
|
inline |
Returns whether Loc
is located in a <command line> file.
Definition at line 1515 of file SourceManager.h.
References Filename, clang::PresumedLoc::getFilename(), getPresumedLoc(), clang::PresumedLoc::isInvalid(), and Loc.
|
inline |
Returns true if the spelling location for the given location is in the main file buffer.
This check ignores line marker directives.
Definition at line 1501 of file SourceManager.h.
References getFileID(), getMainFileID(), and Loc.
Referenced by clang::Sema::BuildModuleInclude().
|
inline |
Returns true if the spelling locations for both SourceLocations are part of the same file buffer.
This check ignores line marker directives.
Definition at line 1493 of file SourceManager.h.
References getFileID().
|
inline |
Returns whether Loc
is located in a <scratch space> file.
Definition at line 1524 of file SourceManager.h.
References Filename, clang::PresumedLoc::getFilename(), getPresumedLoc(), clang::PresumedLoc::isInvalid(), and Loc.
Referenced by isInSystemMacro().
|
inline |
Get the number of loaded SLocEntries we have.
Definition at line 1752 of file SourceManager.h.
|
inline |
Get the number of local SLocEntries we have.
Definition at line 1738 of file SourceManager.h.
Referenced by clang::Preprocessor::HandleEndOfFile(), and clang::PreprocessorLexer::PreprocessorLexer().
void SourceManager::noteSLocAddressSpaceUsage | ( | DiagnosticsEngine & | Diag, |
std::optional< unsigned > | MaxNotes = 32 |
||
) | const |
Definition at line 2244 of file SourceManager.cpp.
|
delete |
void SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
FileEntryRef | NewFile | ||
) |
Override the given source file with another one.
SourceFile | the source file which will be overridden. |
NewFile | the file whose contents will be used as the data instead of the contents of the given source file. |
Definition at line 712 of file SourceManager.cpp.
References clang::FileEntryRef::getSize(), and clang::FileEntry::getSize().
|
inline |
Override the contents of the given source file by providing an already-allocated buffer.
SourceFile | the source file whose contents will be overridden. |
Buffer | the memory buffer whose contents will be used as the data in the given source file. |
Definition at line 992 of file SourceManager.h.
References overrideFileContents().
Referenced by InitializeFileRemapping(), overrideFileContents(), and clang::Preprocessor::SetCodeCompletionPoint().
void SourceManager::overrideFileContents | ( | FileEntryRef | SourceFile, |
std::unique_ptr< llvm::MemoryBuffer > | Buffer | ||
) |
Override the contents of the given source file by providing an already-allocated buffer.
SourceFile | the source file whose contents will be overridden. |
Buffer | the memory buffer whose contents will be used as the data in the given source file. |
Definition at line 702 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::BufferOverridden, and clang::SrcMgr::ContentCache::setBuffer().
void SourceManager::PrintStats | ( | ) | const |
Print statistics to stderr.
Definition at line 2158 of file SourceManager.cpp.
Referenced by clang::FrontendAction::EndSourceFile().
|
inline |
Push an entry to the module build stack.
Definition at line 879 of file SourceManager.h.
Referenced by prepareToBuildModule().
|
inline |
Specify that all files that are read during this compilation are transient.
Definition at line 1038 of file SourceManager.h.
Referenced by clang::FrontendAction::BeginSourceFile().
|
inline |
Definition at line 1785 of file SourceManager.h.
Referenced by clang::ASTReader::ASTReader().
void SourceManager::setFileIsTransient | ( | FileEntryRef | SourceFile | ) |
Specify that a file is transient.
Definition at line 740 of file SourceManager.cpp.
References clang::File, and clang::SrcMgr::ContentCache::IsTransient.
Referenced by clang::FrontendAction::BeginSourceFile().
|
inline |
Set the file ID for the main source file.
Definition at line 891 of file SourceManager.h.
Referenced by clang::CompilerInstance::InitializeSourceManager().
|
inline |
Set the module build stack.
Definition at line 873 of file SourceManager.h.
|
inline |
Set the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 1126 of file SourceManager.h.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
inline |
Set true if the SourceManager should report the original file name for contents of files that were overridden by other files.
Defaults to true.
Definition at line 859 of file SourceManager.h.
Referenced by InitializeFileRemapping().
|
inline |
Set the file ID for the precompiled preamble.
Definition at line 901 of file SourceManager.h.
References clang::FileID::isInvalid(), and clang::Preamble.
Get the FileID for the given file.
If the source file is included multiple times, the FileID will be the first inclusion.
Definition at line 1610 of file SourceManager.cpp.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by getOrCreateFileID(), and translateFile().
|
inline |
Definition at line 1643 of file SourceManager.h.
References clang::FileEntryRef::getFileEntry(), and translateFile().
SourceLocation SourceManager::translateFileLineCol | ( | const FileEntry * | SourceFile, |
unsigned | Line, | ||
unsigned | Col | ||
) | const |
Get the source location for the given file:line:col triplet.
If the source file is included multiple times, the source location will be based upon the first inclusion.
If the source file is included multiple times, the source location will be based upon an arbitrary inclusion.
Definition at line 1596 of file SourceManager.cpp.
References clang::Line.
Referenced by clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata(), and clang::BackendConsumer::getBestLocationFromDebugLoc().
SourceLocation SourceManager::translateLineCol | ( | FileID | FID, |
unsigned | Line, | ||
unsigned | Col | ||
) | const |
Get the source location in FID
for the given line:col.
Get the source location in.
Returns null location if FID
is not a file SLocEntry.
Definition at line 1649 of file SourceManager.cpp.
References Diag(), clang::SrcMgr::LineOffsetMapping::get(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::SLocEntry::getOffset(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), clang::Line, clang::SrcMgr::LineOffsetMapping::size(), and clang::SrcMgr::ContentCache::SourceLineCache.
|
inline |
True if non-system source files should be treated as volatile (likely to change while trying to use them).
Definition at line 865 of file SourceManager.h.
|
friend |
Definition at line 1842 of file SourceManager.h.
|
friend |
Definition at line 1843 of file SourceManager.h.