clang
9.0.0
|
This class handles loading and caching of source files into memory. More...
#include "clang/Basic/SourceManager.h"
Classes | |
struct | MemoryBufferSizes |
Public Types | |
enum | UnownedTag { Unowned } |
using | fileinfo_iterator = llvm::DenseMap< const FileEntry *, 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 . More... | |
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. More... | |
bool | userFilesAreVolatile () const |
True if non-system source files should be treated as volatile (likely to change while trying to use them). More... | |
ModuleBuildStack | getModuleBuildStack () const |
Retrieve the module build stack. More... | |
void | setModuleBuildStack (ModuleBuildStack stack) |
Set the module build stack. More... | |
void | pushModuleBuildStack (StringRef moduleName, FullSourceLoc importLoc) |
Push an entry to the module build stack. More... | |
FileID | getMainFileID () const |
Returns the FileID of the main source file. More... | |
void | setMainFileID (FileID FID) |
Set the file ID for the main source file. More... | |
void | setPreambleFileID (FileID Preamble) |
Set the file ID for the precompiled preamble. More... | |
FileID | getPreambleFileID () const |
Get the file ID for the precompiled preamble if there is one. More... | |
FileID | createFileID (const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0) |
Create a new FileID that represents the specified file being #included from the specified IncludePosition. More... | |
FileID | createFileID (std::unique_ptr< llvm::MemoryBuffer > Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, unsigned LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
Create a new FileID that represents the specified memory buffer. More... | |
FileID | createFileID (UnownedTag, const llvm::MemoryBuffer *Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, unsigned LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
Create a new FileID that represents the specified memory buffer. More... | |
FileID | getOrCreateFileID (const FileEntry *SourceFile, SrcMgr::CharacteristicKind FileCharacter) |
Get the FileID for SourceFile if it exists. More... | |
SourceLocation | createMacroArgExpansionLoc (SourceLocation Loc, SourceLocation ExpansionLoc, unsigned TokLength) |
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be referenced from ExpansionLoc, and that it represents the expansion of a macro argument into the function-like macro body. More... | |
SourceLocation | createExpansionLoc (SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, bool ExpansionIsTokenRange=true, int LoadedID=0, unsigned LoadedOffset=0) |
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be referenced from ExpansionLoc. More... | |
SourceLocation | createTokenSplitLoc (SourceLocation SpellingLoc, SourceLocation TokenStart, SourceLocation TokenEnd) |
Return a new SourceLocation that encodes that the token starting at TokenStart ends prematurely at TokenEnd . More... | |
const llvm::MemoryBuffer * | getMemoryBufferForFile (const FileEntry *File, bool *Invalid=nullptr) |
Retrieve the memory buffer associated with the given file. More... | |
void | overrideFileContents (const FileEntry *SourceFile, llvm::MemoryBuffer *Buffer, bool DoNotFree) |
Override the contents of the given source file by providing an already-allocated buffer. More... | |
void | overrideFileContents (const FileEntry *SourceFile, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
void | overrideFileContents (const FileEntry *SourceFile, const FileEntry *NewFile) |
Override the given source file with another one. More... | |
bool | isFileOverridden (const FileEntry *File) const |
Returns true if the file contents have been overridden. More... | |
void | disableFileContentsOverride (const FileEntry *File) |
Disable overridding the contents of a file, previously enabled with overrideFileContents. More... | |
void | setFileIsTransient (const FileEntry *SourceFile) |
Specify that a file is transient. More... | |
void | setAllFilesAreTransient (bool Transient) |
Specify that all files that are read during this compilation are transient. More... | |
const llvm::MemoryBuffer * | getBuffer (FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const |
Return the buffer for the specified FileID. More... | |
const llvm::MemoryBuffer * | getBuffer (FileID FID, bool *Invalid=nullptr) const |
const FileEntry * | getFileEntryForID (FileID FID) const |
Returns the FileEntry record for the provided FileID. More... | |
const FileEntry * | getFileEntryForSLocEntry (const SrcMgr::SLocEntry &sloc) const |
Returns the FileEntry record for the provided SLocEntry. More... | |
StringRef | getBufferData (FileID FID, bool *Invalid=nullptr) const |
Return a StringRef to the source buffer data for the specified FileID. More... | |
unsigned | getNumCreatedFIDsForFileID (FileID FID) const |
Get the number of FileIDs (files and macros) that were created during preprocessing of FID , including it. More... | |
void | setNumCreatedFIDsForFileID (FileID FID, unsigned NumFIDs, bool Force=false) const |
Set the number of FileIDs (files and macros) that were created during preprocessing of FID , including it. More... | |
FileID | getFileID (SourceLocation SpellingLoc) const |
Return the FileID for a SourceLocation. More... | |
StringRef | getFilename (SourceLocation SpellingLoc) const |
Return the filename of the file containing a SourceLocation. More... | |
SourceLocation | getLocForStartOfFile (FileID FID) const |
Return the source location corresponding to the first byte of the specified file. More... | |
SourceLocation | getLocForEndOfFile (FileID FID) const |
Return the source location corresponding to the last byte of the specified file. More... | |
SourceLocation | getIncludeLoc (FileID FID) const |
Returns the include location if FID is a #include'd file otherwise it returns an invalid location. More... | |
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. More... | |
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. More... | |
CharSourceRange | getImmediateExpansionRange (SourceLocation Loc) const |
Return the start/end of the expansion information for an expansion location. More... | |
CharSourceRange | getExpansionRange (SourceLocation Loc) const |
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file. More... | |
CharSourceRange | getExpansionRange (SourceRange Range) const |
Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. More... | |
CharSourceRange | getExpansionRange (CharSourceRange Range) const |
Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. More... | |
SourceLocation | getSpellingLoc (SourceLocation Loc) const |
Given a SourceLocation object, return the spelling location referenced by the ID. More... | |
SourceLocation | getImmediateSpellingLoc (SourceLocation Loc) const |
Given a SourceLocation object, return the spelling location referenced by the ID. More... | |
SourceLocation | getComposedLoc (FileID FID, unsigned Offset) const |
Form a SourceLocation from a FileID and Offset pair. More... | |
std::pair< FileID, unsigned > | getDecomposedLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. More... | |
std::pair< FileID, unsigned > | getDecomposedExpansionLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. More... | |
std::pair< FileID, unsigned > | getDecomposedSpellingLoc (SourceLocation Loc) const |
Decompose the specified location into a raw FileID + Offset pair. More... | |
std::pair< FileID, unsigned > | getDecomposedIncludedLoc (FileID FID) const |
Returns the "included/expanded in" decomposed location of the given FileID. More... | |
unsigned | getFileOffset (SourceLocation SpellingLoc) const |
Returns the offset from the start of the file that the specified SourceLocation represents. More... | |
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. More... | |
bool | isMacroBodyExpansion (SourceLocation Loc) const |
Tests whether the given source location represents the expansion of a macro body. More... | |
bool | isAtStartOfImmediateMacroExpansion (SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const |
Returns true if the given MacroID location points at the beginning of the immediate macro expansion. More... | |
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. More... | |
bool | isInSLocAddrSpace (SourceLocation Loc, SourceLocation Start, unsigned Length, unsigned *RelativeOffset=nullptr) const |
Returns true if Loc is inside the [Start , +Length ) chunk of the source location address space. More... | |
bool | isInSameSLocAddrSpace (SourceLocation LHS, SourceLocation RHS, int *RelativeOffset) const |
Return true if both LHS and RHS are in the local source location address space or the loaded one. More... | |
const char * | getCharacterData (SourceLocation SL, bool *Invalid=nullptr) const |
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer. More... | |
unsigned | getColumnNumber (FileID FID, unsigned FilePos, bool *Invalid=nullptr) const |
Return the column # for the specified file position. More... | |
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. More... | |
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. More... | |
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. More... | |
PresumedLoc | getPresumedLoc (SourceLocation Loc, bool UseLineDirectives=true) const |
Returns the "presumed" location of a SourceLocation specifies. More... | |
bool | isInMainFile (SourceLocation Loc) const |
Returns whether the PresumedLoc for a given SourceLocation is in the main file. More... | |
bool | isWrittenInSameFile (SourceLocation Loc1, SourceLocation Loc2) const |
Returns true if the spelling locations for both SourceLocations are part of the same file buffer. More... | |
bool | isWrittenInMainFile (SourceLocation Loc) const |
Returns true if the spelling location for the given location is in the main file buffer. More... | |
bool | isWrittenInBuiltinFile (SourceLocation Loc) const |
Returns whether Loc is located in a <built-in> file. More... | |
bool | isWrittenInCommandLineFile (SourceLocation Loc) const |
Returns whether Loc is located in a <command line>=""> file. More... | |
bool | isWrittenInScratchSpace (SourceLocation Loc) const |
Returns whether Loc is located in a <scratch space>=""> file. More... | |
bool | isInSystemHeader (SourceLocation Loc) const |
Returns if a SourceLocation is in a system header. More... | |
bool | isInExternCSystemHeader (SourceLocation Loc) const |
Returns if a SourceLocation is in an "extern C" system header. More... | |
bool | isInSystemMacro (SourceLocation loc) const |
Returns whether Loc is expanded from a macro in a system header. More... | |
unsigned | getFileIDSize (FileID FID) const |
The size of the SLocEntry that FID represents. More... | |
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 . More... | |
unsigned | getLineTableFilenameID (StringRef Str) |
Return the uniqued ID for the specified filename. More... | |
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. More... | |
bool | hasLineTable () const |
Determine if the source manager has a line table. More... | |
LineTableInfo & | getLineTable () |
Retrieve the stored line table. More... | |
size_t | getContentCacheSize () const |
Return the total amount of physical memory allocated by the ContentCache allocator. More... | |
MemoryBufferSizes | getMemoryBufferSizes () const |
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory. More... | |
size_t | getDataStructureSizes () const |
Return the amount of memory used for various side tables and data structures in the SourceManager. More... | |
SourceLocation | translateFileLineCol (const FileEntry *SourceFile, unsigned Line, unsigned Col) const |
Get the source location for the given file:line:col triplet. More... | |
FileID | translateFile (const FileEntry *SourceFile) const |
Get the FileID for the given file. More... | |
SourceLocation | translateLineCol (FileID FID, unsigned Line, unsigned Col) const |
Get the source location in FID for the given line:col. More... | |
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. More... | |
bool | isBeforeInTranslationUnit (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the translation unit. More... | |
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. More... | |
bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the "source location
address space". More... | |
bool | isBeforeInSLocAddrSpace (SourceLocation LHS, unsigned RHS) const |
Determines the order of a source location and a source location offset in the "source location address space". More... | |
bool | isPointWithin (SourceLocation Location, SourceLocation Start, SourceLocation End) const |
Return true if the Point is within Start and End. More... | |
fileinfo_iterator | fileinfo_begin () const |
fileinfo_iterator | fileinfo_end () const |
bool | hasFileInfo (const FileEntry *File) const |
void | PrintStats () const |
Print statistics to stderr. More... | |
void | dump () const |
unsigned | local_sloc_entry_size () const |
Get the number of local SLocEntries we have. More... | |
const SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index, bool *Invalid=nullptr) const |
Get a local SLocEntry. This is exposed for indexing. More... | |
unsigned | loaded_sloc_entry_size () const |
Get the number of loaded SLocEntries we have. More... | |
const SrcMgr::SLocEntry & | getLoadedSLocEntry (unsigned Index, bool *Invalid=nullptr) const |
Get a loaded SLocEntry. This is exposed for indexing. More... | |
const SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=nullptr) const |
unsigned | getNextLocalOffset () const |
void | setExternalSLocEntrySource (ExternalSLocEntrySource *Source) |
std::pair< int, unsigned > | AllocateLoadedSLocEntries (unsigned NumSLocEntries, unsigned TotalSize) |
Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external source. More... | |
bool | isLoadedSourceLocation (SourceLocation Loc) const |
Returns true if Loc came from a PCH/Module. More... | |
bool | isLocalSourceLocation (SourceLocation Loc) const |
Returns true if Loc did not come from a PCH/Module. More... | |
bool | isLoadedFileID (FileID FID) const |
Returns true if FID came from a PCH/Module. More... | |
bool | isLocalFileID (FileID FID) const |
Returns true if FID did not come from a PCH/Module. More... | |
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. More... | |
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 583 of file SourceManager.h.
using clang::SourceManager::fileinfo_iterator = llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::const_iterator |
Definition at line 1624 of file SourceManager.h.
Enumerator | |
---|---|
Unowned |
Definition at line 840 of file SourceManager.h.
SourceManager::SourceManager | ( | DiagnosticsEngine & | Diag, |
FileManager & | FileMgr, | ||
bool | UserFilesAreVolatile = false |
||
) |
Definition at line 340 of file SourceManager.cpp.
References clearIDTables(), and clang::DiagnosticsEngine::setSourceManager().
|
explicitdelete |
SourceManager::~SourceManager | ( | ) |
Definition at line 347 of file SourceManager.cpp.
References i.
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 302 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by ReadOriginalFileName().
std::pair< int, unsigned > SourceManager::AllocateLoadedSLocEntries | ( | unsigned | NumSLocEntries, |
unsigned | 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 480 of file SourceManager.cpp.
References createFileID(), clang::FileID::isInvalid(), and local_sloc_entry_size().
void SourceManager::clearIDTables | ( | ) |
Definition at line 366 of file SourceManager.cpp.
References createExpansionLoc().
Referenced by SourceManager().
SourceLocation SourceManager::createExpansionLoc | ( | SourceLocation | Loc, |
SourceLocation | ExpansionLocStart, | ||
SourceLocation | ExpansionLocEnd, | ||
unsigned | TokLength, | ||
bool | ExpansionIsTokenRange = true , |
||
int | LoadedID = 0 , |
||
unsigned | LoadedOffset = 0 |
||
) |
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be referenced from ExpansionLoc.
Definition at line 600 of file SourceManager.cpp.
References clang::serialized_diags::create().
Referenced by clearIDTables(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::CreateString(), clang::ASTImporter::Import(), clang::TokenLexer::Init(), isTargetEnvironment(), isTrivialSingleTokenExpansion(), and clang::TokenLexer::Lex().
|
inline |
Create a new FileID that represents the specified file being #included from the specified IncludePosition.
This translates NULL into standard input.
Definition at line 818 of file SourceManager.h.
References clang::SrcMgr::isSystem().
Referenced by AllocateLoadedSLocEntries(), clang::tooling::applyAllReplacements(), applyEditsToTemp(), clang::FrontendAction::BeginSourceFile(), ConvertBackendLocation(), clang::Preprocessor::EnterMainSourceFile(), clang::ScratchBuffer::getToken(), clang::ASTImporter::Import(), clang::CompilerInstance::InitializeSourceManager(), and clang::syntax::Arena::lexBuffer().
|
inline |
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 831 of file SourceManager.h.
|
inline |
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 846 of file SourceManager.h.
SourceLocation SourceManager::createMacroArgExpansionLoc | ( | SourceLocation | Loc, |
SourceLocation | ExpansionLoc, | ||
unsigned | TokLength | ||
) |
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be referenced from ExpansionLoc, and that it represents the expansion of a macro argument into the function-like macro body.
Definition at line 591 of file SourceManager.cpp.
Referenced by clang::ASTImporter::Import(), and updateConsecutiveMacroArgTokens().
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 612 of file SourceManager.cpp.
References getFileID().
Referenced by clang::Preprocessor::SplitToken().
void SourceManager::disableFileContentsOverride | ( | const FileEntry * | File | ) |
Disable overridding the contents of a file, previously enabled with overrideFileContents.
This should be called before parsing has begun.
Definition at line 675 of file SourceManager.cpp.
References isFileOverridden(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::ASTReader::resolvePendingMacro().
LLVM_DUMP_METHOD void SourceManager::dump | ( | ) | const |
Definition at line 2154 of file SourceManager.cpp.
|
inline |
Definition at line 1626 of file SourceManager.h.
Referenced by PrintStats().
|
inline |
Definition at line 1627 of file SourceManager.h.
Referenced by PrintStats().
|
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 a non-empty error string.
Definition at line 956 of file SourceManager.h.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::html::AddLineNumbers(), clang::Lexer::Create_PragmaLexer(), clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), DetectEOL(), clang::html::EscapeText(), clang::CodeGenAction::ExecuteAction(), clang::PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), findDirectives(), clang::format::FormatTokenLexer::FormatTokenLexer(), getBufferName(), getColumnNumber(), getLengthOnSingleLine(), HandlePopUpPieceEndTag(), clang::html::HighlightMacros(), isBeforeInTranslationUnit(), isBisonFile(), clang::format::FormatTokenLexer::lex(), LexRawTokensFromMainFile(), clang::RewriteIncludesInInput(), clang::DiagnosticsEngine::SetDelayedDiagnostic(), clang::html::SyntaxHighlight(), and clang::TokenRewriter::TokenRewriter().
|
inline |
Definition at line 971 of file SourceManager.h.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
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 693 of file SourceManager.cpp.
References clang::CharSourceRange::getBegin(), clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), clang::SrcMgr::SLocEntry::getFile(), getFileID(), getImmediateExpansionRange(), getImmediateSpellingLoc(), getLoadedSLocEntry(), getLocalSLocEntry(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), clang::SrcMgr::SLocEntry::isExpansion(), clang::SrcMgr::SLocEntry::isFile(), clang::SourceLocation::isFileID(), isMacroArgExpansion(), and Offset.
Referenced by clang::arcmt::trans::MigrationContext::addPropertyAttribute(), adjustRemoval(), clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), clang::Lexer::findNextToken(), clang::arcmt::trans::findSemiAfterLocation(), clang::tooling::formatAndApplyAllReplacements(), getBeginningOfFileToken(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getImmediateMacroNameForDiagnostics(), clang::Lexer::getIndentationForLine(), clang::StringLiteral::getLocationOfByte(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::comments::Lexer::getSpelling(), clang::html::HighlightRange(), LocPropertyAttribute(), LookThroughTransitiveAssignmentsAndCommaOperators(), onlyWhitespaceBetween(), clang::RawComment::RawComment(), clang::edit::Commit::replaceText(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), clang::Preprocessor::SplitToken(), and clang::syntax::FileRange::text().
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 1425 of file SourceManager.cpp.
References getBuffer(), getFileID(), and isInvalid().
Referenced by clang::Preprocessor::CheckMacroName(), clang::CodeGen::CodeGenModule::EmitAnnotationUnit(), and clang::CoverageSourceInfo::SourceRangeSkipped().
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 1117 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedSpellingLoc(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by addFixitForObjCARCConversion(), clang::arcmt::ObjCMigrateAction::BeginInvocation(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::DumpToken(), clang::Lexer::findLocationAfterToken(), fixItNullability(), GetFirstChar(), clang::Lexer::getSpelling(), clang::Preprocessor::getSpellingOfSingleCharacterNumericConstant(), clang::Lexer::getTokenPrefixLength(), clang::VerifyDiagnosticConsumer::HandleComment(), isSameWidthConstantConversion(), IsStringPrefix(), mustSynthesizeSetterGetterMethod(), clang::Parser::ParseConstraintExpression(), RewriteOneForwardClassDecl(), scanToNextArgument(), clang::syntax::Token::text(), and Write_RethrowObject().
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 1142 of file SourceManager.cpp.
References getBuffer(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by buildFixItInsertionLine(), getExpansionColumnNumber(), getPresumedLoc(), getSpellingColumnNumber(), and HandlePopUpPieceEndTag().
|
inline |
Form a SourceLocation from a FileID and Offset pair.
Definition at line 1183 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), clang::SrcMgr::SLocEntry::isFile(), and Offset.
Referenced by getNumberOfModules(), and clang::ASTImporter::Import().
|
inline |
Return the total amount of physical memory allocated by the ContentCache allocator.
Definition at line 1525 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 2233 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 1212 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), clang::SourceLocation::isFileID(), and Offset.
Referenced by buildFixItInsertionLine(), getExpansionColumnNumber(), getExpansionLineNumber(), getFileCharacteristic(), getPresumedLoc(), HandlePopUpPieceEndTag(), isGCCAsmStatement(), isInMainFile(), and ReadLineMarkerFlags().
Returns the "included/expanded in" decomposed location of the given FileID.
Definition at line 1947 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), getSLocEntry(), clang::SrcMgr::SLocEntry::isExpansion(), clang::FileID::isInvalid(), and clang::SourceLocation::isValid().
Referenced by MoveUpIncludeHierarchy(), and clang::DiagnosticsEngine::SetDelayedDiagnostic().
|
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 1198 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset().
Referenced by clang::ASTUnit::addFileLevelDecl(), clang::arcmt::trans::MigrationContext::addPropertyAttribute(), clang::syntax::TokenCollector::Builder::build(), buildFixItInsertionLine(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::syntax::FileRange::FileRange(), clang::Lexer::findNextToken(), clang::arcmt::trans::findSemiAfterLocation(), getBeginningOfFileToken(), clang::Lexer::GetBeginningOfToken(), getBufferData(), clang::ASTWriter::getDeclID(), getDecomposedIncludedLoc(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getImmediateMacroNameForDiagnostics(), getImmediateSpellingLoc(), clang::Lexer::getIndentationForLine(), clang::StringLiteral::getLocationOfByte(), getMacroArgExpandedLocation(), getRangeSize(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::comments::Lexer::getSpelling(), hasSuperInitCall(), clang::ASTImporter::Import(), isAtStartOfImmediateMacroExpansion(), isBeforeInTranslationUnit(), isFunctionMacroExpansion(), clang::format::FormatTokenLexer::lex(), loadModuleMapForModuleBuild(), LocPropertyAttribute(), makeRangeFromFileLocs(), clang::Sema::notePreviousDefinition(), onlyWhitespaceBetween(), clang::tooling::operator==(), printLoc(), clang::syntax::Token::range(), clang::RawComment::RawComment(), clang::edit::Commit::replaceText(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), clang::DiagnosticsEngine::SetDelayedDiagnostic(), clang::Preprocessor::SplitToken(), and translateLineCol().
|
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 1231 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), clang::SourceLocation::isFileID(), and Offset.
Referenced by getCharacterData(), getSpellingColumnNumber(), and getSpellingLineNumber().
|
inline |
Definition at line 758 of file SourceManager.h.
References Diag().
Referenced by clang::Decl::dump(), clang::DeclContext::dumpLookups(), findDirectives(), and getTargetEntryUniqueInfo().
unsigned SourceManager::getExpansionColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1204 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedExpansionLoc(), and isInvalid().
Referenced by createTextRegion(), EmitAlphaCounter(), highlightRange(), and outputPrintable().
unsigned SourceManager::getExpansionLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1373 of file SourceManager.cpp.
References getDecomposedExpansionLoc(), getLineNumber(), and isInvalid().
Referenced by CompactMacroExpandedPieces(), createTextRegion(), EmitAlphaCounter(), clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), findLinesForRange(), highlightRange(), printLocation(), RewriteOneForwardClassDecl(), and clang::JSONNodeDumper::Visit().
|
inline |
Given a SourceLocation object Loc
, return the expansion location referenced by the ID.
Definition at line 1119 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::markup::AddFID(), clang::AttachDependencyGraphGen(), clang::syntax::TokenCollector::Builder::build(), CompactMacroExpandedPieces(), clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), EmitAlphaCounter(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::markup::EmitLocation(), clang::Sema::findMacroSpelling(), clang::markup::GetFID(), getLengthOnSingleLine(), clang::Preprocessor::getModuleForLocation(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), getNullabilityCompletenessCheckFileID(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::diff::SyntaxTree::getSourceRangeOffsets(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::html::HighlightMacros(), clang::html::HighlightRange(), clang::TokenLexer::Init(), clang::SourceLocation::print(), printLoc(), clang::printSourceLocationAsJson(), clang::RewriteMacrosInInput(), toLevel(), and clang::JSONNodeDumper::Visit().
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 1001 of file SourceManager.cpp.
References clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), getImmediateExpansionRange(), clang::SourceLocation::isFileID(), clang::CharSourceRange::isTokenRange(), clang::CharSourceRange::setBegin(), clang::CharSourceRange::setEnd(), and clang::CharSourceRange::setTokenRange().
Referenced by clang::syntax::TokenCollector::Builder::build(), clang::TextDiagnostic::emitDiagnosticLoc(), FindLocsWithCommonFileID(), getLengthOnSingleLine(), clang::html::HighlightMacros(), isTargetEnvironment(), and clang::arcmt::writeARCDiagsToPlist().
|
inline |
Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file.
Definition at line 1146 of file SourceManager.h.
References Begin, End, clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::CharSourceRange::getEnd(), and clang::CharSourceRange::isTokenRange().
|
inline |
Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file.
Definition at line 1155 of file SourceManager.h.
References clang::CharSourceRange::getAsRange(), clang::CharSourceRange::getEnd(), clang::CharSourceRange::isTokenRange(), and clang::CharSourceRange::setTokenRange().
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 1395 of file SourceManager.cpp.
References clang::SrcMgr::C_User, clang::LineEntry::FileKind, getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getFileCharacteristic(), getSLocEntry(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SrcMgr::SLocEntry::isFile(), and clang::SourceLocation::isValid().
Referenced by DetectEOL().
Returns the FileEntry record for the provided FileID.
Definition at line 988 of file SourceManager.h.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::SLocEntry::isFile(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::arcmt::MigrationProcess::applyTransform(), clang::tooling::AtomicChange::AtomicChange(), clang::AttachDependencyGraphGen(), clang::PrecompiledPreamble::Build(), compareCrossTUSourceLocs(), DetectEOL(), clang::Preprocessor::EnterMainSourceFile(), clang::sema::SemaPPCallbacks::FileChanged(), clang::ModuleMap::getContainingModuleMapFile(), clang::PreprocessorLexer::getFileEntry(), clang::Lexer::getImmediateMacroNameForDiagnostics(), clang::Preprocessor::getModuleForLocation(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), hasSuperInitCall(), IsFromSameFile(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), clang::Preprocessor::isPCHThroughHeader(), isTargetEnvironment(), clang::Preprocessor::LookupFile(), clang::Sema::notePreviousDefinition(), clang::tooling::operator==(), prepareToBuildModule(), printLoc(), PrintUnexpected(), clang::CodeGen::CGDebugInfo::remapDIPath(), clang::VerifyDiagnosticConsumer::UpdateParsedFileStatus(), and clang::arcmt::writeARCDiagsToPlist().
|
inline |
Returns the FileEntry record for the provided SLocEntry.
Definition at line 1001 of file SourceManager.h.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::ContentCache::OrigEntry.
|
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 1050 of file SourceManager.h.
Referenced by clang::CodeGen::CodeGenModule::AddDeferredUnusedCoverageMapping(), clang::markup::AddFID(), clang::AttachDependencyGraphGen(), AuditedType(), clang::syntax::TokenCollector::Builder::build(), checkConfigMacro(), checkObjCUnusedIvar(), CompactMacroExpandedPieces(), clang::Lexer::Create_PragmaLexer(), createTokenSplitLoc(), DiagnoseNullConversion(), EmitAlphaCounter(), EvaluateDefined(), clang::sema::SemaPPCallbacks::FileChanged(), clang::syntax::FileRange::FileRange(), findLinesForRange(), FindLocsWithCommonFileID(), clang::tooling::findSelectedASTNodes(), getBufferData(), getBufferName(), clang::ModuleMap::getContainingModuleMapFile(), clang::markup::GetFID(), getImmediateExpansionRange(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getImmediateMacroNameForDiagnostics(), getLengthOnSingleLine(), getMacroArgExpansionFileIDs(), clang::Preprocessor::getModuleForLocation(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), getNullabilityCompletenessCheckFileID(), clang::ScratchBuffer::getToken(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), hasSuperInitCall(), clang::html::HighlightMacros(), clang::html::HighlightRange(), highlightRange(), clang::ASTImporter::Import(), clang::index::IndexingContext::importedModule(), isArgumentExpandedFromMacro(), isAtEndOfImmediateMacroExpansion(), IsFromSameFile(), clang::ento::AnalysisManager::isInCodeFile(), isMacroArgExpansion(), isMacroBodyExpansion(), clang::TokenLexer::Lex(), LookThroughTransitiveAssignmentsAndCommaOperators(), clang::Lexer::makeFileCharRange(), mapDiagnosticRanges(), PrintUnexpected(), retrieveMacroLocation(), Scan(), shouldIgnoreMacro(), shouldReportOccurrenceForSystemDeclOnlyMode(), clang::CoverageSourceInfo::SourceRangeSkipped(), and UseNSOptionsMacro().
unsigned SourceManager::getFileIDSize | ( | FileID | FID | ) | const |
The size of the SLocEntry that FID
represents.
Definition at line 1539 of file SourceManager.cpp.
References getNextLocalOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and local_sloc_entry_size().
Referenced by DetectEOL(), clang::CoverageSourceInfo::SourceRangeSkipped(), and translateLineCol().
|
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 1129 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::ASTUnit::addFileLevelDecl(), clang::ASTReader::FindExternalLexicalDecls(), clang::ASTWriter::getDeclID(), clang::index::IndexingContext::importedModule(), clang::SanitizerBlacklist::isBlacklistedLocation(), isPreprocessedEntityIfInFileID(), makeStandaloneDiagnostic(), clang::index::FileIndexRecord::print(), clang::XRayFunctionFilter::shouldImbueLocation(), and shouldReportOccurrenceForSystemDeclOnlyMode().
|
inline |
Definition at line 760 of file SourceManager.h.
Referenced by clang::tooling::Replacement::apply(), clang::tooling::RefactoringTool::applyAllReplacements(), clang::tooling::formatAndApplyAllReplacements(), clang::SrcMgr::ContentCache::getBuffer(), clang::cross_tu::CrossTranslationUnitContext::getLookupName(), clang::cross_tu::CrossTranslationUnitContext::importDefinition(), clang::ModuleMap::inferFrameworkModule(), clang::ModuleMap::isBuiltinHeader(), clang::ASTWriter::PreparePathForOutput(), clang::TextDiagnostic::printDiagnosticMessage(), and clang::ModuleMap::setUmbrellaHeader().
|
inline |
Return the filename of the file containing a SourceLocation.
Definition at line 1061 of file SourceManager.h.
Referenced by clang::tooling::DiagnosticMessage::DiagnosticMessage(), clang::SanitizerBlacklist::isBlacklistedLocation(), clang::ento::AnalysisManager::isInCodeFile(), makeStandaloneDiagnostic(), 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 1252 of file SourceManager.h.
Referenced by clang::syntax::TokenCollector::Builder::build(), DetectEOL(), clang::tooling::DiagnosticMessage::DiagnosticMessage(), clang::syntax::FileRange::FileRange(), getLengthOnSingleLine(), clang::diff::SyntaxTree::getSourceRangeOffsets(), clang::html::HighlightRange(), clang::format::FormatTokenLexer::lex(), makeStandaloneDiagnostic(), makeStandaloneRange(), clang::RewriteMacrosInInput(), clang::CoverageSourceInfo::SourceRangeSkipped(), and clang::html::SyntaxHighlight().
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 987 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocRange(), getFileID(), getSLocEntry(), and clang::SourceLocation::isMacroID().
Referenced by checkAllAtProps(), CheckMoveOnConstruction(), DiagnoseNullConversion(), getBufferData(), getExpansionRange(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getImmediateMacroNameForDiagnostics(), getMacroArgExpansionFileIDs(), handleObjCOwnershipTypeAttr(), isFunctionMacroExpansion(), clang::TokenLexer::Lex(), mapDiagnosticRanges(), retrieveMacroLocation(), and clang::CoverageSourceInfo::SourceRangeSkipped().
|
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 1708 of file SourceManager.h.
References clang::CharSourceRange::getBegin(), and clang::SourceLocation::isMacroID().
Referenced by getTopMostMacro(), isArgumentExpandedFromMacro(), IsFromSameFile(), IsInAnyMacroBody(), and isOriginMacroBody().
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 977 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), and clang::SourceLocation::isFileID().
Referenced by getBufferData(), getMacroArgExpansionFileIDs(), getTopMacroCallerLoc(), clang::Lexer::makeFileCharRange(), and retrieveMacroLocation().
|
inline |
Returns the include location if FID
is a #include'd file otherwise it returns an invalid location.
Definition at line 1093 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::sema::SemaPPCallbacks::FileChanged(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), clang::ento::AnalysisManager::isInCodeFile(), clang::Sema::notePreviousDefinition(), and clang::CoverageSourceInfo::SourceRangeSkipped().
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.
SourceLineCache for it on demand.
Definition at line 1273 of file SourceManager.cpp.
References ComputeLineNumbers(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), clang::SrcMgr::ContentCache::NumLines, and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by buildFixItInsertionLine(), DetectEOL(), getExpansionLineNumber(), getPresumedLoc(), clang::ASTContext::getRawCommentForDeclNoCache(), getSpellingLineNumber(), and isGCCAsmStatement().
LineTableInfo & SourceManager::getLineTable | ( | ) |
Retrieve the stored line table.
Definition at line 330 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 295 of file SourceManager.cpp.
|
inline |
Get a loaded SLocEntry. This is exposed for indexing.
Definition at line 1651 of file SourceManager.h.
Referenced by getBufferData(), and translateFile().
|
inline |
Get a local SLocEntry. This is exposed for indexing.
Definition at line 1641 of file SourceManager.h.
Referenced by emitBlob(), getBufferData(), and translateFile().
|
inline |
Return the source location corresponding to the last byte of the specified file.
Definition at line 1081 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by DetectEOL(), clang::format::FormatTokenLexer::lex(), and clang::CoverageSourceInfo::SourceRangeSkipped().
|
inline |
Return the source location corresponding to the first byte of the specified file.
Definition at line 1069 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Sema::ActOnStartOfTranslationUnit(), clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::arcmt::trans::MigrationContext::addPropertyAttribute(), clang::tooling::Replacement::apply(), applyEditsToTemp(), applyRewrite(), ConvertBackendLocation(), clang::Lexer::Create_PragmaLexer(), clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), clang::format::Environment::Environment(), clang::PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction(), clang::ASTReader::FindFileRegionDecls(), clang::Lexer::findNextToken(), clang::arcmt::trans::findSemiAfterLocation(), clang::edit::Commit::Edit::getFileLocation(), clang::edit::Commit::Edit::getInsertFromRange(), clang::StringLiteral::getLocationOfByte(), getPresumedLoc(), clang::Lexer::getRawToken(), clang::Lexer::getSpelling(), clang::ScratchBuffer::getToken(), HandlePopUpPieceEndTag(), LocPropertyAttribute(), clang::arcmt::trans::MigrationContext::rewritePropertyAttribute(), clang::DiagnosticsEngine::SetDelayedDiagnostic(), clang::CoverageSourceInfo::SourceRangeSkipped(), and Write_ProtocolExprReferencedMetadata().
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 1918 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SourceLocation::getLocWithOffset(), clang::SourceLocation::isFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), and Offset.
Referenced by clang::ASTUnit::getLocation().
|
inline |
Returns the FileID of the main source file.
Definition at line 794 of file SourceManager.h.
Referenced by clang::Sema::ActOnStartOfTranslationUnit(), clang::CodeGen::CodeGenModule::AddDeferredUnusedCoverageMapping(), clang::PrecompiledPreamble::Build(), clang::syntax::TokenCollector::Builder::build(), clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), DetectEOL(), clang::DoRewriteTest(), clang::Preprocessor::EnterMainSourceFile(), clang::CodeGenAction::ExecuteAction(), clang::PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::CompilerInstance::InitializeSourceManager(), isBisonFile(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), LexRawTokensFromMainFile(), clang::Preprocessor::LookupFile(), clang::ento::ModelInjector::ModelInjector(), prepareToBuildModule(), ReadOriginalFileName(), clang::CodeGen::CGDebugInfo::remapDIPath(), clang::RewriteIncludesInInput(), and clang::RewriteMacrosInInput().
const llvm::MemoryBuffer * SourceManager::getMemoryBufferForFile | ( | const FileEntry * | File, |
bool * | Invalid = nullptr |
||
) |
Retrieve the memory buffer associated with the given file.
Invalid | If non-NULL, will be set true if an error occurs while retrieving the memory buffer. |
Definition at line 646 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBuffer().
Referenced by clang::PrecompiledPreamble::Build(), 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 2215 of file SourceManager.cpp.
References i.
|
inline |
Retrieve the module build stack.
Definition at line 774 of file SourceManager.h.
Referenced by compileModuleImpl(), clang::CompilerInstance::loadModule(), and prepareToBuildModule().
|
inline |
Definition at line 1106 of file SourceManager.h.
References clang::ExternalSLocEntrySource::getModuleImportLoc().
|
inline |
Definition at line 1668 of file SourceManager.h.
Referenced by getFileIDSize(), and clang::TokenLexer::Init().
|
inline |
Get the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 1018 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
|
inline |
Get the FileID for SourceFile
if it exists.
Otherwise, create a new FileID for the SourceFile
.
Definition at line 856 of file SourceManager.h.
References clang::FileID::isValid().
Referenced by clang::tooling::Replacement::apply(), and clang::tooling::formatAndApplyAllReplacements().
|
inline |
Get the file ID for the precompiled preamble if there is one.
Definition at line 808 of file SourceManager.h.
unsigned SourceManager::getPresumedColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1211 of file SourceManager.cpp.
References ComputeLineNumbers(), clang::PresumedLoc::getColumn(), getPresumedLoc(), isInvalid(), and SM.
unsigned SourceManager::getPresumedLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1379 of file SourceManager.cpp.
References clang::PresumedLoc::getLine(), getPresumedLoc(), and isInvalid().
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 1439 of file SourceManager.cpp.
References clang::C, Filename, clang::SrcMgr::ContentCache::getBuffer(), getColumnNumber(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), getLineNumber(), getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), clang::FileEntry::getName(), getSLocEntry(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SrcMgr::SLocEntry::isFile(), clang::SourceLocation::isInvalid(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::AttachHeaderIncludeGen(), buildFixItInsertionLine(), clang::CodeGen::SanitizerMetadata::disableSanitizerForInstruction(), clang::DoPrintPreprocessedInput(), clang::TextNodeDumper::dumpLocation(), clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), clang::CodeGen::CodeGenModule::EmitAnnotationUnit(), clang::CodeGen::CodeGenFunction::EmitCheckSourceLocation(), clang::CodeGen::CGOpenMPRuntime::emitUpdateLocation(), getFunctionSourceLocation(), clang::getParameterABISpelling(), getPresumedColumnNumber(), getPresumedLineNumber(), getTargetEntryUniqueInfo(), clang::LogDiagnosticPrinter::HandleDiagnostic(), isTargetEnvironment(), clang::index::FileIndexRecord::print(), clang::SourceLocation::print(), PrintMacroDefinition(), clang::printSourceLocationAsJson(), ReadLineMarkerFlags(), clang::CodeGen::CGDebugInfo::remapDIPath(), clang::CodeGen::CGDebugInfo::setLocation(), and clang::JSONNodeDumper::Visit().
|
inline |
Definition at line 1659 of file SourceManager.h.
Referenced by emitBlob(), EvaluateDefined(), getBufferData(), getCharacterData(), clang::ASTWriter::getDeclID(), getDecomposedIncludedLoc(), getFileCharacteristic(), getFileIDSize(), getImmediateExpansionRange(), clang::Lexer::getImmediateMacroName(), getImmediateSpellingLoc(), getLineNumber(), getNullabilityCompletenessCheckFileID(), getPresumedLoc(), clang::ScratchBuffer::getToken(), clang::index::IndexingContext::importedModule(), isAtEndOfImmediateMacroExpansion(), isAtStartOfImmediateMacroExpansion(), isFunctionMacroExpansion(), isInMainFile(), isMacroArgExpansion(), isMacroBodyExpansion(), clang::Lexer::makeFileCharRange(), shouldReportOccurrenceForSystemDeclOnlyMode(), translateFile(), and translateLineCol().
unsigned SourceManager::getSpellingColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1197 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedSpellingLoc(), and isInvalid().
Referenced by clang::CoverageSourceInfo::SourceRangeSkipped().
unsigned SourceManager::getSpellingLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1367 of file SourceManager.cpp.
References getDecomposedSpellingLoc(), getLineNumber(), and isInvalid().
Referenced by ShouldDiagnoseEmptyStmtBody(), clang::CoverageSourceInfo::SourceRangeSkipped(), and clang::JSONNodeDumper::Visit().
|
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 1167 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::TokenConcatenation::AvoidConcat(), disambiguateSpellingInScope(), clang::TextNodeDumper::dumpLocation(), FindLocsWithCommonFileID(), clang::TypedefNameDecl::getAnonDeclWithTypedefName(), clang::Lexer::GetBeginningOfToken(), GetFirstChar(), clang::Lexer::getImmediateMacroName(), clang::Lexer::getImmediateMacroNameForDiagnostics(), clang::StringLiteral::getLocationOfByte(), getRangeSize(), getStrlenExprArg(), clang::Lexer::isAtEndOfMacroExpansion(), clang::diff::isNodeExcluded(), IsStringPrefix(), mapDiagnosticRanges(), clang::Sema::notePreviousDefinition(), clang::SourceLocation::print(), clang::printSourceLocationAsJson(), clang::edit::Commit::replaceText(), SelectDigraphErrorMessage(), shouldIgnoreDueToReservedName(), clang::CoverageSourceInfo::SourceRangeSkipped(), clang::Preprocessor::SplitToken(), and clang::JSONNodeDumper::Visit().
SourceLocation SourceManager::getTopMacroCallerLoc | ( | SourceLocation | Loc | ) | const |
Definition at line 993 of file SourceManager.cpp.
References getImmediateSpellingLoc(), and isMacroArgExpansion().
Referenced by DiagnoseNullConversion(), and clang::edit::Commit::replaceText().
Definition at line 1628 of file SourceManager.h.
References dump().
|
inline |
Determine if the source manager has a line table.
Definition at line 1514 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 384 of file SourceManager.cpp.
References clang::FileID::isInvalid(), clang::SrcMgr::ContentCache::IsSystemFile, clang::SrcMgr::ContentCache::IsTransient, clang::SrcMgr::ContentCache::OrigEntry, and clang::SrcMgr::ContentCache::replaceBuffer().
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 1075 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocEnd(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getFileID(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::SLocEntry::isExpansion(), isInFileID(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and clang::SourceLocation::isValid().
Referenced by clang::Lexer::isAtEndOfMacroExpansion().
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 1040 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getSLocEntry(), clang::SrcMgr::SLocEntry::isExpansion(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and clang::SourceLocation::isValid().
Referenced by CheckMoveOnConstruction(), and clang::Lexer::isAtStartOfMacroExpansion().
|
inline |
Determines the order of 2 source locations in the "source location address space".
Definition at line 1596 of file SourceManager.h.
Referenced by clang::TokenLexer::Lex().
|
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 1604 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 2018 of file SourceManager.cpp.
References getBuffer(), getDecomposedLoc(), isInTheSameTranslationUnit(), and clang::SourceLocation::isValid().
Referenced by clang::format::AffectedRangeManager::affectsCharSourceRange(), comparePiece(), clang::StmtSequence::contains(), disambiguateSpellingInScope(), clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(), clang::MacroDirective::findDirectiveAtLoc(), clang::ASTReader::FindExternalLexicalDecls(), clang::FunctionDecl::getReturnTypeSourceRange(), clang::PreprocessingRecord::isEntityInFileID(), clang::PPConditionalDirectiveRecord::CondDirectiveLoc::Comp::operator()(), clang::format::WhitespaceManager::Change::IsBeforeInFile::operator()(), clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(), removePunyEdges(), and clang::LexicallyOrderedRecursiveASTVisitor< Derived >::TraverseDeclContextHelper().
Returns true if the file contents have been overridden.
Definition at line 922 of file SourceManager.h.
Referenced by disableFileContentsOverride(), and clang::ASTReader::resolvePendingMacro().
|
inline |
Returns if a SourceLocation is in an "extern C" system header.
Definition at line 1458 of file SourceManager.h.
References clang::SrcMgr::C_ExternCSystem.
|
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 1486 of file SourceManager.h.
Referenced by clang::Lexer::getImmediateMacroName(), clang::Lexer::getSourceText(), isAtEndOfImmediateMacroExpansion(), isPreprocessedEntityIfInFileID(), makeRangeFromFileLocs(), clang::CoverageSourceInfo::SourceRangeSkipped(), and translateLineCol().
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 1515 of file SourceManager.cpp.
References getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), getSLocEntry(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SrcMgr::SLocEntry::isFile(), and clang::SourceLocation::isInvalid().
Referenced by clang::CodeGen::CodeGenPGO::assignRegionCounters(), CheckUnreachable(), clang::Preprocessor::getModuleForLocation(), clang::Preprocessor::getModuleHeaderToIncludeForDiagnostics(), isConfigurationPattern(), clang::ento::AnalysisManager::isInCodeFile(), clang::diff::isNodeExcluded(), clang::Preprocessor::LookupFile(), and printLocation().
|
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 1322 of file SourceManager.h.
References isInMainFile().
Referenced by updateConsecutiveMacroArgTokens().
|
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 1297 of file SourceManager.h.
Referenced by clang::TokenLexer::isParsingPreprocessorDirective().
|
inline |
Returns if a SourceLocation is in a system header.
Definition at line 1453 of file SourceManager.h.
References clang::SrcMgr::isSystem().
Referenced by clang::Sema::ActOnComment(), clang::ASTContext::addComment(), clang::CodeGen::CodeGenPGO::assignRegionCounters(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::checkInitMethod(), clang::Preprocessor::CheckMacroName(), clang::Sema::CheckVirtualDtorCall(), DiagnoseNamespaceInlineMismatch(), EmitDiagForCXXThrowInNonThrowingFunc(), clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(), clang::index::generateUSRForMacro(), clang::Preprocessor::getModuleMacro(), clang::ento::MemRegionManager::getVarRegion(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), isCXXSharedPtrDtor(), clang::ento::CallEvent::isInSystemHeader(), clang::Sema::isLibstdcxxEagerExceptionSpecHack(), isLibstdcxxPointerReturnFalseHack(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::Preprocessor::LookUpIdentifierInfo(), clang::Sema::makeUnavailableInSystemHeader(), clang::Sema::maybeAddCUDAHostDeviceAttrs(), clang::edit::Commit::replaceText(), shouldIgnoreDueToReservedName(), and toLevel().
|
inline |
Returns whether Loc
is expanded from a macro in a system header.
Definition at line 1463 of file SourceManager.h.
References clang::SourceLocation::isMacroID().
Referenced by AnalyzeCompoundAssignment(), and clang::Sema::diagnoseZeroToNullptrConversion().
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 2072 of file SourceManager.cpp.
References clang::InBeforeInTUCacheEntry::clear(), clang::InBeforeInTUCacheEntry::getCachedResult(), clang::InBeforeInTUCacheEntry::isCacheValid(), MoveUpIncludeHierarchy(), clang::InBeforeInTUCacheEntry::setCommonLoc(), and clang::InBeforeInTUCacheEntry::setQueryFIDs().
Referenced by compareCrossTUSourceLocs(), and isBeforeInTranslationUnit().
Returns true if FID
came from a PCH/Module.
Definition at line 1696 of file SourceManager.h.
Referenced by clang::Preprocessor::EnterMainSourceFile(), and clang::VerifyDiagnosticConsumer::HandleDiagnostic().
|
inline |
Returns true if Loc
came from a PCH/Module.
Definition at line 1686 of file SourceManager.h.
Returns true if FID
did not come from a PCH/Module.
Definition at line 1702 of file SourceManager.h.
|
inline |
Returns true if Loc
did not come from a PCH/Module.
Definition at line 1691 of file SourceManager.h.
Referenced by clang::ASTUnit::addFileLevelDecl(), clang::ASTWriter::getDeclID(), and clang::PreprocessingRecord::isEntityInFileID().
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 1019 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
Referenced by checkLocForMacroArgExpansion(), clang::Lexer::GetBeginningOfToken(), getBufferData(), clang::Lexer::getImmediateMacroNameForDiagnostics(), getMacroArgExpansionFileIDs(), clang::ASTContext::getRawCommentForDeclNoCache(), getStrlenExprArg(), getTopMacroCallerLoc(), isFunctionMacroExpansion(), retrieveMacroLocation(), and clang::JSONNodeDumper::Visit().
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 1032 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroBodyExpansion(), and clang::SourceLocation::isMacroID().
Referenced by IsInAnyMacroBody(), and isOriginMacroBody().
|
inline |
Return true if the Point is within Start and End.
Definition at line 1615 of file SourceManager.h.
|
inline |
Returns whether Loc
is located in a <built-in> file.
Definition at line 1435 of file SourceManager.h.
References Filename.
Referenced by FindLocsWithCommonFileID(), and clang::ASTImporter::Import().
|
inline |
Returns whether Loc
is located in a <command line>=""> file.
Definition at line 1441 of file SourceManager.h.
References Filename.
|
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 1430 of file SourceManager.h.
Referenced by clang::CreateModernObjCRewriter(), clang::CreateObjCRewriter(), IsFromSameFile(), isInMainFile(), and clang::RewriteMacrosInInput().
|
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 1422 of file SourceManager.h.
Referenced by IsFromSameFile(), removePunyEdges(), and updateConsecutiveMacroArgTokens().
|
inline |
Returns whether Loc
is located in a <scratch space>=""> file.
Definition at line 1447 of file SourceManager.h.
References Filename.
|
inline |
Get the number of loaded SLocEntries we have.
Definition at line 1648 of file SourceManager.h.
Referenced by translateFile().
|
inline |
Get the number of local SLocEntries we have.
Definition at line 1638 of file SourceManager.h.
Referenced by AllocateLoadedSLocEntries(), emitBlob(), getFileIDSize(), clang::PreprocessorLexer::PreprocessorLexer(), translateFile(), and translateLineCol().
|
delete |
void SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
llvm::MemoryBuffer * | Buffer, | ||
bool | DoNotFree | ||
) |
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. |
DoNotFree | If true, then the buffer will not be freed when the source manager is destroyed. |
Definition at line 652 of file SourceManager.cpp.
Referenced by InitializeFileRemapping(), and clang::CompilerInstance::InitializeSourceManager().
|
inline |
Definition at line 907 of file SourceManager.h.
void SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
const FileEntry * | 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 664 of file SourceManager.cpp.
References clang::FileEntry::getSize().
void SourceManager::PrintStats | ( | ) | const |
Print statistics to stderr.
Definition at line 2126 of file SourceManager.cpp.
References fileinfo_begin(), and fileinfo_end().
Referenced by clang::FrontendAction::EndSourceFile().
|
inline |
Push an entry to the module build stack.
Definition at line 785 of file SourceManager.h.
Referenced by compileModuleImpl(), and prepareToBuildModule().
|
inline |
Specify that all files that are read during this compilation are transient.
Definition at line 944 of file SourceManager.h.
Referenced by clang::FrontendAction::BeginSourceFile().
|
inline |
Definition at line 1670 of file SourceManager.h.
void SourceManager::setFileIsTransient | ( | const FileEntry * | SourceFile | ) |
Specify that a file is transient.
Definition at line 688 of file SourceManager.cpp.
Referenced by clang::FrontendAction::BeginSourceFile().
|
inline |
Set the file ID for the main source file.
Definition at line 797 of file SourceManager.h.
Referenced by clang::CompilerInstance::InitializeSourceManager(), and clang::ento::ModelInjector::ModelInjector().
|
inline |
Set the module build stack.
Definition at line 779 of file SourceManager.h.
Referenced by compileModuleImpl().
|
inline |
Set the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 1029 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
|
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 765 of file SourceManager.h.
Referenced by InitializeFileRemapping().
|
inline |
Set the file ID for the precompiled preamble.
Definition at line 802 of file SourceManager.h.
References clang::FileID::isInvalid().
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 1595 of file SourceManager.cpp.
References getActualFileUID(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getLoadedSLocEntry(), getLocalSLocEntry(), clang::FileEntry::getName(), getSLocEntry(), clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), clang::FileID::isValid(), loaded_sloc_entry_size(), local_sloc_entry_size(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by translateFileLineCol().
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 1581 of file SourceManager.cpp.
References translateFile(), and translateLineCol().
Referenced by clang::ASTUnit::getLocation().
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 1710 of file SourceManager.cpp.
References ComputeLineNumbers(), clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), clang::SrcMgr::SLocEntry::getFile(), getFileIDSize(), clang::SrcMgr::FileInfo::getIncludeLoc(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), i, clang::SrcMgr::SLocEntry::isFile(), clang::SourceLocation::isFileID(), isInFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::FileID::isValid(), local_sloc_entry_size(), clang::SrcMgr::ContentCache::NumLines, and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by buildFixItInsertionLine(), and translateFileLineCol().
|
inline |
True if non-system source files should be treated as volatile (likely to change while trying to use them).
Definition at line 771 of file SourceManager.h.
Referenced by clang::SrcMgr::ContentCache::getBuffer().
|
friend |
Definition at line 1726 of file SourceManager.h.
|
friend |
Definition at line 1727 of file SourceManager.h.