clang API Documentation
This class handles loading and caching of source files into memory. More...
#include <SourceManager.h>


Classes | |
| class | LocBeforeThanCompare |
| Comparison function class. More... | |
| struct | MemoryBufferSizes |
Public Types | |
| typedef llvm::DenseMap< const FileEntry *, SrcMgr::ContentCache * > ::const_iterator | fileinfo_iterator |
Public Member Functions | |
| SourceManager (DiagnosticsEngine &Diag, FileManager &FileMgr) | |
| ~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 overriden by other files.Defaults to true. | |
| FileID | createMainFileIDForMemBuffer (const llvm::MemoryBuffer *Buffer) |
| FileID | getMainFileID () const |
| getMainFileID - Returns the FileID of the main source file. | |
| FileID | createMainFileID (const FileEntry *SourceFile, SrcMgr::CharacteristicKind Kind=SrcMgr::C_User) |
| createMainFileID - Create the FileID for 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) |
| FileID | createFileIDForMemBuffer (const llvm::MemoryBuffer *Buffer, int LoadedID=0, unsigned LoadedOffset=0, SourceLocation IncludeLoc=SourceLocation()) |
| SourceLocation | createMacroArgExpansionLoc (SourceLocation Loc, SourceLocation ExpansionLoc, unsigned TokLength) |
| SourceLocation | createExpansionLoc (SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, int LoadedID=0, unsigned LoadedOffset=0) |
| const llvm::MemoryBuffer * | getMemoryBufferForFile (const FileEntry *File, bool *Invalid=0) |
| Retrieve the memory buffer associated with the given file. | |
| void | overrideFileContents (const FileEntry *SourceFile, const llvm::MemoryBuffer *Buffer, bool DoNotFree=false) |
| Override the contents of the given source file by providing an already-allocated buffer. | |
| void | overrideFileContents (const FileEntry *SourceFile, const FileEntry *NewFile) |
| Override the the given source file with another one. | |
| const llvm::MemoryBuffer * | getBuffer (FileID FID, SourceLocation Loc, bool *Invalid=0) const |
| const llvm::MemoryBuffer * | getBuffer (FileID FID, bool *Invalid=0) const |
| const FileEntry * | getFileEntryForID (FileID FID) const |
| getFileEntryForID - 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=0) const |
| 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 |
| SourceLocation | getLocForStartOfFile (FileID FID) const |
| 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. | |
| SourceLocation | getExpansionLoc (SourceLocation Loc) const |
| 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 |
| std::pair< SourceLocation, SourceLocation > | getExpansionRange (SourceLocation Loc) const |
| SourceLocation | getSpellingLoc (SourceLocation Loc) const |
| SourceLocation | getImmediateSpellingLoc (SourceLocation Loc) const |
| std::pair< FileID, unsigned > | getDecomposedLoc (SourceLocation Loc) const |
| std::pair< FileID, unsigned > | getDecomposedExpansionLoc (SourceLocation Loc) const |
| std::pair< FileID, unsigned > | getDecomposedSpellingLoc (SourceLocation Loc) const |
| unsigned | getFileOffset (SourceLocation SpellingLoc) const |
| bool | isMacroArgExpansion (SourceLocation Loc) const |
| bool | isInSLocAddrSpace (SourceLocation Loc, SourceLocation Start, unsigned Length, unsigned *RelativeOffset=0) const |
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. | |
| 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. If it's true and RelativeOffset is non-null, it will be set to the offset of RHS relative to LHS. | |
| const char * | getCharacterData (SourceLocation SL, bool *Invalid=0) const |
| unsigned | getColumnNumber (FileID FID, unsigned FilePos, bool *Invalid=0) const |
| unsigned | getSpellingColumnNumber (SourceLocation Loc, bool *Invalid=0) const |
| unsigned | getExpansionColumnNumber (SourceLocation Loc, bool *Invalid=0) const |
| unsigned | getPresumedColumnNumber (SourceLocation Loc, bool *Invalid=0) const |
| unsigned | getLineNumber (FileID FID, unsigned FilePos, bool *Invalid=0) const |
| unsigned | getSpellingLineNumber (SourceLocation Loc, bool *Invalid=0) const |
| unsigned | getExpansionLineNumber (SourceLocation Loc, bool *Invalid=0) const |
| unsigned | getPresumedLineNumber (SourceLocation Loc, bool *Invalid=0) const |
| const char * | getBufferName (SourceLocation Loc, bool *Invalid=0) const |
| SrcMgr::CharacteristicKind | getFileCharacteristic (SourceLocation Loc) const |
| PresumedLoc | getPresumedLoc (SourceLocation Loc) const |
| bool | isFromSameFile (SourceLocation Loc1, SourceLocation Loc2) const |
| bool | isFromMainFile (SourceLocation Loc) const |
| bool | isInSystemHeader (SourceLocation Loc) const |
| isInSystemHeader - Returns if a SourceLocation is in a system header. | |
| bool | isInExternCSystemHeader (SourceLocation Loc) const |
| 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 SLocEnty that FID represents. | |
| bool | isInFileID (SourceLocation Loc, FileID FID, unsigned *RelativeOffset=0) 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) |
| void | AddLineNote (SourceLocation Loc, unsigned LineNo, int FilenameID) |
| 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 |
| MemoryBufferSizes | getMemoryBufferSizes () const |
| size_t | getDataStructureSizes () const |
| 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 |
| unsigned | local_sloc_entry_size () const |
| Get the number of local SLocEntries we have. | |
| const SrcMgr::SLocEntry & | getLocalSLocEntry (unsigned Index, bool *Invalid=0) 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=0) const |
| Get a loaded SLocEntry. This is exposed for indexing. | |
| const SrcMgr::SLocEntry & | getSLocEntry (FileID FID, bool *Invalid=0) 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. | |
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 486 of file SourceManager.h.
| typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::const_iterator clang::SourceManager::fileinfo_iterator |
Definition at line 1235 of file SourceManager.h.
| SourceManager::SourceManager | ( | DiagnosticsEngine & | Diag, |
| FileManager & | FileMgr | ||
| ) |
Definition at line 370 of file SourceManager.cpp.
References clearIDTables(), and clang::DiagnosticsEngine::setSourceManager().
| SourceManager::~SourceManager | ( | ) |
Definition at line 378 of file SourceManager.cpp.
| void SourceManager::AddLineNote | ( | SourceLocation | Loc, |
| unsigned | LineNo, | ||
| int | FilenameID | ||
| ) |
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 295 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 315 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 473 of file SourceManager.cpp.
| void SourceManager::clearIDTables | ( | ) |
Definition at line 406 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 |
||
| ) |
createExpansionLoc - Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be referenced from ExpansionLoc.
Definition at line 542 of file SourceManager.cpp.
References clang::serialized_diags::create().
Referenced by clearIDTables(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::CreateString(), clang::TokenLexer::Init(), and clang::TokenLexer::Lex().
| FileID clang::SourceManager::createFileID | ( | const FileEntry * | SourceFile, |
| SourceLocation | IncludePos, | ||
| SrcMgr::CharacteristicKind | FileCharacter, | ||
| int | LoadedID = 0, |
||
| unsigned | LoadedOffset = 0 |
||
| ) | [inline] |
createFileID - Create a new FileID that represents the specified file being #included from the specified IncludePosition. This translates NULL into standard input.
Definition at line 650 of file SourceManager.h.
Referenced by createFileIDForMemBuffer(), createMainFileID(), clang::ASTImporter::Import(), and clang::ModuleMap::parseModuleMapFile().
| FileID clang::SourceManager::createFileIDForMemBuffer | ( | const llvm::MemoryBuffer * | Buffer, |
| int | LoadedID = 0, |
||
| unsigned | LoadedOffset = 0, |
||
| SourceLocation | IncludeLoc = SourceLocation() |
||
| ) | [inline] |
createFileIDForMemBuffer - 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 661 of file SourceManager.h.
References clang::SrcMgr::C_User, and createFileID().
Referenced by ConvertBackendLocation(), createMainFileIDForMemBuffer(), clang::Preprocessor::EnterMainSourceFile(), and clang::ASTImporter::Import().
| SourceLocation SourceManager::createMacroArgExpansionLoc | ( | SourceLocation | Loc, |
| SourceLocation | ExpansionLoc, | ||
| unsigned | TokLength | ||
| ) |
createMacroArgExpansionLoc - 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 533 of file SourceManager.cpp.
Referenced by updateConsecutiveMacroArgTokens().
| FileID clang::SourceManager::createMainFileID | ( | const FileEntry * | SourceFile, |
| SrcMgr::CharacteristicKind | Kind = SrcMgr::C_User |
||
| ) | [inline] |
createMainFileID - Create the FileID for the main source file.
Definition at line 621 of file SourceManager.h.
References createFileID(), and clang::FileID::isInvalid().
Referenced by clang::CompilerInstance::InitializeSourceManager().
| FileID clang::SourceManager::createMainFileIDForMemBuffer | ( | const llvm::MemoryBuffer * | Buffer | ) | [inline] |
createMainFileIDForMembuffer - Create the FileID for a memory buffer that will represent the FileID for the main source. One example of when this would be used is when the main source is read from STDIN.
Definition at line 607 of file SourceManager.h.
References createFileIDForMemBuffer(), and clang::FileID::isInvalid().
| fileinfo_iterator clang::SourceManager::fileinfo_begin | ( | ) | const [inline] |
Definition at line 1236 of file SourceManager.h.
Referenced by PrintStats().
| fileinfo_iterator clang::SourceManager::fileinfo_end | ( | ) | const [inline] |
Definition at line 1237 of file SourceManager.h.
Referenced by PrintStats().
| const llvm::MemoryBuffer* clang::SourceManager::getBuffer | ( | FileID | FID, |
| SourceLocation | Loc, | ||
| bool * | Invalid = 0 |
||
| ) | const [inline] |
getBuffer - 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 723 of file SourceManager.h.
References 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(), FindExpectedDiags(), getBufferName(), getColumnNumber(), clang::html::HighlightMacros(), isBeforeInTranslationUnit(), LexRawTokensFromMainFile(), clang::ModuleMap::parseModuleMapFile(), clang::html::SyntaxHighlight(), and clang::TokenRewriter::TokenRewriter().
| const llvm::MemoryBuffer* clang::SourceManager::getBuffer | ( | FileID | FID, |
| bool * | Invalid = 0 |
||
| ) | const [inline] |
Definition at line 738 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
| StringRef SourceManager::getBufferData | ( | FileID | FID, |
| bool * | Invalid = 0 |
||
| ) | const |
getBufferData - 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 605 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(), clang::Lexer::findLocationAfterToken(), clang::arcmt::trans::findSemiAfterLocation(), getBeginningOfFileToken(), clang::Rewriter::getEditBuffer(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), clang::StringLiteral::getLocationOfByte(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::html::HighlightRange(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), clang::Lexer::MeasureTokenLength(), clang::Rewriter::ReplaceText(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
| const char * SourceManager::getBufferName | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Return the filename or buffer identifier of the buffer the location is in. Note that this name does not respect #line directives. Use getPresumedLoc for normal clients.
Definition at line 1240 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 = 0 |
||
| ) | const |
getCharacterData - 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 929 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 clang::Lexer::AdvanceToTokenCharacter(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::DumpToken(), clang::Lexer::findLocationAfterToken(), GetFirstChar(), clang::Rewriter::getRewrittenText(), clang::Lexer::getSpelling(), and clang::Preprocessor::getSpellingOfSingleCharacterNumericConstant().
| unsigned SourceManager::getColumnNumber | ( | FileID | FID, |
| unsigned | FilePos, | ||
| bool * | Invalid = 0 |
||
| ) | const |
getColumnNumber - Return the column # for the specified file position. This is significantly cheaper to compute than the line number. This returns zero if the column number isn't known. This may only be called on a file sloc, so you must choose a spelling or expansion location before calling this method.
getColumnNumber - Return the column # for the specified file position. this is significantly cheaper to compute than the line number.
Definition at line 955 of file SourceManager.cpp.
References getBuffer().
Referenced by 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 1142 of file SourceManager.h.
| size_t SourceManager::getDataStructureSizes | ( | ) | const |
Definition at line 1819 of file SourceManager.cpp.
| std::pair<FileID, unsigned> clang::SourceManager::getDecomposedExpansionLoc | ( | SourceLocation | Loc | ) | const [inline] |
getDecomposedExpansionLoc - 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 919 of file SourceManager.h.
References getFileID(), clang::SrcMgr::SLocEntry::getOffset(), getSLocEntry(), and clang::SourceLocation::isFileID().
Referenced by getExpansionColumnNumber(), getExpansionLineNumber(), getFileCharacteristic(), getPresumedLoc(), and ReadLineMarkerFlags().
| std::pair<FileID, unsigned> clang::SourceManager::getDecomposedLoc | ( | SourceLocation | Loc | ) | const [inline] |
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 906 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(), getFileOffset(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), getImmediateSpellingLoc(), clang::StringLiteral::getLocationOfByte(), getMacroArgExpandedLocation(), clang::Lexer::getSourceText(), clang::Lexer::getSpelling(), clang::ASTImporter::Import(), clang::Lexer::isAtStartOfMacroExpansion(), isBeforeInTranslationUnit(), clang::Lexer::makeFileCharRange(), makeRangeFromFileLocs(), clang::Lexer::MeasureTokenLength(), MoveUpIncludeHierarchy(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
| std::pair<FileID, unsigned> clang::SourceManager::getDecomposedSpellingLoc | ( | SourceLocation | Loc | ) | const [inline] |
getDecomposedSpellingLoc - 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 937 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 594 of file SourceManager.h.
Referenced by clang::ASTContext::getDiagnostics().
| unsigned SourceManager::getExpansionColumnNumber | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Definition at line 994 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedExpansionLoc(), and isInvalid().
Referenced by llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel().
| unsigned SourceManager::getExpansionLineNumber | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Definition at line 1189 of file SourceManager.cpp.
References getDecomposedExpansionLoc(), getLineNumber(), and isInvalid().
Referenced by clang::CodeGen::CodeGenModule::EmitAnnotationLineNo(), and llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel().
| SourceLocation clang::SourceManager::getExpansionLoc | ( | SourceLocation | Loc | ) | const [inline] |
getExpansionLoc - Given a SourceLocation object, return the expansion location referenced by the ID.
Definition at line 861 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::Sema::ActOnUsingDirective(), AddFID(), CompactPathDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), EmitLocation(), clang::CodeGen::CGDebugInfo::EmitLocation(), clang::Sema::findMacroSpelling(), GetFID(), handleObjCOwnershipTypeAttr(), clang::html::HighlightMacros(), clang::html::HighlightRange(), clang::TokenLexer::Init(), clang::CompilerInstance::loadModule(), clang::Lexer::MeasureTokenLength(), clang::SourceLocation::print(), clang::arcmt::TransformActions::reportError(), clang::arcmt::TransformActions::reportNote(), clang::arcmt::TransformActions::reportWarning(), clang::RewriteMacrosInInput(), and clang::CodeGen::CGDebugInfo::setLocation().
| std::pair< SourceLocation, SourceLocation > SourceManager::getExpansionRange | ( | SourceLocation | Loc | ) | const |
getExpansionRange - 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 898 of file SourceManager.cpp.
References getImmediateExpansionRange(), and clang::SourceLocation::isFileID().
Referenced by clang::TextDiagnostic::emitDiagnosticLoc(), and clang::html::HighlightMacros().
| SrcMgr::CharacteristicKind SourceManager::getFileCharacteristic | ( | SourceLocation | Loc | ) | const |
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 1210 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().
getFileEntryForID - Returns the FileEntry record for the provided FileID.
Definition at line 754 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), clang::SrcMgr::SLocEntry::isFile(), and clang::SrcMgr::ContentCache::OrigEntry.
Referenced by clang::arcmt::MigrationProcess::applyTransform(), clang::CacheTokens(), clang::PTHManager::CreateLexer(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::Preprocessor::EnterMainSourceFile(), clang::Preprocessor::EnterSourceFile(), clang::CodeGenAction::ExecuteAction(), clang::ModuleMap::getContainingModuleMapFile(), clang::PreprocessorLexer::getFileEntry(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::Preprocessor::HandleEndOfFile(), clang::ModuleMap::inferModuleFromLocation(), clang::CompilerInstance::loadModule(), clang::Preprocessor::LookupFile(), 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 767 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), and clang::SrcMgr::ContentCache::OrigEntry.
| FileID clang::SourceManager::getFileID | ( | SourceLocation | SpellingLoc | ) | const [inline] |
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 814 of file SourceManager.h.
Referenced by AddFID(), checkObjCUnusedIvar(), clang::Lexer::Create_PragmaLexer(), clang::TextDiagnostic::emitDiagnosticLoc(), getBufferName(), clang::ModuleMap::getContainingModuleMapFile(), getDecomposedExpansionLoc(), getDecomposedLoc(), getDecomposedSpellingLoc(), GetFID(), getImmediateExpansionRange(), clang::Lexer::getImmediateMacroName(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), clang::html::HighlightMacros(), clang::html::HighlightRange(), clang::ModuleMap::inferModuleFromLocation(), clang::Lexer::isAtEndOfMacroExpansion(), isFromMainFile(), isFromSameFile(), isMacroArgExpansion(), clang::CompilerInstance::loadModule(), and Scan().
| unsigned SourceManager::getFileIDSize | ( | FileID | FID | ) | const |
The size of the SLocEnty that FID represents.
The size of the SLocEnty that.
Definition at line 1319 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 871 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by clang::ASTUnit::addFileLevelDecl(), getLocForEndOfFile(), getLocForStartOfFile(), isPreprocessedEntityIfInFileID(), and translateLineCol().
| FileManager& clang::SourceManager::getFileManager | ( | ) | const [inline] |
Definition at line 596 of file SourceManager.h.
Referenced by clang::ModuleMap::findModuleForHeader(), clang::SrcMgr::ContentCache::getBuffer(), clang::ModuleMap::inferFrameworkModule(), and clang::ModuleMap::isHeaderInUnavailableModule().
| unsigned clang::SourceManager::getFileOffset | ( | SourceLocation | SpellingLoc | ) | const [inline] |
getFileOffset - This method 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 953 of file SourceManager.h.
References getDecomposedLoc().
Referenced by clang::html::HighlightRange(), clang::RewriteMacrosInInput(), and clang::html::SyntaxHighlight().
| std::pair< SourceLocation, SourceLocation > SourceManager::getImmediateExpansionRange | ( | SourceLocation | Loc | ) | const |
getImmediateExpansionRange - Loc is required to be an expansion location. Return the start/end of the expansion information.
Definition at line 889 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), clang::SrcMgr::ExpansionInfo::getExpansionLocRange(), getFileID(), getSLocEntry(), and clang::SourceLocation::isMacroID().
Referenced by checkAllAtProps(), getExpansionRange(), getImmediateMacroCalleeLoc(), getImmediateMacroCallerLoc(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), and handleObjCOwnershipTypeAttr().
| SourceLocation SourceManager::getImmediateSpellingLoc | ( | SourceLocation | Loc | ) | const |
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 878 of file SourceManager.cpp.
References getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SourceLocation::getLocWithOffset(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::getSpellingLoc(), and clang::SourceLocation::isFileID().
Referenced by getImmediateMacroCalleeLoc(), getImmediateMacroCallerLoc(), and skipToMacroArgExpansion().
| 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 850 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getFile(), getSLocEntry(), and clang::SrcMgr::SLocEntry::isFile().
Referenced by clang::Preprocessor::HandleEndOfFile(), and clang::ModuleMap::inferModuleFromLocation().
| unsigned SourceManager::getLineNumber | ( | FileID | FID, |
| unsigned | FilePos, | ||
| bool * | Invalid = 0 |
||
| ) | const |
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 1064 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 clang::TextDiagnostic::emitDiagnosticLoc(), getExpansionLineNumber(), getPresumedLoc(), getSpellingLineNumber(), clang::Rewriter::IncreaseIndentation(), and clang::Rewriter::InsertText().
| LineTableInfo & SourceManager::getLineTable | ( | ) |
Retrieve the stored line table.
Definition at line 360 of file SourceManager.cpp.
| unsigned SourceManager::getLineTableFilenameID | ( | StringRef | Name | ) |
getLineTableFilenameID - Return the uniqued ID for the specified filename.
Definition at line 285 of file SourceManager.cpp.
Referenced by clang::Preprocessor::HandlePragmaSystemHeader().
| const SrcMgr::SLocEntry& clang::SourceManager::getLoadedSLocEntry | ( | unsigned | Index, |
| bool * | Invalid = 0 |
||
| ) | const [inline] |
Get a loaded SLocEntry. This is exposed for indexing.
Definition at line 1260 of file SourceManager.h.
References Index, and clang::ExternalSLocEntrySource::ReadSLocEntry().
Referenced by translateFile().
| const SrcMgr::SLocEntry& clang::SourceManager::getLocalSLocEntry | ( | unsigned | Index, |
| bool * | Invalid = 0 |
||
| ) | const [inline] |
Get a local SLocEntry. This is exposed for indexing.
Definition at line 1250 of file SourceManager.h.
References Index.
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 838 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] |
getLocForStartOfFile - Return the source location corresponding to the first byte of the specified file.
Definition at line 826 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(), ConvertBackendLocation(), clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::EnterSourceFile(), clang::ASTReader::FindFileRegionDecls(), clang::Lexer::findLocationAfterToken(), clang::arcmt::trans::findSemiAfterLocation(), getPresumedLoc(), clang::ASTUnit::PreambleData::getSourceRange(), clang::Lexer::getSpelling(), clang::ASTUnit::getStartOfMainFileID(), clang::Preprocessor::HandleEndOfFile(), clang::ASTImporter::Import(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), clang::Lexer::MeasureTokenLength(), clang::PTHLexer::PTHLexer(), clang::PCHValidator::ReadPredefinesBuffer(), and clang::arcmt::trans::MigrationContext::rewritePropertyAttribute().
| SourceLocation SourceManager::getMacroArgExpandedLocation | ( | SourceLocation | Loc | ) | const |
If Loc points inside a function macro argument, the returned location will be the macro location in which the argument was expanded. If 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 1650 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] |
getMainFileID - Returns the FileID of the main source file.
Definition at line 618 of file SourceManager.h.
Referenced by clang::CacheTokens(), clang::DoRewriteTest(), clang::Preprocessor::EnterMainSourceFile(), clang::CodeGenAction::ExecuteAction(), clang::DumpRawTokensAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), clang::ASTUnit::getStartOfMainFileID(), clang::LogDiagnosticPrinter::HandleDiagnostic(), clang::Preprocessor::HandleEndOfFile(), clang::CompilerInstance::InitializeSourceManager(), isFromMainFile(), clang::ASTUnit::isInMainFileID(), LexRawTokensFromMainFile(), clang::CompilerInstance::loadModule(), clang::Preprocessor::LookupFile(), clang::ASTUnit::mapLocationFromPreamble(), clang::ASTUnit::mapLocationToPreamble(), and clang::RewriteMacrosInInput().
| const llvm::MemoryBuffer * SourceManager::getMemoryBufferForFile | ( | const FileEntry * | File, |
| bool * | Invalid = 0 |
||
| ) |
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 577 of file SourceManager.cpp.
References clang::SrcMgr::ContentCache::getBuffer().
Referenced by clang::Preprocessor::SetCodeCompletionPoint().
| SourceManager::MemoryBufferSizes SourceManager::getMemoryBufferSizes | ( | ) | const |
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory.
Definition at line 1801 of file SourceManager.cpp.
| unsigned clang::SourceManager::getNextLocalOffset | ( | ) | const [inline] |
Definition at line 1276 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 784 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 641 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 = 0 |
||
| ) | const |
Definition at line 1001 of file SourceManager.cpp.
References clang::PresumedLoc::getColumn(), getPresumedLoc(), and isInvalid().
| unsigned SourceManager::getPresumedLineNumber | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Definition at line 1195 of file SourceManager.cpp.
References clang::PresumedLoc::getLine(), getPresumedLoc(), and isInvalid().
Referenced by CheckLists(), and PrintProblem().
| PresumedLoc SourceManager::getPresumedLoc | ( | SourceLocation | Loc | ) | const |
getPresumedLoc - This method returns the "presumed" location of a SourceLocation specifies. A "presumed location" can be modified by #line or GNU line marker directives. This provides a view on the data that a user should see in diagnostics, for example.
Note that a presumed location is always given as the expansion point of an expansion location, not at the spelling location.
Loc is invalid or the file containing Loc has changed on disk), returns an invalid presumed location.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 1255 of file SourceManager.cpp.
References 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(), getDiagnosticPresumedLoc(), 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 = 0 |
||
| ) | const [inline] |
Definition at line 1268 of file SourceManager.h.
Referenced by getBuffer(), getBufferData(), getCharacterData(), getDecomposedExpansionLoc(), getDecomposedLoc(), getDecomposedSpellingLoc(), getFileCharacteristic(), getFileEntryForID(), getFileIDSize(), getImmediateExpansionRange(), clang::Lexer::getImmediateMacroName(), getImmediateSpellingLoc(), getIncludeLoc(), getLineNumber(), getLocForEndOfFile(), getLocForStartOfFile(), getNumCreatedFIDsForFileID(), getPresumedLoc(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), clang::Lexer::isAtEndOfMacroExpansion(), clang::Lexer::isAtStartOfMacroExpansion(), isInFileID(), isMacroArgExpansion(), clang::Lexer::makeFileCharRange(), MoveUpIncludeHierarchy(), setNumCreatedFIDsForFileID(), translateFile(), and translateLineCol().
| unsigned SourceManager::getSpellingColumnNumber | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Definition at line 987 of file SourceManager.cpp.
References getColumnNumber(), getDecomposedSpellingLoc(), and isInvalid().
| unsigned SourceManager::getSpellingLineNumber | ( | SourceLocation | Loc, |
| bool * | Invalid = 0 |
||
| ) | const |
Definition at line 1183 of file SourceManager.cpp.
References getDecomposedSpellingLoc(), getLineNumber(), and isInvalid().
| SourceLocation clang::SourceManager::getSpellingLoc | ( | SourceLocation | Loc | ) | const [inline] |
getSpellingLoc - 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 890 of file SourceManager.h.
References clang::SourceLocation::isFileID().
Referenced by AreTokensAdjacent(), clang::Lexer::GetBeginningOfToken(), GetFirstChar(), getImmediateMacroName(), clang::Lexer::getImmediateMacroName(), clang::StringLiteral::getLocationOfByte(), clang::ASTImporter::Import(), clang::Lexer::isAtEndOfMacroExpansion(), isInSystemMacro(), and clang::SourceLocation::print().
| bool clang::SourceManager::hasFileInfo | ( | const FileEntry * | File | ) | const [inline] |
Definition at line 1238 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 1131 of file SourceManager.h.
| 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 1215 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 1223 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 1700 of file SourceManager.cpp.
References clang::IsBeforeInTranslationUnitCache::clear(), getBuffer(), clang::IsBeforeInTranslationUnitCache::getCachedResult(), getDecomposedLoc(), clang::IsBeforeInTranslationUnitCache::isCacheValid(), clang::SourceLocation::isValid(), MoveUpIncludeHierarchy(), clang::IsBeforeInTranslationUnitCache::setCommonLoc(), and clang::IsBeforeInTranslationUnitCache::setQueryFIDs().
Referenced by clang::PreprocessingRecord::addPreprocessedEntity(), DiagnoseIgnoredQualifiers(), GetFullTypeForDeclarator(), clang::thread_safety::SortDiagBySourceLocation::operator()(), and clang::SourceManager::LocBeforeThanCompare::operator()().
| bool clang::SourceManager::isFromMainFile | ( | SourceLocation | Loc | ) | const [inline] |
isFromMainFile - Returns true if the file of provided SourceLocation is the main file.
Definition at line 1076 of file SourceManager.h.
References getFileID(), and getMainFileID().
Referenced by clang::Sema::ActOnUsingDirective(), and clang::RewriteMacrosInInput().
| bool clang::SourceManager::isFromSameFile | ( | SourceLocation | Loc1, |
| SourceLocation | Loc2 | ||
| ) | const [inline] |
isFromSameFile - Returns true if both SourceLocations correspond to the same file.
Definition at line 1070 of file SourceManager.h.
References getFileID().
| bool clang::SourceManager::isInExternCSystemHeader | ( | SourceLocation | Loc | ) | const [inline] |
isInExternCSystemHeader - Returns if a SourceLocation is in an "extern C" system header.
Definition at line 1087 of file SourceManager.h.
References clang::SrcMgr::C_ExternCSystem, and getFileCharacteristic().
| bool clang::SourceManager::isInFileID | ( | SourceLocation | Loc, |
| FileID | FID, | ||
| unsigned * | RelativeOffset = 0 |
||
| ) | 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 1102 of file SourceManager.h.
References clang::SrcMgr::SLocEntry::getOffset(), and getSLocEntry().
Referenced by clang::Lexer::getImmediateMacroName(), clang::Lexer::getSourceText(), clang::Lexer::isAtEndOfMacroExpansion(), clang::ASTUnit::isInMainFileID(), clang::ASTUnit::isInPreambleFileID(), isPreprocessedEntityIfInFileID(), clang::Lexer::makeFileCharRange(), makeRangeFromFileLocs(), clang::ASTUnit::mapLocationFromPreamble(), and clang::ASTUnit::mapLocationToPreamble().
| 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 992 of file SourceManager.h.
Referenced by isEmptyARCMTMacroStatement(), and updateConsecutiveMacroArgTokens().
| bool clang::SourceManager::isInSLocAddrSpace | ( | SourceLocation | Loc, |
| SourceLocation | Start, | ||
| unsigned | Length, | ||
| unsigned * | RelativeOffset = 0 |
||
| ) | 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 968 of file SourceManager.h.
| bool clang::SourceManager::isInSystemHeader | ( | SourceLocation | Loc | ) | const [inline] |
isInSystemHeader - Returns if a SourceLocation is in a system header.
Definition at line 1081 of file SourceManager.h.
References clang::SrcMgr::C_User, and getFileCharacteristic().
Referenced by clang::Sema::ActOnAtEnd(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::checkInitMethod(), isForbiddenTypeAllowed(), clang::ento::CallOrObjCMessage::isInSystemHeader(), isInSystemMacro(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), clang::Sema::makeUnavailableInSystemHeader(), clang::arcmt::TransformActions::reportError(), clang::arcmt::TransformActions::reportNote(), and clang::arcmt::TransformActions::reportWarning().
| bool clang::SourceManager::isInSystemMacro | ( | SourceLocation | loc | ) | [inline] |
Returns whether Loc is expanded from a macro in a system header.
Definition at line 1092 of file SourceManager.h.
References getSpellingLoc(), isInSystemHeader(), and clang::SourceLocation::isMacroID().
| bool clang::SourceManager::isLoadedFileID | ( | FileID | FID | ) | const [inline] |
Returns true if FID came from a PCH/Module.
Definition at line 1304 of file SourceManager.h.
Referenced by clang::Preprocessor::EnterMainSourceFile(), clang::ASTUnit::findFileRegionDecls(), and isLocalFileID().
| bool clang::SourceManager::isLoadedSourceLocation | ( | SourceLocation | Loc | ) | const [inline] |
Returns true if Loc came from a PCH/Module.
Definition at line 1294 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 1310 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 1299 of file SourceManager.h.
Referenced by clang::ASTUnit::addFileLevelDecl().
| bool SourceManager::isMacroArgExpansion | ( | SourceLocation | Loc | ) | const |
isMacroArgExpansion - This method 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 913 of file SourceManager.cpp.
References clang::SrcMgr::SLocEntry::getExpansion(), getFileID(), getSLocEntry(), clang::SrcMgr::ExpansionInfo::isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
Referenced by clang::Lexer::GetBeginningOfToken(), getImmediateMacroCalleeLoc(), getImmediateMacroCallerLoc(), getImmediateMacroName(), and skipToMacroArgExpansion().
| unsigned clang::SourceManager::loaded_sloc_entry_size | ( | ) | const [inline] |
Get the number of loaded SLocEntries we have.
Definition at line 1257 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 1247 of file SourceManager.h.
Referenced by getFileIDSize(), clang::Preprocessor::HandleEndOfFile(), clang::PreprocessorLexer::PreprocessorLexer(), and translateFile().
| void SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
| const llvm::MemoryBuffer * | Buffer, | ||
| bool | DoNotFree = false |
||
| ) |
Override the contents of the given source file by providing an already-allocated buffer.
| SourceFile | the source file whose contents will be overriden. |
| 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 584 of file SourceManager.cpp.
Referenced by clang::GenerateModuleAction::BeginSourceFileAction(), InitializeFileRemapping(), clang::CompilerInstance::InitializeSourceManager(), and clang::Preprocessor::SetCodeCompletionPoint().
| void SourceManager::overrideFileContents | ( | const FileEntry * | SourceFile, |
| const FileEntry * | NewFile | ||
| ) |
Override the the given source file with another one.
| SourceFile | the source file which will be overriden. |
| NewFile | the file whose contents will be used as the data instead of the contents of the given source file. |
Definition at line 594 of file SourceManager.cpp.
References clang::FileEntry::getSize().
| void SourceManager::PrintStats | ( | ) | const |
PrintStats - Print statistics to stderr.
Definition at line 1769 of file SourceManager.cpp.
References fileinfo_begin(), and fileinfo_end().
Referenced by clang::FrontendAction::EndSourceFile().
| void clang::SourceManager::setExternalSLocEntrySource | ( | ExternalSLocEntrySource * | Source | ) | [inline] |
Definition at line 1278 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 629 of file SourceManager.h.
References clang::FileID::isInvalid().
| 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 795 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 overriden by other files.Defaults to true.
Definition at line 600 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 635 of file SourceManager.h.
References clang::FileID::isInvalid().
Get the FileID for the given file.
If the source file is included multiple times, the FileID will be the first inclusion.
Definition at line 1374 of file SourceManager.cpp.
References getActualFileInode(), 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 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 1360 of file SourceManager.cpp.
References translateFile(), and translateLineCol().
Referenced by clang::CodeGenAction::ExecuteAction(), and clang::ASTUnit::getLocation().
| 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 1487 of file SourceManager.cpp.
References ComputeLineNumbers(), Diag(), 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 translateFileLineCol().
friend class ASTReader [friend] |
Definition at line 1389 of file SourceManager.h.
friend class ASTWriter [friend] |
Definition at line 1390 of file SourceManager.h.