clang: clang::SourceManager Class Reference (original) (raw)
This class handles loading and caching of source files into memory. More...
#include "[clang/Basic/SourceManager.h](SourceManager%5F8h%5Fsource.html)"
| Public Types | |
|---|---|
| using | fileinfo_iterator |
| Public Member Functions | |
|---|---|
| SourceManager (DiagnosticsEngine &Diag, FileManager &FileMgr, bool UserFilesAreVolatile=false) | |
| SourceManager (const SourceManager &)=delete | |
| SourceManager & | operator= (const SourceManager &)=delete |
| ~SourceManager () | |
| void | clearIDTables () |
| void | initializeForReplay (const SourceManager &Old) |
| Initialize this source manager suitably to replay the compilation described by Old. | |
| DiagnosticsEngine & | getDiagnostics () const |
| FileManager & | getFileManager () const |
| void | setOverridenFilesKeepOriginalName (bool value) |
| Set true if the SourceManager should report the original file name for contents of files that were overridden by other files. | |
| bool | userFilesAreVolatile () const |
| True if non-system source files should be treated as volatile (likely to change while trying to use them). | |
| ModuleBuildStack | getModuleBuildStack () const |
| Retrieve the module build stack. | |
| void | setModuleBuildStack (ModuleBuildStack stack) |
| Set the module build stack. | |
| void | pushModuleBuildStack (StringRef moduleName, FullSourceLoc importLoc) |
| Push an entry to the module build stack. | |
| FileID | getMainFileID () const |
| Returns the FileID of the main source file. | |
| void | setMainFileID (FileID FID) |
| Set the file ID for the main source file. | |
| bool | isMainFile (const FileEntry &SourceFile) |
| Returns true when the given FileEntry corresponds to the main file. | |
| void | setPreambleFileID (FileID Preamble) |
| Set the file ID for the precompiled preamble. | |
| FileID | getPreambleFileID () const |
| Get the file ID for the precompiled preamble if there is one. | |
| FileID | createFileID (FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0) |
| Create a new FileID that represents the specified file being #included from the specified IncludePosition. | |
| FileID | createFileID (std::unique_ptr< llvm::MemoryBuffer > Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
| Create a new FileID that represents the specified memory buffer. | |
| FileID | createFileID (const llvm::MemoryBufferRef &Buffer, SrcMgr::CharacteristicKind FileCharacter=SrcMgr::C_User, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
| Create a new FileID that represents the specified memory buffer. | |
| FileID | getOrCreateFileID (FileEntryRef SourceFile, SrcMgr::CharacteristicKind FileCharacter) |
| Get the FileID for SourceFile if it exists. | |
| SourceLocation | createMacroArgExpansionLoc (SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length) |
| Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body. | |
| SourceLocation | createExpansionLoc (SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0) |
| Creates an expansion SLocEntry for a macro use. | |
| SourceLocation | createTokenSplitLoc (SourceLocation SpellingLoc, SourceLocation TokenStart, SourceLocation TokenEnd) |
| Return a new SourceLocation that encodes that the token starting at TokenStart ends prematurely at TokenEnd. | |
| std::optional< llvm::MemoryBufferRef > | getMemoryBufferForFileOrNone (FileEntryRef File) |
| Retrieve the memory buffer associated with the given file. | |
| llvm::MemoryBufferRef | getMemoryBufferForFileOrFake (FileEntryRef File) |
| Retrieve the memory buffer associated with the given file. | |
| void | overrideFileContents (FileEntryRef SourceFile, const llvm::MemoryBufferRef &Buffer) |
| Override the contents of the given source file by providing an already-allocated buffer. | |
| void | overrideFileContents (FileEntryRef SourceFile, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
| Override the contents of the given source file by providing an already-allocated buffer. | |
| void | overrideFileContents (const FileEntry *SourceFile, FileEntryRef NewFile) |
| Override the given source file with another one. | |
| bool | isFileOverridden (const FileEntry *File) const |
| Returns true if the file contents have been overridden. | |
| OptionalFileEntryRef | bypassFileContentsOverride (FileEntryRef File) |
| Bypass the overridden contents of a file. | |
| void | setFileIsTransient (FileEntryRef SourceFile) |
| Specify that a file is transient. | |
| void | setAllFilesAreTransient (bool Transient) |
| Specify that all files that are read during this compilation are transient. | |
| std::optional< llvm::MemoryBufferRef > | getBufferOrNone (FileID FID, SourceLocation Loc=SourceLocation()) const |
| Return the buffer for the specified FileID. | |
| llvm::MemoryBufferRef | getBufferOrFake (FileID FID, SourceLocation Loc=SourceLocation()) const |
| Return the buffer for the specified FileID. | |
| const FileEntry * | getFileEntryForID (FileID FID) const |
| Returns the FileEntry record for the provided FileID. | |
| OptionalFileEntryRef | getFileEntryRefForID (FileID FID) const |
| Returns the FileEntryRef for the provided FileID. | |
| std::optional< StringRef > | getNonBuiltinFilenameForID (FileID FID) const |
| Returns the filename for the provided FileID, unless it's a built-in buffer that's not represented by a filename. | |
| const FileEntry * | getFileEntryForSLocEntry (const SrcMgr::SLocEntry &SLocEntry) const |
| Returns the FileEntry record for the provided SLocEntry. | |
| StringRef | getBufferData (FileID FID, bool *Invalid=nullptr) const |
| Return a StringRef to the source buffer data for the specified FileID. | |
| std::optional< StringRef > | getBufferDataOrNone (FileID FID) const |
| Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if invalid. | |
| std::optional< StringRef > | getBufferDataIfLoaded (FileID FID) const |
| Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if it's not yet loaded. | |
| unsigned | getNumCreatedFIDsForFileID (FileID FID) const |
| Get the number of FileIDs (files and macros) that were created during preprocessing of FID, including it. | |
| void | setNumCreatedFIDsForFileID (FileID FID, unsigned NumFIDs, bool Force=false) |
| Set the number of FileIDs (files and macros) that were created during preprocessing of FID, including it. | |
| FileID | getFileID (SourceLocation SpellingLoc) const |
| Return the FileID for a SourceLocation. | |
| StringRef | getFilename (SourceLocation SpellingLoc) const |
| Return the filename of the file containing a SourceLocation. | |
| SourceLocation | getLocForStartOfFile (FileID FID) const |
| Return the source location corresponding to the first byte of the specified file. | |
| SourceLocation | getLocForEndOfFile (FileID FID) const |
| Return the source location corresponding to the last byte of the specified file. | |
| SourceLocation | getIncludeLoc (FileID FID) const |
| Returns the include location if FID is a #include'd file otherwise it returns an invalid location. | |
| std::pair< SourceLocation, StringRef > | getModuleImportLoc (SourceLocation Loc) const |
| SourceLocation | getExpansionLoc (SourceLocation Loc) const |
| Given a SourceLocation object Loc, return the expansion location referenced by the ID. | |
| SourceLocation | getFileLoc (SourceLocation Loc) const |
| Given Loc, if it is a macro location return the expansion location or the spelling location, depending on if it comes from a macro argument or not. | |
| CharSourceRange | getImmediateExpansionRange (SourceLocation Loc) const |
| Return the start/end of the expansion information for an expansion location. | |
| CharSourceRange | getExpansionRange (SourceLocation Loc) const |
| Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate file. | |
| CharSourceRange | getExpansionRange (SourceRange Range) const |
| Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. | |
| CharSourceRange | getExpansionRange (CharSourceRange Range) const |
| Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in the ultimate file. | |
| SourceLocation | getSpellingLoc (SourceLocation Loc) const |
| Given a SourceLocation object, return the spelling location referenced by the ID. | |
| SourceLocation | getImmediateSpellingLoc (SourceLocation Loc) const |
| Given a SourceLocation object, return the spelling location referenced by the ID. | |
| SourceLocation | getComposedLoc (FileID FID, unsigned Offset) const |
| Form a SourceLocation from a FileID and Offset pair. | |
| FileIDAndOffset | getDecomposedLoc (SourceLocation Loc) const |
| Decompose the specified location into a raw FileID + Offset pair. | |
| FileIDAndOffset | getDecomposedExpansionLoc (SourceLocation Loc) const |
| Decompose the specified location into a raw FileID + Offset pair. | |
| FileIDAndOffset | getDecomposedSpellingLoc (SourceLocation Loc) const |
| Decompose the specified location into a raw FileID + Offset pair. | |
| FileIDAndOffset | getDecomposedIncludedLoc (FileID FID) const |
| Returns the "included/expanded in" decomposed location of the given FileID. | |
| unsigned | getFileOffset (SourceLocation SpellingLoc) const |
| Returns the offset from the start of the file that the specified SourceLocation represents. | |
| bool | isMacroArgExpansion (SourceLocation Loc, SourceLocation *StartLoc=nullptr) const |
| Tests whether the given source location represents a macro argument's expansion into the function-like macro definition. | |
| bool | isMacroBodyExpansion (SourceLocation Loc) const |
| Tests whether the given source location represents the expansion of a macro body. | |
| bool | isAtStartOfImmediateMacroExpansion (SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const |
| Returns true if the given MacroID location points at the beginning of the immediate macro expansion. | |
| bool | isAtEndOfImmediateMacroExpansion (SourceLocation Loc, SourceLocation *MacroEnd=nullptr) const |
| Returns true if the given MacroID location points at the character end of the immediate macro expansion. | |
| bool | isInSLocAddrSpace (SourceLocation Loc, SourceLocation Start, unsigned Length, SourceLocation::UIntTy *RelativeOffset=nullptr) const |
| Returns true if Loc is inside the [Start, +Length) chunk of the source location address space. | |
| bool | isInSameSLocAddrSpace (SourceLocation LHS, SourceLocation RHS, SourceLocation::IntTy *RelativeOffset) const |
| Return true if both LHS and RHS are in the local source location address space or the loaded one. | |
| const char * | getCharacterData (SourceLocation SL, bool *Invalid=nullptr) const |
| Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer. | |
| unsigned | getColumnNumber (FileID FID, unsigned FilePos, bool *Invalid=nullptr) const |
| Return the column # for the specified file position. | |
| unsigned | getColumnNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
| 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 | getLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
| unsigned | getSpellingLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
| unsigned | getExpansionLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
| unsigned | getPresumedLineNumber (SourceLocation Loc, bool *Invalid=nullptr) const |
| StringRef | getBufferName (SourceLocation Loc, bool *Invalid=nullptr) const |
| Return the filename or buffer identifier of the buffer the location is in. | |
| SrcMgr::CharacteristicKind | getFileCharacteristic (SourceLocation Loc) const |
| Return the file characteristic of the specified source location, indicating whether this is a normal file, a system header, or an "implicit extern C" system header. | |
| PresumedLoc | getPresumedLoc (SourceLocation Loc, bool UseLineDirectives=true) const |
| Returns the "presumed" location of a SourceLocation specifies. | |
| bool | isInMainFile (SourceLocation Loc) const |
| Returns whether the [PresumedLoc](classclang%5F1%5F1PresumedLoc.html "Represents an unpacked "presumed" location which can be presented to the user.") for a given SourceLocation is in the main file. | |
| bool | isWrittenInSameFile (SourceLocation Loc1, SourceLocation Loc2) const |
| Returns true if the spelling locations for both SourceLocations are part of the same file buffer. | |
| bool | isWrittenInMainFile (SourceLocation Loc) const |
| Returns true if the spelling location for the given location is in the main file buffer. | |
| bool | isWrittenInBuiltinFile (SourceLocation Loc) const |
| Returns whether Loc is located in a file. | |
| bool | isWrittenInCommandLineFile (SourceLocation Loc) const |
| Returns whether Loc is located in a file. | |
| bool | isWrittenInScratchSpace (SourceLocation Loc) const |
| Returns whether Loc is located in a file. | |
| bool | isInPredefinedFile (SourceLocation Loc) const |
| Returns whether Loc is located in a built-in or command line source. | |
| bool | isInSystemHeader (SourceLocation Loc) const |
| Returns if a SourceLocation is in a system header. | |
| bool | isInExternCSystemHeader (SourceLocation Loc) const |
| Returns if a SourceLocation is in an "extern C" system header. | |
| bool | isInSystemMacro (SourceLocation loc) const |
| Returns whether Loc is expanded from a macro in a system header. | |
| unsigned | getFileIDSize (FileID FID) const |
| The size of the SLocEntry that FID represents. | |
| bool | isInFileID (SourceLocation Loc, FileID FID, unsigned *RelativeOffset=nullptr) const |
| Given a specific FileID, returns true if Loc is inside that FileID chunk and sets relative offset (offset of Loc from beginning of FileID) to relativeOffset. | |
| unsigned | getLineTableFilenameID (StringRef Str) |
| Return the uniqued ID for the specified filename. | |
| void | AddLineNote (SourceLocation Loc, unsigned LineNo, int FilenameID, bool IsFileEntry, bool IsFileExit, SrcMgr::CharacteristicKind FileKind) |
| Add a line note to the line table for the FileID and offset specified by Loc. | |
| bool | hasLineTable () const |
| Determine if the source manager has a line table. | |
| LineTableInfo & | getLineTable () |
| Retrieve the stored line table. | |
| size_t | getContentCacheSize () const |
| Return the total amount of physical memory allocated by the ContentCache allocator. | |
| MemoryBufferSizes | getMemoryBufferSizes () const |
| Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory. | |
| size_t | getDataStructureSizes () const |
| Return the amount of memory used for various side tables and data structures in the SourceManager. | |
| SourceLocation | translateFileLineCol (const FileEntry *SourceFile, unsigned Line, unsigned Col) const |
| Get the source location for the given file:line:col triplet. | |
| FileID | translateFile (const FileEntry *SourceFile) const |
| Get the FileID for the given file. | |
| FileID | translateFile (FileEntryRef SourceFile) const |
| SourceLocation | translateLineCol (FileID FID, unsigned Line, unsigned Col) const |
| Get the source location in FID for the given line:col. | |
| SourceLocation | getMacroArgExpandedLocation (SourceLocation Loc) const |
| If Loc points inside a function macro argument, the returned location will be the macro location in which the argument was expanded. | |
| bool | isBeforeInTranslationUnit (SourceLocation LHS, SourceLocation RHS) const |
| Determines the order of 2 source locations in the translation unit. | |
| std::pair< bool, bool > | isInTheSameTranslationUnit (FileIDAndOffset &LOffs, FileIDAndOffset &ROffs) const |
| Determines whether the two decomposed source location is in the same translation unit. | |
| FileID | getUniqueLoadedASTFileID (SourceLocation Loc) const |
| bool | isInTheSameTranslationUnitImpl (const FileIDAndOffset &LOffs, const FileIDAndOffset &ROffs) const |
| Determines whether the two decomposed source location is in the same TU. | |
| bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation RHS) const |
| Determines the order of 2 source locations in the "source location address space". | |
| bool | isBeforeInSLocAddrSpace (SourceLocation LHS, SourceLocation::UIntTy RHS) const |
| Determines the order of a source location and a source location offset in the "source location address space". | |
| bool | isPointWithin (SourceLocation Location, SourceLocation Start, SourceLocation End) const |
| Return true if the Point is within Start and End. | |
| fileinfo_iterator | fileinfo_begin () const |
| fileinfo_iterator | fileinfo_end () const |
| bool | hasFileInfo (const FileEntry *File) const |
| void | PrintStats () const |
| Print statistics to stderr. | |
| void | dump () const |
| void | noteSLocAddressSpaceUsage (DiagnosticsEngine &Diag, std::optional< unsigned > MaxNotes=32) const |
| unsigned | local_sloc_entry_size () const |
| Get the number of local SLocEntries we have. | |
| const SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index) const |
| Get a local SLocEntry. This is exposed for indexing. | |
| SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index) |
| Get a local SLocEntry. This is exposed for indexing. | |
| unsigned | loaded_sloc_entry_size () const |
| Get the number of loaded SLocEntries we have. | |
| const SrcMgr::SLocEntry & | getLoadedSLocEntry (unsigned Index, bool *Invalid=nullptr) const |
| Get a loaded SLocEntry. This is exposed for indexing. | |
| SrcMgr::SLocEntry & | getLoadedSLocEntry (unsigned Index, bool *Invalid=nullptr) |
| Get a loaded SLocEntry. This is exposed for indexing. | |
| const SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=nullptr) const |
| SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=nullptr) |
| SourceLocation::UIntTy | getNextLocalOffset () const |
| void | setExternalSLocEntrySource (ExternalSLocEntrySource *Source) |
| std::pair< int, SourceLocation::UIntTy > | AllocateLoadedSLocEntries (unsigned NumSLocEntries, SourceLocation::UIntTy TotalSize) |
| Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external source. | |
| bool | isLoadedSourceLocation (SourceLocation Loc) const |
| Returns true if Loc came from a PCH/Module. | |
| bool | isLocalSourceLocation (SourceLocation Loc) const |
| Returns true if Loc did not come from a PCH/Module. | |
| bool | isLoadedFileID (FileID FID) const |
| Returns true if FID came from a PCH/Module. | |
| bool | isLocalFileID (FileID FID) const |
| Returns true if FID did not come from a PCH/Module. | |
| SourceLocation | getImmediateMacroCallerLoc (SourceLocation Loc) const |
| Gets the location of the immediate macro caller, one level up the stack toward the initial macro typed into the source. | |
| SourceLocation | getTopMacroCallerLoc (SourceLocation Loc) const |
| Friends | |
|---|---|
| class | ASTReader |
| class | ASTWriter |
This class handles loading and caching of source files into memory.
This object owns the MemoryBuffer objects for all of the loaded files and assigns unique FileID's for each unique #include chain.
The SourceManager can be queried for information about SourceLocation objects, turning them into either spelling or expansion locations. Spelling locations represent where the bytes corresponding to a token came from and expansion locations represent where the location is in the user's view. In the case of a macro expansion, for example, the spelling location indicates where the expanded token came from and the expansion location specifies where it was expanded.
Definition at line 663 of file SourceManager.h.
◆ fileinfo_iterator
Initial value:
llvm::DenseMap<FileEntryRef, SrcMgr::ContentCache *>::const_iterator
Definition at line 1724 of file SourceManager.h.
◆ SourceManager() [2/2]
| clang::SourceManager::SourceManager ( const SourceManager & ) | explicitdelete |
|---|
◆ ~SourceManager()
| SourceManager::~SourceManager | ( | ) |
|---|
◆ AddLineNote()
◆ AllocateLoadedSLocEntries()
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 457 of file SourceManager.cpp.
References int.
◆ bypassFileContentsOverride()
◆ clearIDTables()
| void SourceManager::clearIDTables | ( | ) |
|---|
◆ createExpansionLoc()
◆ createFileID() [1/3]
◆ createFileID() [2/3]
◆ createFileID() [3/3]
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 559 of file SourceManager.cpp.
◆ createMacroArgExpansionLoc()
◆ createTokenSplitLoc()
◆ dump()
| LLVM_DUMP_METHOD void SourceManager::dump | ( | ) | const |
|---|
◆ fileinfo_begin()
| fileinfo_iterator clang::SourceManager::fileinfo_begin ( ) const | inline |
|---|
◆ fileinfo_end()
| fileinfo_iterator clang::SourceManager::fileinfo_end ( ) const | inline |
|---|
◆ getBufferData()
| StringRef SourceManager::getBufferData | ( | FileID | FID, |
|---|---|---|---|
| bool * | Invalid = nullptr ) const |
◆ getBufferDataIfLoaded()
| std::optional< StringRef > SourceManager::getBufferDataIfLoaded | ( | FileID | FID | ) | const |
|---|
◆ getBufferDataOrNone()
| std::optional< StringRef > SourceManager::getBufferDataOrNone | ( | FileID | FID | ) | const |
|---|
◆ getBufferName()
◆ getBufferOrFake()
◆ getBufferOrNone()
◆ getCharacterData()
◆ getColumnNumber() [1/2]
◆ getColumnNumber() [2/2]
◆ getComposedLoc()
◆ getContentCacheSize()
| size_t clang::SourceManager::getContentCacheSize ( ) const | inline |
|---|
Return the total amount of physical memory allocated by the ContentCache allocator.
Definition at line 1613 of file SourceManager.h.
◆ getDataStructureSizes()
| size_t SourceManager::getDataStructureSizes | ( | ) | const |
|---|
◆ getDecomposedExpansionLoc()
◆ getDecomposedIncludedLoc()
◆ getDecomposedLoc()
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 1276 of file SourceManager.h.
References getFileID().
Referenced by getColumnNumber(), getDecomposedExpansionLoc(), getDecomposedIncludedLoc(), getDecomposedSpellingLoc(), getFileOffset(), getImmediateSpellingLoc(), getLineNumber(), getMacroArgExpandedLocation(), getRangeSize(), getUniqueLoadedASTFileID(), clang::ASTImporter::Import(), isAtStartOfImmediateMacroExpansion(), isBeforeInTranslationUnit(), and loadModuleMapForModuleBuild().
◆ getDecomposedSpellingLoc()
◆ getDiagnostics()
◆ getExpansionColumnNumber()
◆ getExpansionLineNumber()
◆ getExpansionLoc()
◆ getExpansionRange() [1/3]
◆ getExpansionRange() [2/3]
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 966 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::SourceLocExpr::EvaluateInContext(), getExpansionRange(), and getExpansionRange().
◆ getExpansionRange() [3/3]
◆ 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.
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:
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 1387 of file SourceManager.cpp.
References clang::SrcMgr::C_User, clang::LineEntry::FileKind, getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), clang::SrcMgr::FileInfo::getFileCharacteristic(), clang::SrcMgr::FileInfo::hasLineDirectives(), and clang::SourceLocation::isValid().
Referenced by isInExternCSystemHeader(), and isInSystemHeader().
◆ getFileEntryForID()
| const FileEntry * clang::SourceManager::getFileEntryForID ( FileID FID) const | inline |
|---|
◆ getFileEntryForSLocEntry()
◆ getFileEntryRefForID()
◆ getFileID()
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 1149 of file SourceManager.h.
References getFileID().
Referenced by clang::Sema::ActOnAnnotModuleEnd(), clang::ast_matchers::AST_POLYMORPHIC_MATCHER_REGEX(), createTokenSplitLoc(), DiagnoseNullConversion(), EvaluateDefined(), getBufferName(), getDecomposedLoc(), getFileID(), getFilename(), getImmediateExpansionRange(), getModuleImportLoc(), getNullabilityCompletenessCheckFileID(), clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic(), clang::ASTImporter::Import(), isAtEndOfImmediateMacroExpansion(), isMacroArgExpansion(), isMacroBodyExpansion(), isWrittenInMainFile(), isWrittenInSameFile(), noteSLocAddressSpaceUsage(), shouldIgnoreMacro(), clang::syntax::spelledIdentifierTouching(), and clang::syntax::spelledTokensTouching().
◆ getFileIDSize()
◆ getFileLoc()
◆ getFileManager()
| FileManager & clang::SourceManager::getFileManager ( ) const | inline |
|---|
Definition at line 858 of file SourceManager.h.
Referenced by createFileID(), getBufferDataOrNone(), getBufferOrNone(), getCharacterData(), clang::ento::getConfiguration(), getLineNumber(), getMemoryBufferForFileOrNone(), getPresumedLoc(), clang::ASTImporter::Import(), clang::Rewriter::overwriteChangedFiles(), and translateLineCol().
◆ getFilename()
| StringRef SourceManager::getFilename | ( | SourceLocation | SpellingLoc | ) | const |
|---|
◆ getFileOffset()
◆ getImmediateExpansionRange()
◆ getImmediateMacroCallerLoc()
◆ getImmediateSpellingLoc()
◆ getIncludeLoc()
◆ getLineNumber() [1/2]
Given a SourceLocation, return the spelling line number for the position indicated.
getLineNumber - Given a SourceLocation, return the spelling line number for the position indicated.
This requires building and caching a table of line offsets for the MemoryBuffer, so this is not cheap: use only when about to emit a diagnostic.
Definition at line 1267 of file SourceManager.cpp.
References clang::SrcMgr::LineOffsetMapping::begin(), clang::SrcMgr::LineOffsetMapping::end(), clang::SrcMgr::LineOffsetMapping::get(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getFileManager(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by getExpansionLineNumber(), getLineNumber(), getPresumedLoc(), and getSpellingLineNumber().
◆ getLineNumber() [2/2]
◆ getLineTable()
◆ getLineTableFilenameID()
| 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 259 of file SourceManager.cpp.
References getLineTable().
◆ getLoadedSLocEntry() [1/2]
◆ getLoadedSLocEntry() [2/2]
◆ getLocalSLocEntry() [1/2]
◆ getLocalSLocEntry() [2/2]
◆ getLocForEndOfFile()
◆ getLocForStartOfFile()
◆ getMacroArgExpandedLocation()
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.
- 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.
Definition at line 1834 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SourceLocation::getLocWithOffset(), clang::SourceLocation::isFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), and clang::SourceLocation::isValid().
◆ getMainFileID()
| FileID clang::SourceManager::getMainFileID ( ) const | inline |
|---|
◆ getMemoryBufferForFileOrFake()
| llvm::MemoryBufferRef clang::SourceManager::getMemoryBufferForFileOrFake ( FileEntryRef File) | inline |
|---|
◆ getMemoryBufferForFileOrNone()
| std::optional< llvm::MemoryBufferRef > SourceManager::getMemoryBufferForFileOrNone | ( | FileEntryRef | File | ) |
|---|
◆ getMemoryBufferSizes()
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory.
Definition at line 2293 of file SourceManager.cpp.
◆ getModuleBuildStack()
◆ getModuleImportLoc()
◆ getNextLocalOffset()
◆ getNonBuiltinFilenameForID()
| std::optional< StringRef > SourceManager::getNonBuiltinFilenameForID | ( | FileID | FID | ) | const |
|---|
◆ getNumCreatedFIDsForFileID()
| 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 1122 of file SourceManager.h.
◆ getOrCreateFileID()
◆ getPreambleFileID()
| FileID clang::SourceManager::getPreambleFileID ( ) const | inline |
|---|
Get the file ID for the precompiled preamble if there is one.
Definition at line 911 of file SourceManager.h.
◆ getPresumedColumnNumber()
◆ getPresumedLineNumber()
◆ getPresumedLoc()
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.
Returns
The presumed location of the specified SourceLocation. If the presumed location cannot be calculated (e.g., because 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 1433 of file SourceManager.cpp.
References clang::C, getColumnNumber(), clang::SrcMgr::FileInfo::getContentCache(), getDecomposedExpansionLoc(), clang::SrcMgr::SLocEntry::getFile(), getFileManager(), clang::SrcMgr::FileInfo::getIncludeLoc(), getLineNumber(), getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::FileInfo::hasLineDirectives(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), and clang::SourceLocation::isInvalid().
Referenced by clang::CodeGen::CodeGenFunction::EmitCheckSourceLocation(), emitMappingInformation(), clang::CodeGen::CGOpenMPRuntime::emitUpdateLocation(), clang::SourceLocExpr::EvaluateInContext(), clang::AnalysisDeclContext::getFunctionName(), getIdentStringFromSourceLocation(), clang::CIRGen::CIRGenFunction::getLoc(), clang::CIRGen::CIRGenModule::getLoc(), getPresumedColumnNumber(), getPresumedLineNumber(), isInPredefinedFile(), isWrittenInBuiltinFile(), isWrittenInCommandLineFile(), and isWrittenInScratchSpace().
◆ getSLocEntry() [1/2]
◆ getSLocEntry() [2/2]
Definition at line 1775 of file SourceManager.h.
References getSLocEntry(), clang::Invalid, and SourceManager().
Referenced by AddLineNote(), EvaluateDefined(), getCharacterData(), getDecomposedIncludedLoc(), getFileIDSize(), getImmediateExpansionRange(), getImmediateSpellingLoc(), getLineNumber(), getNullabilityCompletenessCheckFileID(), getPresumedLoc(), getSLocEntry(), clang::ASTImporter::Import(), isAtEndOfImmediateMacroExpansion(), isAtStartOfImmediateMacroExpansion(), isInFileID(), isMacroArgExpansion(), isMacroBodyExpansion(), translateFile(), and translateLineCol().
◆ getSpellingColumnNumber()
◆ getSpellingLineNumber()
◆ getSpellingLoc()
◆ getTopMacroCallerLoc()
◆ getUniqueLoadedASTFileID()
◆ hasFileInfo()
| bool clang::SourceManager::hasFileInfo ( const FileEntry * File) const | inline |
|---|
◆ hasLineTable()
| bool clang::SourceManager::hasLineTable ( ) const | inline |
|---|
Determine if the source manager has a line table.
Definition at line 1602 of file SourceManager.h.
◆ initializeForReplay()
| void SourceManager::initializeForReplay | ( | const SourceManager & | Old | ) |
|---|
◆ isAtEndOfImmediateMacroExpansion()
Returns true if the given MacroID location points at the character end of the immediate macro expansion.
Parameters
| MacroEnd | If non-null and function returns true, it is set to the character end location of the immediate macro expansion. |
|---|
Definition at line 1040 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocEnd(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getFileID(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isExpansion(), isInFileID(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and clang::SourceLocation::isValid().
◆ isAtStartOfImmediateMacroExpansion()
Returns true if the given MacroID location points at the beginning of the immediate macro expansion.
Parameters
| MacroBegin | If non-null and function returns true, it is set to the begin location of the immediate macro expansion. |
|---|
Definition at line 1005 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocStart(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isExpansion(), clang::FileID::isInvalid(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), clang::SourceLocation::isMacroID(), and clang::SourceLocation::isValid().
Referenced by CheckMoveOnConstruction().
◆ isBeforeInSLocAddrSpace() [1/2]
◆ isBeforeInSLocAddrSpace() [2/2]
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 1704 of file SourceManager.h.
◆ isBeforeInTranslationUnit()
◆ isFileOverridden()
| bool clang::SourceManager::isFileOverridden ( const FileEntry * File) const | inline |
|---|
◆ isInExternCSystemHeader()
◆ isInFileID()
◆ isInMainFile()
◆ isInPredefinedFile()
◆ isInSameSLocAddrSpace()
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 1378 of file SourceManager.h.
Referenced by isInTheSameTranslationUnit().
◆ isInSLocAddrSpace()
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 1354 of file SourceManager.h.
◆ isInSystemHeader()
Returns if a SourceLocation is in a system header.
Definition at line 1539 of file SourceManager.h.
References getFileCharacteristic(), and clang::SourceLocation::isInvalid().
Referenced by clang::ast_matchers::AST_POLYMORPHIC_MATCHER(), CheckConstexprFunctionBody(), CheckSimplerImplicitMovesMSVCWorkaround(), DiagnoseBadConversion(), DiagReservedModuleName(), DoEmitAvailabilityWarning(), EmitDiagForCXXThrowInNonThrowingFunc(), isForbiddenTypeAllowed(), isInSystemMacro(), isStandardNew(), and shouldIgnoreDueToReservedName().
◆ isInSystemMacro()
◆ isInTheSameTranslationUnit()
◆ isInTheSameTranslationUnitImpl()
◆ isLoadedFileID()
| bool clang::SourceManager::isLoadedFileID ( FileID FID) const | inline |
|---|
◆ isLoadedSourceLocation()
◆ isLocalFileID()
| bool clang::SourceManager::isLocalFileID ( FileID FID) const | inline |
|---|
◆ isLocalSourceLocation()
Returns true if Loc did not come from a PCH/Module.
Definition at line 1812 of file SourceManager.h.
◆ isMacroArgExpansion()
◆ isMacroBodyExpansion()
◆ isMainFile()
◆ isPointWithin()
◆ isWrittenInBuiltinFile()
◆ isWrittenInCommandLineFile()
◆ isWrittenInMainFile()
◆ isWrittenInSameFile()
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 1490 of file SourceManager.h.
References getFileID().
◆ isWrittenInScratchSpace()
◆ loaded_sloc_entry_size()
| unsigned clang::SourceManager::loaded_sloc_entry_size ( ) const | inline |
|---|
◆ local_sloc_entry_size()
| unsigned clang::SourceManager::local_sloc_entry_size ( ) const | inline |
|---|
◆ noteSLocAddressSpaceUsage()
◆ operator=()
◆ overrideFileContents() [1/3]
◆ overrideFileContents() [2/3]
| void clang::SourceManager::overrideFileContents ( FileEntryRef SourceFile, const llvm::MemoryBufferRef & Buffer ) | inline |
|---|
Override the contents of the given source file by providing an already-allocated buffer.
Parameters
| SourceFile | the source file whose contents will be overridden. |
|---|---|
| Buffer | the memory buffer whose contents will be used as the data in the given source file. |
Definition at line 996 of file SourceManager.h.
References overrideFileContents().
Referenced by overrideFileContents().
◆ overrideFileContents() [3/3]
| void SourceManager::overrideFileContents | ( | FileEntryRef | SourceFile, |
|---|---|---|---|
| std::unique_ptr< llvm::MemoryBuffer > | Buffer ) |
◆ PrintStats()
| void SourceManager::PrintStats | ( | ) | const |
|---|
◆ pushModuleBuildStack()
| void clang::SourceManager::pushModuleBuildStack ( StringRef moduleName, FullSourceLoc importLoc ) | inline |
|---|
◆ setAllFilesAreTransient()
| void clang::SourceManager::setAllFilesAreTransient ( bool Transient) | inline |
|---|
◆ setExternalSLocEntrySource()
◆ setFileIsTransient()
| void SourceManager::setFileIsTransient | ( | FileEntryRef | SourceFile | ) |
|---|
◆ setMainFileID()
| void clang::SourceManager::setMainFileID ( FileID FID) | inline |
|---|
◆ setModuleBuildStack()
◆ setNumCreatedFIDsForFileID()
Set the number of FileIDs (files and macros) that were created during preprocessing of FID, including it.
Definition at line 1130 of file SourceManager.h.
◆ setOverridenFilesKeepOriginalName()
| 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 863 of file SourceManager.h.
◆ setPreambleFileID()
| void clang::SourceManager::setPreambleFileID ( FileID Preamble) | inline |
|---|
◆ translateFile() [1/2]
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 1572 of file SourceManager.cpp.
References clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getLoadedSLocEntry(), getLocalSLocEntry(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), loaded_sloc_entry_size(), local_sloc_entry_size(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by getOrCreateFileID(), translateFile(), and translateFileLineCol().
◆ translateFile() [2/2]
◆ translateFileLineCol()
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 1558 of file SourceManager.cpp.
References clang::Line, translateFile(), and translateLineCol().
◆ translateLineCol()
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.
- FID for the given line:col. Returns null location if
- FID is not a file SLocEntry.
Definition at line 1611 of file SourceManager.cpp.
References clang::SrcMgr::LineOffsetMapping::get(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::SrcMgr::FileInfo::getContentCache(), clang::SrcMgr::SLocEntry::getFile(), getFileManager(), clang::SourceLocation::getLocWithOffset(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), clang::Invalid, clang::SrcMgr::SLocEntry::isFile(), clang::FileID::isInvalid(), clang::Line, clang::SrcMgr::LineOffsetMapping::size(), and clang::SrcMgr::ContentCache::SourceLineCache.
Referenced by translateFileLineCol().
◆ userFilesAreVolatile()
| 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 869 of file SourceManager.h.
◆ ASTReader
◆ ASTWriter
The documentation for this class was generated from the following files:
- include/clang/Basic/SourceManager.h
- lib/Basic/SourceManager.cpp