clang API Documentation
This class handles loading and caching of source files into memory. More...
#include <SourceManager.h>
Classes | |
struct | MemoryBufferSizes |
struct | OverriddenFilesInfoTy |
Public Types | |
typedef llvm::DenseMap< const FileEntry *, SrcMgr::ContentCache * > ::const_iterator | fileinfo_iterator |
Public Member Functions | |
SourceManager (DiagnosticsEngine &Diag, FileManager &FileMgr, bool UserFilesAreVolatile=false) | |
~SourceManager () | |
void | clearIDTables () |
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. Defaults to true. | |
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. | |
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 (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. | |
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. | |
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. | |
SourceLocation | createExpansionLoc (SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, 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. | |
llvm::MemoryBuffer * | getMemoryBufferForFile (const FileEntry *File, bool *Invalid=nullptr) |
Retrieve the memory buffer associated with the given file. | |
void | overrideFileContents (const FileEntry *SourceFile, llvm::MemoryBuffer *Buffer, bool DoNotFree) |
Override the contents of the given source file by providing an already-allocated buffer. | |
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. | |
bool | isFileOverridden (const FileEntry *File) |
Returns true if the file contents have been overridden. | |
void | disableFileContentsOverride (const FileEntry *File) |
Disable overridding the contents of a file, previously enabled with overrideFileContents. | |
llvm::MemoryBuffer * | getBuffer (FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const |
Return the buffer for the specified FileID. | |
llvm::MemoryBuffer * | getBuffer (FileID FID, bool *Invalid=nullptr) const |
const FileEntry * | getFileEntryForID (FileID FID) const |
Returns the FileEntry record for the provided FileID. | |
const FileEntry * | getFileEntryForSLocEntry (const SrcMgr::SLocEntry &sloc) 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. | |
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) const |
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. | |
std::pair< SourceLocation, SourceLocation > | getImmediateExpansionRange (SourceLocation Loc) const |
Return the start/end of the expansion information for an expansion location. | |
std::pair< SourceLocation, SourceLocation > | getExpansionRange (SourceLocation Loc) const |
Given a SourceLocation object, return the range of tokens covered by the expansion 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. | |
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) 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, unsigned *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, int *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 |
const char * | 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 | 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) |
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) |
Add a line note to the line table for the FileID and offset specified by Loc. | |
void | AddLineNote (SourceLocation Loc, unsigned LineNo, int FilenameID, bool IsFileEntry, bool IsFileExit, bool IsSystemHeader, bool IsExternCHeader) |
AddLineNote - Add a GNU line marker to the line table. | |
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. | |
SourceLocation | translateLineCol (FileID FID, unsigned Line, unsigned Col) const |
Get the source location in FID for the given line:col. Returns null location if FID is not a file SLocEntry. | |
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. 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. | |
bool | isBeforeInTranslationUnit (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the translation unit. | |
bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation RHS) const |
Determines the order of 2 source locations in the "source location
address space". | |
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". | |
fileinfo_iterator | fileinfo_begin () const |
fileinfo_iterator | fileinfo_end () const |
bool | hasFileInfo (const FileEntry *File) const |
void | PrintStats () const |
Print statistics to stderr. | |
unsigned | local_sloc_entry_size () const |
Get the number of local SLocEntries we have. | |
const SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index, bool *Invalid=nullptr) const |
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. | |
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. | |
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 |
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 553 of file SourceManager.h.
typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::const_iterator clang::SourceManager::fileinfo_iterator |
Definition at line 1463 of file SourceManager.h.
SourceManager::SourceManager | ( | DiagnosticsEngine & | Diag, |
FileManager & | FileMgr, | ||
bool | UserFilesAreVolatile = false |
||
) |
Definition at line 372 of file SourceManager.cpp.
References clearIDTables(), and clang::DiagnosticsEngine::setSourceManager().
Definition at line 382 of file SourceManager.cpp.
void SourceManager::AddLineNote | ( | SourceLocation | Loc, |
unsigned | LineNo, | ||
int | FilenameID | ||
) |
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.
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 297 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
void SourceManager::AddLineNote | ( | SourceLocation | Loc, |
unsigned | LineNo, | ||
int | FilenameID, | ||
bool | IsFileEntry, | ||
bool | IsFileExit, | ||
bool | IsSystemHeader, | ||
bool | IsExternCHeader | ||
) |
AddLineNote - Add a GNU line marker to the line table.
Definition at line 317 of file SourceManager.cpp.
References clang::SrcMgr::C_ExternCSystem, clang::SrcMgr::C_System, clang::SrcMgr::C_User, clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::SLocEntry::isFile().
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 490 of file SourceManager.cpp.
void SourceManager::clearIDTables | ( | ) |
Definition at line 405 of file SourceManager.cpp.
References clang::LineTableInfo::clear(), and createExpansionLoc().
Referenced by clang::CompilerInstance::ExecuteAction(), and SourceManager().
SourceLocation SourceManager::createExpansionLoc | ( | SourceLocation | Loc, |
SourceLocation | ExpansionLocStart, | ||
SourceLocation | ExpansionLocEnd, | ||
unsigned | TokLength, | ||
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 608 of file SourceManager.cpp.
References clang::serialized_diags::create().
Referenced by clearIDTables(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::CreateString(), clang::TokenLexer::Init(), clang::TokenLexer::Lex(), and clang::ASTReader::ReadSLocEntry().
FileID clang::SourceManager::createFileID | ( | const FileEntry * | SourceFile, |
SourceLocation | IncludePos, | ||
SrcMgr::CharacteristicKind | FileCharacter, | ||
int | LoadedID = 0 , |
||
unsigned | LoadedOffset = 0 |
||
) | [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 777 of file SourceManager.h.
References clang::SrcMgr::C_User.
Referenced by clang::tooling::Replacement::apply(), clang::tooling::applyAllReplacements(), applyEditsToTemp(), ConvertBackendLocation(), createFileID(), clang::index::SimpleFormatContext::createInMemoryFile(), clang::Preprocessor::EnterMainSourceFile(), clang::ASTImporter::Import(), clang::CompilerInstance::InitializeSourceManager(), ParseDirective(), clang::ModuleMap::parseModuleMapFile(), clang::ASTReader::ReadSLocEntry(), and clang::format::reformat().
FileID clang::SourceManager::createFileID | ( | std::unique_ptr< llvm::MemoryBuffer > | Buffer, |
SrcMgr::CharacteristicKind | FileCharacter = SrcMgr::C_User , |
||
int | LoadedID = 0 , |
||
unsigned | LoadedOffset = 0 , |
||
SourceLocation | IncludeLoc = SourceLocation() |
||
) | [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 791 of file SourceManager.h.
References createFileID().
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 599 of file SourceManager.cpp.
Referenced by updateConsecutiveMacroArgTokens().
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 672 of file SourceManager.cpp.
References isFileOverridden(), and clang::SrcMgr::ContentCache::OrigEntry.
fileinfo_iterator clang::SourceManager::fileinfo_begin | ( | ) | const [inline] |
Definition at line 1464 of file SourceManager.h.
Referenced by PrintStats().
fileinfo_iterator clang::SourceManager::fileinfo_end | ( | ) | const [inline] |
Definition at line 1465 of file SourceManager.h.
Referenced by PrintStats().
llvm::MemoryBuffer* clang::SourceManager::getBuffer | ( | FileID | FID, |
SourceLocation | Loc, | ||
bool * | Invalid = nullptr |
||
) | const [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 876 of file SourceManager.h.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::html::AddLineNumbers(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::EnterSourceFile(), clang::html::EscapeText(), clang::CodeGenAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), findDirectives(), getBufferName(), getColumnNumber(), getLengthOnSingleLine(), clang::html::HighlightMacros(), isBeforeInTranslationUnit(), LexRawTokensFromMainFile(), clang::ModuleMap::parseModuleMapFile(), clang::RewriteIncludesInInput(), clang::html::SyntaxHighlight(), and clang::TokenRewriter::TokenRewriter().
llvm::MemoryBuffer* clang::SourceManager::getBuffer | ( | FileID | FID, |
bool * | Invalid = nullptr |
||
) | const [inline] |
Definition at line 891 of file SourceManager.h.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
StringRef SourceManager::getBufferData | ( | FileID | FID, |
bool * | Invalid = nullptr |
||
) | const |
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 685 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::arcmt::trans::MigrationContext::addPropertyAttribute(), adjustRemoval(), clang::Lexer::findLocationAfterToken(), clang::arcmt::trans::findSemiAfterLocation(), getBeginningOfFileToken(), clang::Rewriter::getEditBuffer(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), clang::StringLiteral::getLocationOfByte(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::comments::Lexer::getSpelling(), clang::html::HighlightRange(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), LocPropertyAttribute(), onlyWhitespaceBetween(), clang::Rewriter::ReplaceText(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
const char * 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.
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 1432 of file SourceManager.cpp.
References getBuffer(), getFileID(), and isInvalid().
Referenced by clang::CodeGen::CodeGenModule::EmitAnnotationUnit(), and clang::Preprocessor::EnterSourceFile().
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.
Invalid | If non-NULL, will be set true if an error occurs. |
getCharacterData - Return a pointer to the start of the specified location in the appropriate MemoryBuffer.
Definition at line 1098 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::Lexer::AdvanceToTokenCharacter(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::DumpToken(), clang::Lexer::findLocationAfterToken(), GetFirstChar(), clang::Rewriter::getRewrittenText(), clang::Lexer::getSpelling(), clang::Preprocessor::getSpellingOfSingleCharacterNumericConstant(), and clang::VerifyDiagnosticConsumer::HandleComment().
unsigned SourceManager::getColumnNumber | ( | FileID | FID, |
unsigned | FilePos, | ||
bool * | Invalid = nullptr |
||
) | const |
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.
getColumnNumber - Return the column # for the specified file position. this is significantly cheaper to compute than the line number.
Definition at line 1123 of file SourceManager.cpp.
References getBuffer(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by buildFixItInsertionLine(), clang::TextDiagnostic::emitDiagnosticLoc(), getExpansionColumnNumber(), getPresumedLoc(), and getSpellingColumnNumber().
size_t clang::SourceManager::getContentCacheSize | ( | ) | const [inline] |
Return the total amount of physical memory allocated by the ContentCache allocator.
Definition at line 1383 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 2153 of file SourceManager.cpp.
std::pair<FileID, unsigned> clang::SourceManager::getDecomposedExpansionLoc | ( | SourceLocation | Loc | ) | const [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 1103 of file SourceManager.h.
References getFileID(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and clang::SourceLocation::isFileID().
Referenced by buildFixItInsertionLine(), getExpansionColumnNumber(), getExpansionLineNumber(), getFileCharacteristic(), getPresumedLoc(), isInMainFile(), and ReadLineMarkerFlags().
std::pair< FileID, unsigned > SourceManager::getDecomposedIncludedLoc | ( | FileID | FID | ) | const |
Returns the "included/expanded in" decomposed location of the given FileID.
Definition at line 1952 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().
std::pair<FileID, unsigned> clang::SourceManager::getDecomposedLoc | ( | SourceLocation | Loc | ) | const [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 1089 of file SourceManager.h.
References getFileID(), clang::SrcMgr::SLocEntry::getOffset(), and getSLocEntry().
Referenced by clang::ASTUnit::addFileLevelDecl(), clang::arcmt::trans::MigrationContext::addPropertyAttribute(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::Lexer::findLocationAfterToken(), clang::arcmt::trans::findSemiAfterLocation(), getBeginningOfFileToken(), clang::Lexer::GetBeginningOfToken(), getDecomposedIncludedLoc(), getFileOffset(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), getImmediateSpellingLoc(), clang::StringLiteral::getLocationOfByte(), getMacroArgExpandedLocation(), clang::tooling::getRangeSize(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::comments::Lexer::getSpelling(), clang::ASTImporter::Import(), isAtStartOfImmediateMacroExpansion(), isBeforeInTranslationUnit(), LocPropertyAttribute(), makeRangeFromFileLocs(), onlyWhitespaceBetween(), printLoc(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
std::pair<FileID, unsigned> clang::SourceManager::getDecomposedSpellingLoc | ( | SourceLocation | Loc | ) | const [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 1122 of file SourceManager.h.
References getFileID(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and clang::SourceLocation::isFileID().
Referenced by getCharacterData(), getSpellingColumnNumber(), and getSpellingLineNumber().
DiagnosticsEngine& clang::SourceManager::getDiagnostics | ( | ) | const [inline] |
Definition at line 717 of file SourceManager.h.
Referenced by clang::ASTContext::getDiagnostics(), and ParseDirective().
unsigned SourceManager::getExpansionColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1175 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedExpansionLoc(), and isInvalid().
Referenced by llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), highlightRange(), and llvm::DOTGraphTraits< ExplodedNode * >::printLocation().
unsigned SourceManager::getExpansionLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1381 of file SourceManager.cpp.
References getDecomposedExpansionLoc(), getLineNumber(), and isInvalid().
Referenced by clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), highlightRange(), and llvm::DOTGraphTraits< ExplodedNode * >::printLocation().
SourceLocation clang::SourceManager::getExpansionLoc | ( | SourceLocation | Loc | ) | const [inline] |
Given a SourceLocation object Loc
, return the expansion location referenced by the ID.
Definition at line 1037 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnUsingDirective(), clang::markup::AddFID(), CompactPathDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::markup::EmitLocation(), clang::CodeGen::CGDebugInfo::EmitLocation(), clang::Sema::findMacroSpelling(), clang::markup::GetFID(), getLengthOnSingleLine(), clang::ASTContext::getRawCommentForDeclNoCache(), clang::Lexer::getRawToken(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), handleObjCOwnershipTypeAttr(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::html::HighlightMacros(), clang::html::HighlightRange(), clang::TokenLexer::Init(), clang::SourceLocation::print(), printLoc(), clang::RewriteMacrosInInput(), and clang::CodeGen::CGDebugInfo::setLocation().
std::pair< SourceLocation, SourceLocation > SourceManager::getExpansionRange | ( | SourceLocation | Loc | ) | const |
Given a SourceLocation object, return the range of tokens covered by the expansion the ultimate file.
getExpansionRange - Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file.
Definition at line 989 of file SourceManager.cpp.
References getImmediateExpansionRange(), and clang::SourceLocation::isFileID().
Referenced by clang::TextDiagnostic::emitDiagnosticLoc(), getLengthOnSingleLine(), and clang::html::HighlightMacros().
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:
# 4 "foo.h" 3
which changes all source locations in the current file after that to be considered to be from a 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: # 4 "foo.h" 3 which changes all source locations in the current file after that to be considered to be from a system header.
Definition at line 1402 of file SourceManager.cpp.
References clang::SrcMgr::C_User, clang::LineEntry::FileKind, clang::LineTableInfo::FindNearestLineEntry(), getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getFileCharacteristic(), getSLocEntry(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::SrcMgr::SLocEntry::isFile(), and clang::SourceLocation::isInvalid().
Referenced by clang::Preprocessor::HandleEndOfFile(), isInExternCSystemHeader(), and isInSystemHeader().
const FileEntry* clang::SourceManager::getFileEntryForID | ( | FileID | FID | ) | const [inline] |
Returns the FileEntry record for the provided FileID.
Definition at line 907 of file SourceManager.h.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), clang::SrcMgr::SLocEntry::isFile(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::arcmt::MigrationProcess::applyTransform(), clang::CacheTokens(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::Preprocessor::EnterMainSourceFile(), clang::Preprocessor::EnterSourceFile(), clang::CodeGenAction::ExecuteAction(), clang::ModuleMap::getContainingModuleMapFile(), clang::PreprocessorLexer::getFileEntry(), getFilename(), getImmediateMacroName(), clang::ASTUnit::getMainFileName(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::Preprocessor::HandleEndOfFile(), clang::ModuleMap::inferModuleFromLocation(), IsFromSameFile(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), clang::Preprocessor::LookupFile(), clang::Rewriter::overwriteChangedFiles(), printLoc(), PrintUnexpected(), clang::Preprocessor::SetCodeCompletionPoint(), clang::VerifyDiagnosticConsumer::UpdateParsedFileStatus(), clang::arcmt::writeARCDiagsToPlist(), and clang::FixItRewriter::WriteFixedFiles().
const FileEntry* clang::SourceManager::getFileEntryForSLocEntry | ( | const SrcMgr::SLocEntry & | sloc | ) | const [inline] |
Returns the FileEntry record for the provided SLocEntry.
Definition at line 920 of file SourceManager.h.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::ContentCache::OrigEntry.
FileID clang::SourceManager::getFileID | ( | SourceLocation | SpellingLoc | ) | const [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 968 of file SourceManager.h.
Referenced by clang::markup::AddFID(), clang::tooling::Replacement::apply(), checkConfigMacro(), checkObjCUnusedIvar(), clang::Lexer::Create_PragmaLexer(), clang::TextDiagnostic::emitDiagnosticLoc(), getBufferName(), clang::ModuleMap::getContainingModuleMapFile(), getDecomposedExpansionLoc(), getDecomposedLoc(), getDecomposedSpellingLoc(), clang::markup::GetFID(), getFilename(), getImmediateExpansionRange(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), getLengthOnSingleLine(), getModuleImportLoc(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::html::HighlightMacros(), clang::html::HighlightRange(), highlightRange(), clang::ModuleMap::inferModuleFromLocation(), isAtEndOfImmediateMacroExpansion(), IsFromSameFile(), isMacroArgExpansion(), isMacroBodyExpansion(), isWrittenInMainFile(), isWrittenInSameFile(), clang::Lexer::makeFileCharRange(), mapDiagnosticRanges(), ParseDirective(), PrintUnexpected(), clang::format::reformat(), Scan(), and shouldIgnoreMacro().
unsigned SourceManager::getFileIDSize | ( | FileID | FID | ) | const |
The size of the SLocEntry that FID
represents.
Definition at line 1542 of file SourceManager.cpp.
References getNextLocalOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and local_sloc_entry_size().
Referenced by getLocForEndOfFile().
SourceLocation clang::SourceManager::getFileLoc | ( | SourceLocation | Loc | ) | const [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 1047 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::ASTUnit::addFileLevelDecl(), getLocForEndOfFile(), getLocForStartOfFile(), clang::SanitizerBlacklist::isBlacklistedLocation(), isPreprocessedEntityIfInFileID(), clang::ASTReader::isPreprocessedEntityInFileID(), makeStandaloneDiagnostic(), and translateLineCol().
FileManager& clang::SourceManager::getFileManager | ( | ) | const [inline] |
Definition at line 719 of file SourceManager.h.
Referenced by clang::tooling::Replacement::apply(), clang::SrcMgr::ContentCache::getBuffer(), clang::ModuleMap::inferFrameworkModule(), clang::ModuleMap::isHeaderUnavailableInModule(), and clang::ModuleMap::parseModuleMapFile().
StringRef clang::SourceManager::getFilename | ( | SourceLocation | SpellingLoc | ) | const [inline] |
Return the filename of the file containing a SourceLocation.
Definition at line 979 of file SourceManager.h.
References getFileEntryForID(), and getFileID().
Referenced by clang::ento::LikelyFalsePositiveSuppressionBRVisitor::getEndPath(), clang::SanitizerBlacklist::isBlacklistedLocation(), makeStandaloneDiagnostic(), and PrintExpected().
unsigned clang::SourceManager::getFileOffset | ( | SourceLocation | SpellingLoc | ) | const [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 1143 of file SourceManager.h.
References getDecomposedLoc().
Referenced by getLengthOnSingleLine(), clang::html::HighlightRange(), makeStandaloneDiagnostic(), makeStandaloneRange(), clang::RewriteMacrosInInput(), and clang::html::SyntaxHighlight().
std::pair< SourceLocation, SourceLocation > SourceManager::getImmediateExpansionRange | ( | SourceLocation | Loc | ) | const |
Return the start/end of the expansion information for an expansion location.
Loc
is required to be an expansion location.getImmediateExpansionRange - Loc is required to be an expansion location. Return the start/end of the expansion information.
Definition at line 980 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocRange(), getFileID(), getSLocEntry(), and clang::SourceLocation::isMacroID().
Referenced by clang::edit::EditedSource::canInsertInOffset(), checkAllAtProps(), clang::Sema::DiagnoseAbsenceOfOverrideControl(), getExpansionRange(), GetFullTypeForDeclarator(), getImmediateMacroCallerLoc(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), handleObjCOwnershipTypeAttr(), and mapDiagnosticRanges().
SourceLocation clang::SourceManager::getImmediateMacroCallerLoc | ( | SourceLocation | Loc | ) | const [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 1545 of file SourceManager.h.
References getImmediateExpansionRange(), getImmediateSpellingLoc(), isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
Referenced by getTopMostMacro(), IsFromSameFile(), and IsInAnyMacroBody().
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.
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 969 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), and clang::SourceLocation::isFileID().
Referenced by getImmediateMacroCallerLoc(), clang::Lexer::makeFileCharRange(), and mapDiagnosticRanges().
SourceLocation clang::SourceManager::getIncludeLoc | ( | FileID | FID | ) | const [inline] |
Returns the include location if FID
is a #include'd file otherwise it returns an invalid location.
Definition at line 1011 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getIncludeLoc(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Preprocessor::HandleEndOfFile(), and clang::ModuleMap::inferModuleFromLocation().
unsigned SourceManager::getLineNumber | ( | FileID | FID, |
unsigned | FilePos, | ||
bool * | Invalid = nullptr |
||
) | const |
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.
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 1281 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(), clang::TextDiagnostic::emitDiagnosticLoc(), getExpansionLineNumber(), getPresumedLoc(), clang::ASTContext::getRawCommentForDeclNoCache(), getSpellingLineNumber(), clang::Rewriter::IncreaseIndentation(), and clang::Rewriter::InsertText().
Retrieve the stored line table.
Definition at line 362 of file SourceManager.cpp.
unsigned SourceManager::getLineTableFilenameID | ( | StringRef | Name | ) |
Return the uniqued ID for the specified filename.
getLineTableFilenameID - Return the uniqued ID for the specified filename.
Definition at line 287 of file SourceManager.cpp.
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
const SrcMgr::SLocEntry& clang::SourceManager::getLoadedSLocEntry | ( | unsigned | Index, |
bool * | Invalid = nullptr |
||
) | const [inline] |
Get a loaded SLocEntry. This is exposed for indexing.
Definition at line 1488 of file SourceManager.h.
Referenced by translateFile().
const SrcMgr::SLocEntry& clang::SourceManager::getLocalSLocEntry | ( | unsigned | Index, |
bool * | Invalid = nullptr |
||
) | const [inline] |
Get a local SLocEntry. This is exposed for indexing.
Definition at line 1478 of file SourceManager.h.
Referenced by translateFile().
SourceLocation clang::SourceManager::getLocForEndOfFile | ( | FileID | FID | ) | const [inline] |
Return the source location corresponding to the last byte of the specified file.
Definition at line 999 of file SourceManager.h.
References getFileIDSize(), getFileLoc(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::ASTUnit::getEndOfPreambleFileID().
SourceLocation clang::SourceManager::getLocForStartOfFile | ( | FileID | FID | ) | const [inline] |
Return the source location corresponding to the first byte of the specified file.
Definition at line 987 of file SourceManager.h.
References getFileLoc(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::html::AddHeaderFooterInternalBuiltinCSS(), clang::arcmt::trans::MigrationContext::addPropertyAttribute(), clang::tooling::Replacement::apply(), applyEditsToTemp(), applyRewrite(), ConvertBackendLocation(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::EnterSourceFile(), clang::ASTReader::FindFileRegionDecls(), clang::Lexer::findLocationAfterToken(), clang::arcmt::trans::findSemiAfterLocation(), clang::edit::Commit::Edit::getFileLocation(), clang::edit::Commit::Edit::getInsertFromRange(), clang::StringLiteral::getLocationOfByte(), getPresumedLoc(), clang::Lexer::getRawToken(), clang::ASTUnit::PreambleData::getSourceRange(), clang::Lexer::getSpelling(), clang::ASTUnit::getStartOfMainFileID(), clang::Preprocessor::HandleEndOfFile(), clang::ASTImporter::Import(), LocPropertyAttribute(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), clang::PTHLexer::PTHLexer(), clang::format::reformat(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
If Loc
points inside a function macro argument, the returned location will be the macro location in which the argument was expanded. 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.
If.
Definition at line 1925 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SourceLocation::getLocWithOffset(), clang::SourceLocation::isFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), and clang::SourceLocation::isValid().
Referenced by clang::ASTUnit::getLocation().
FileID clang::SourceManager::getMainFileID | ( | ) | const [inline] |
Returns the FileID of the main source file.
Definition at line 753 of file SourceManager.h.
Referenced by clang::CacheTokens(), clang::DoRewriteTest(), clang::Preprocessor::EnterMainSourceFile(), clang::CodeGenAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), clang::ASTUnit::getMainFileName(), clang::ASTUnit::getStartOfMainFileID(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::Preprocessor::HandleEndOfFile(), clang::CompilerInstance::InitializeSourceManager(), clang::ASTUnit::isInMainFileID(), clang::CodeGen::CodeGenModule::isInSanitizerBlacklist(), isWrittenInMainFile(), LexRawTokensFromMainFile(), clang::Preprocessor::LookupFile(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), clang::RewriteIncludesInInput(), clang::RewriteMacrosInInput(), and clang::Preprocessor::SetCodeCompletionPoint().
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 642 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBuffer().
Referenced by clang::Preprocessor::SetCodeCompletionPoint().
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory.
Definition at line 2135 of file SourceManager.cpp.
ModuleBuildStack clang::SourceManager::getModuleBuildStack | ( | ) | const [inline] |
Retrieve the module build stack.
Definition at line 733 of file SourceManager.h.
Referenced by clang::GenerateModuleAction::BeginSourceFileAction(), compileModuleImpl(), and clang::CompilerInstance::loadModule().
std::pair<SourceLocation, StringRef> clang::SourceManager::getModuleImportLoc | ( | SourceLocation | Loc | ) | const [inline] |
Definition at line 1024 of file SourceManager.h.
References getFileID(), and clang::ExternalSLocEntrySource::getModuleImportLoc().
unsigned clang::SourceManager::getNextLocalOffset | ( | ) | const [inline] |
Definition at line 1505 of file SourceManager.h.
Referenced by getFileIDSize(), and clang::TokenLexer::Init().
unsigned clang::SourceManager::getNumCreatedFIDsForFileID | ( | FileID | FID | ) | const [inline] |
Get the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 937 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
FileID clang::SourceManager::getPreambleFileID | ( | ) | const [inline] |
Get the file ID for the precompiled preamble if there is one.
Definition at line 767 of file SourceManager.h.
Referenced by clang::ASTUnit::getEndOfPreambleFileID(), clang::ASTUnit::PreambleData::getSourceRange(), clang::ASTUnit::isInPreambleFileID(), clang::ASTUnit::mapLocationFromPreamble(), and clang::ASTUnit::mapLocationToPreamble().
unsigned SourceManager::getPresumedColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1182 of file SourceManager.cpp.
References clang::PresumedLoc::getColumn(), getPresumedLoc(), and isInvalid().
Referenced by clang::Sema::DiagnoseEmptyLoopBody().
unsigned SourceManager::getPresumedLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1387 of file SourceManager.cpp.
References clang::PresumedLoc::getLine(), getPresumedLoc(), and isInvalid().
Referenced by clang::comments::Sema::actOnHTMLEndTag(), CheckLists(), clang::comments::Parser::parseHTMLStartTag(), PrintExpected(), and PrintUnexpected().
PresumedLoc SourceManager::getPresumedLoc | ( | SourceLocation | Loc, |
bool | UseLineDirectives = true |
||
) | const |
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.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.
Definition at line 1447 of file SourceManager.cpp.
References AttributeLangSupport::C, clang::LineTableInfo::FindNearestLineEntry(), clang::SrcMgr::ContentCache::getBuffer(), getColumnNumber(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::LineTableInfo::getFilename(), 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::DoPrintPreprocessedInput(), clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), clang::CodeGen::CodeGenModule::EmitAnnotationUnit(), clang::CodeGen::CodeGenFunction::EmitCheckSourceLocation(), clang::CodeGen::EmitOpenMPUpdateLocation(), getPresumedColumnNumber(), getPresumedLineNumber(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::Preprocessor::HandlePragmaSystemHeader(), clang::SourceLocation::print(), ReadLineMarkerFlags(), and clang::CodeGen::CGDebugInfo::setLocation().
const SrcMgr::SLocEntry& clang::SourceManager::getSLocEntry | ( | FileID | FID, |
bool * | Invalid = nullptr |
||
) | const [inline] |
Definition at line 1496 of file SourceManager.h.
Referenced by getBuffer(), getBufferData(), getCharacterData(), getDecomposedExpansionLoc(), getDecomposedIncludedLoc(), getDecomposedLoc(), getDecomposedSpellingLoc(), getFileCharacteristic(), getFileEntryForID(), getFileIDSize(), getImmediateExpansionRange(), clang::Lexer::getImmediateMacroName(), getImmediateSpellingLoc(), getIncludeLoc(), getLineNumber(), getLocForEndOfFile(), getLocForStartOfFile(), getNumCreatedFIDsForFileID(), getPresumedLoc(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), isAtEndOfImmediateMacroExpansion(), isAtStartOfImmediateMacroExpansion(), isInFileID(), isInMainFile(), isMacroArgExpansion(), isMacroBodyExpansion(), clang::Lexer::makeFileCharRange(), clang::ASTReader::ReadSLocEntry(), setNumCreatedFIDsForFileID(), translateFile(), and translateLineCol().
unsigned SourceManager::getSpellingColumnNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1168 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedSpellingLoc(), and isInvalid().
Referenced by clang::format::ContinuationIndenter::addTokenToState().
unsigned SourceManager::getSpellingLineNumber | ( | SourceLocation | Loc, |
bool * | Invalid = nullptr |
||
) | const |
Definition at line 1375 of file SourceManager.cpp.
References getDecomposedSpellingLoc(), getLineNumber(), and isInvalid().
Referenced by ParseDirective().
SourceLocation clang::SourceManager::getSpellingLoc | ( | SourceLocation | Loc | ) | const [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 1070 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::TokenConcatenation::AvoidConcat(), clang::Sema::DiagnoseAbsenceOfOverrideControl(), clang::Lexer::GetBeginningOfToken(), GetFirstChar(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), clang::StringLiteral::getLocationOfByte(), clang::tooling::getRangeSize(), clang::ASTImporter::Import(), clang::Lexer::isAtEndOfMacroExpansion(), isInSystemMacro(), mapDiagnosticRanges(), and clang::SourceLocation::print().
bool clang::SourceManager::hasFileInfo | ( | const FileEntry * | File | ) | const [inline] |
Definition at line 1466 of file SourceManager.h.
Referenced by clang::Preprocessor::HandleEndOfFile().
bool clang::SourceManager::hasLineTable | ( | ) | const [inline] |
Determine if the source manager has a line table.
Definition at line 1372 of file SourceManager.h.
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 1055 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 1020 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 clang::Lexer::isAtStartOfMacroExpansion().
bool clang::SourceManager::isBeforeInSLocAddrSpace | ( | SourceLocation | LHS, |
SourceLocation | RHS | ||
) | const [inline] |
Determines the order of 2 source locations in the "source location address space".
Definition at line 1443 of file SourceManager.h.
Referenced by clang::TokenLexer::Lex().
bool clang::SourceManager::isBeforeInSLocAddrSpace | ( | SourceLocation | LHS, |
unsigned | RHS | ||
) | const [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 1451 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 2025 of file SourceManager.cpp.
References clang::InBeforeInTUCacheEntry::clear(), getBuffer(), clang::InBeforeInTUCacheEntry::getCachedResult(), getDecomposedLoc(), clang::InBeforeInTUCacheEntry::isCacheValid(), clang::SourceLocation::isValid(), MoveUpIncludeHierarchy(), clang::InBeforeInTUCacheEntry::setCommonLoc(), and clang::InBeforeInTUCacheEntry::setQueryFIDs().
Referenced by clang::RawCommentList::addComment(), clang::PreprocessingRecord::addPreprocessedEntity(), compare(), comparePiece(), clang::Sema::diagnoseIgnoredQualifiers(), diagnoseRepeatedUseOfWeak(), clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(), clang::MacroDirective::findDirectiveAtLoc(), clang::ASTReader::findPreprocessedEntitiesInRange(), clang::DeclSpec::Finish(), clang::Preprocessor::getLastMacroWithSpelling(), clang::FunctionDecl::getReturnTypeSourceRange(), clang::Sema::getUndefinedButUsed(), clang::PPConditionalDirectiveRecord::CondDirectiveLoc::Comp::operator()(), clang::format::WhitespaceManager::Change::IsBeforeInFile::operator()(), clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(), and removePunyEdges().
bool clang::SourceManager::isFileOverridden | ( | const FileEntry * | File | ) | [inline] |
Returns true if the file contents have been overridden.
Definition at line 851 of file SourceManager.h.
Referenced by disableFileContentsOverride().
bool clang::SourceManager::isInExternCSystemHeader | ( | SourceLocation | Loc | ) | const [inline] |
Returns if a SourceLocation is in an "extern C" system header.
Definition at line 1327 of file SourceManager.h.
References clang::SrcMgr::C_ExternCSystem, and getFileCharacteristic().
bool clang::SourceManager::isInFileID | ( | SourceLocation | Loc, |
FileID | FID, | ||
unsigned * | RelativeOffset = nullptr |
||
) | const [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 1342 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), and getSLocEntry().
Referenced by clang::Lexer::getImmediateMacroName(), clang::Lexer::getSourceText(), isAtEndOfImmediateMacroExpansion(), clang::ASTUnit::isInMainFileID(), clang::ASTUnit::isInPreambleFileID(), isPreprocessedEntityIfInFileID(), clang::ASTReader::isPreprocessedEntityInFileID(), makeRangeFromFileLocs(), 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 1518 of file SourceManager.cpp.
References clang::LineTableInfo::FindNearestLineEntry(), 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::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnUsingDirective(), clang::CodeGen::CodeGenPGO::assignRegionCounters(), clang::ObjCMethodCall::canBeOverridenInSubclass(), CheckUnreachable(), diagnoseUseOfInternalDeclInInlineFunction(), getFirstStackedCallToHeaderFile(), isMainFileLoc(), and mayInlineDecl().
bool clang::SourceManager::isInSameSLocAddrSpace | ( | SourceLocation | LHS, |
SourceLocation | RHS, | ||
int * | RelativeOffset | ||
) | const [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 1209 of file SourceManager.h.
Referenced by isEmptyARCMTMacroStatement(), and updateConsecutiveMacroArgTokens().
bool clang::SourceManager::isInSLocAddrSpace | ( | SourceLocation | Loc, |
SourceLocation | Start, | ||
unsigned | Length, | ||
unsigned * | RelativeOffset = nullptr |
||
) | const [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 1184 of file SourceManager.h.
bool clang::SourceManager::isInSystemHeader | ( | SourceLocation | Loc | ) | const [inline] |
Returns if a SourceLocation is in a system header.
Definition at line 1322 of file SourceManager.h.
References clang::SrcMgr::C_User, and getFileCharacteristic().
Referenced by clang::Sema::ActOnAtEnd(), clang::Sema::ActOnComment(), clang::ASTContext::addComment(), areDefinedInSystemModules(), clang::Sema::BuildCXXNew(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::checkInitMethod(), clang::Sema::DiagnoseAbsenceOfOverrideControl(), DiagnoseNamespaceInlineMismatch(), clang::CodeGen::CodeGenPGO::emitEmptyCounterMapping(), clang::index::generateUSRForMacro(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), isForbiddenTypeAllowed(), clang::ento::CallEvent::isInSystemHeader(), isInSystemMacro(), clang::Sema::isLibstdcxxEagerExceptionSpecHack(), isLibstdcxxPointerReturnFalseHack(), clang::Sema::makeUnavailableInSystemHeader(), mayInlineDecl(), clang::Sema::MergeTypedefNameDecl(), and clang::Sema::ParseObjCSelectorExpression().
bool clang::SourceManager::isInSystemMacro | ( | SourceLocation | loc | ) | [inline] |
Returns whether Loc
is expanded from a macro in a system header.
Definition at line 1332 of file SourceManager.h.
References getSpellingLoc(), isInSystemHeader(), and clang::SourceLocation::isMacroID().
Referenced by clang::Sema::DiagnoseUnusedExprResult().
bool clang::SourceManager::isLoadedFileID | ( | FileID | FID | ) | const [inline] |
Returns true if FID
came from a PCH/Module.
Definition at line 1533 of file SourceManager.h.
Referenced by clang::Preprocessor::EnterMainSourceFile(), clang::ASTUnit::findFileRegionDecls(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), and isLocalFileID().
bool clang::SourceManager::isLoadedSourceLocation | ( | SourceLocation | Loc | ) | const [inline] |
Returns true if Loc
came from a PCH/Module.
Definition at line 1523 of file SourceManager.h.
bool clang::SourceManager::isLocalFileID | ( | FileID | FID | ) | const [inline] |
Returns true if FID
did not come from a PCH/Module.
Definition at line 1539 of file SourceManager.h.
References isLoadedFileID().
bool clang::SourceManager::isLocalSourceLocation | ( | SourceLocation | Loc | ) | const [inline] |
Returns true if Loc
did not come from a PCH/Module.
Definition at line 1528 of file SourceManager.h.
Referenced by clang::ASTUnit::addFileLevelDecl().
bool SourceManager::isMacroArgExpansion | ( | SourceLocation | Loc | ) | const |
Tests whether the given source location represents a macro argument's expansion into the function-like macro definition.
Such source locations only appear inside of the expansion locations representing where a particular function-like macro was expanded.
Definition at line 1004 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
Referenced by clang::edit::EditedSource::canInsertInOffset(), clang::Lexer::GetBeginningOfToken(), getImmediateMacroCallerLoc(), getImmediateMacroName(), clang::ASTContext::getRawCommentForDeclNoCache(), and mapDiagnosticRanges().
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 1012 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroBodyExpansion(), and clang::SourceLocation::isMacroID().
Referenced by DiagnoseUnusedComparison(), clang::Sema::DiagnoseUnusedExprResult(), and IsInAnyMacroBody().
bool clang::SourceManager::isWrittenInMainFile | ( | SourceLocation | Loc | ) | const [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 1317 of file SourceManager.h.
References getFileID(), and getMainFileID().
Referenced by IsFromSameFile(), and clang::RewriteMacrosInInput().
bool clang::SourceManager::isWrittenInSameFile | ( | SourceLocation | Loc1, |
SourceLocation | Loc2 | ||
) | const [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 1309 of file SourceManager.h.
References getFileID().
Referenced by IsFromSameFile(), and removePunyEdges().
unsigned clang::SourceManager::loaded_sloc_entry_size | ( | ) | const [inline] |
Get the number of loaded SLocEntries we have.
Definition at line 1485 of file SourceManager.h.
Referenced by translateFile().
unsigned clang::SourceManager::local_sloc_entry_size | ( | ) | const [inline] |
Get the number of local SLocEntries we have.
Definition at line 1475 of file SourceManager.h.
Referenced by getFileIDSize(), clang::Preprocessor::HandleEndOfFile(), clang::PreprocessorLexer::PreprocessorLexer(), and translateFile().
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 649 of file SourceManager.cpp.
Referenced by clang::tooling::applyAllReplacements(), compileModuleImpl(), clang::index::SimpleFormatContext::createInMemoryFile(), InitializeFileRemapping(), clang::CompilerInstance::InitializeSourceManager(), overrideFileContents(), clang::ASTReader::ReadSLocEntry(), clang::format::reformat(), and clang::Preprocessor::SetCodeCompletionPoint().
void clang::SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
std::unique_ptr< llvm::MemoryBuffer > | Buffer | ||
) | [inline] |
Definition at line 836 of file SourceManager.h.
References overrideFileContents().
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 661 of file SourceManager.cpp.
References clang::FileEntry::getSize().
void SourceManager::PrintStats | ( | ) | const |
Print statistics to stderr.
Definition at line 2103 of file SourceManager.cpp.
References fileinfo_begin(), and fileinfo_end().
Referenced by clang::FrontendAction::EndSourceFile().
void clang::SourceManager::pushModuleBuildStack | ( | StringRef | moduleName, |
FullSourceLoc | importLoc | ||
) | [inline] |
Push an entry to the module build stack.
Definition at line 744 of file SourceManager.h.
Referenced by clang::GenerateModuleAction::BeginSourceFileAction(), and compileModuleImpl().
void clang::SourceManager::setExternalSLocEntrySource | ( | ExternalSLocEntrySource * | Source | ) | [inline] |
Definition at line 1507 of file SourceManager.h.
Referenced by clang::ASTReader::ASTReader().
void clang::SourceManager::setMainFileID | ( | FileID | FID | ) | [inline] |
Set the file ID for the main source file.
Definition at line 756 of file SourceManager.h.
Referenced by clang::CompilerInstance::InitializeSourceManager(), and clang::ASTReader::ReadAST().
void clang::SourceManager::setModuleBuildStack | ( | ModuleBuildStack | stack | ) | [inline] |
Set the module build stack.
Definition at line 738 of file SourceManager.h.
Referenced by compileModuleImpl().
void clang::SourceManager::setNumCreatedFIDsForFileID | ( | FileID | FID, |
unsigned | NumFIDs | ||
) | const [inline] |
Set the number of FileIDs (files and macros) that were created during preprocessing of FID
, including it.
Definition at line 948 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Preprocessor::HandleEndOfFile().
void clang::SourceManager::setOverridenFilesKeepOriginalName | ( | bool | value | ) | [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 724 of file SourceManager.h.
Referenced by InitializeFileRemapping().
void clang::SourceManager::setPreambleFileID | ( | FileID | Preamble | ) | [inline] |
Set the file ID for the precompiled preamble.
Definition at line 761 of file SourceManager.h.
References clang::FileID::isInvalid().
Referenced by clang::ASTReader::ReadAST().
FileID SourceManager::translateFile | ( | const FileEntry * | SourceFile | ) | const |
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 1598 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(), loaded_sloc_entry_size(), local_sloc_entry_size(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by ParseDirective(), and 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 1584 of file SourceManager.cpp.
References translateFile(), and translateLineCol().
Referenced by clang::tooling::Replacement::apply(), clang::CodeGenAction::ExecuteAction(), clang::ASTUnit::getLocation(), and ParseDirective().
SourceLocation SourceManager::translateLineCol | ( | FileID | FID, |
unsigned | Line, | ||
unsigned | Col | ||
) | const |
Get the source location in FID
for the given line:col. Returns null location if FID
is not a file SLocEntry.
Get the source location in.
Definition at line 1713 of file SourceManager.cpp.
References ComputeLineNumbers(), clang::SrcMgr::ContentCache::getBuffer(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getFileLoc(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), clang::SrcMgr::ContentCache::NumLines, and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by ParseDirective(), and translateFileLineCol().
bool clang::SourceManager::userFilesAreVolatile | ( | ) | const [inline] |
True if non-system source files should be treated as volatile (likely to change while trying to use them).
Definition at line 730 of file SourceManager.h.
Referenced by clang::SrcMgr::ContentCache::getBuffer().
friend class ASTReader [friend] |
Definition at line 1651 of file SourceManager.h.
friend class ASTWriter [friend] |
Definition at line 1652 of file SourceManager.h.