18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/Support/Compiler.h" 20 #include "llvm/Support/MemoryBuffer.h" 21 #include "llvm/Support/raw_ostream.h" 26 using namespace clang;
37 OS << Message <<
'\n';
46 OS <<
"<invalid loc>";
70 LLVM_DUMP_METHOD std::string 71 SourceLocation::printToString(const SourceManager &SM) const { 73 llvm::raw_string_ostream OS(S); 78 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const { 79 print(llvm::errs(), SM); 82 //===----------------------------------------------------------------------===// 84 //===----------------------------------------------------------------------===// 86 FileID FullSourceLoc::getFileID() const { 88 return SrcMgr->getFileID(*this); 91 FullSourceLoc FullSourceLoc::getExpansionLoc() const { 93 return FullSourceLoc(SrcMgr->getExpansionLoc(*this), *SrcMgr); 96 FullSourceLoc FullSourceLoc::getSpellingLoc() const { 98 return FullSourceLoc(SrcMgr->getSpellingLoc(*this), *SrcMgr); 101 FullSourceLoc FullSourceLoc::getFileLoc() const { 103 return FullSourceLoc(SrcMgr->getFileLoc(*this), *SrcMgr); 106 PresumedLoc FullSourceLoc::getPresumedLoc(bool UseLineDirectives) const { 108 return PresumedLoc(); 110 return SrcMgr->getPresumedLoc(*this, UseLineDirectives); 113 bool FullSourceLoc::isMacroArgExpansion(FullSourceLoc *StartLoc) const { 115 return SrcMgr->isMacroArgExpansion(*this, StartLoc); 118 FullSourceLoc FullSourceLoc::getImmediateMacroCallerLoc() const { 120 return FullSourceLoc(SrcMgr->getImmediateMacroCallerLoc(*this), *SrcMgr); 123 std::pair<FullSourceLoc, StringRef> FullSourceLoc::getModuleImportLoc() const { 125 return std::make_pair(FullSourceLoc(), StringRef()); 127 std::pair<SourceLocation, StringRef> ImportLoc = 128 SrcMgr->getModuleImportLoc(*this); 129 return std::make_pair(FullSourceLoc(ImportLoc.first, *SrcMgr), 133 unsigned FullSourceLoc::getFileOffset() const { 135 return SrcMgr->getFileOffset(*this); 138 unsigned FullSourceLoc::getLineNumber(bool *Invalid) const { 140 return SrcMgr->getLineNumber(getFileID(), getFileOffset(), Invalid); 143 unsigned FullSourceLoc::getColumnNumber(bool *Invalid) const { 145 return SrcMgr->getColumnNumber(getFileID(), getFileOffset(), Invalid); 148 const FileEntry *FullSourceLoc::getFileEntry() const { 150 return SrcMgr->getFileEntryForID(getFileID()); 153 unsigned FullSourceLoc::getExpansionLineNumber(bool *Invalid) const { 155 return SrcMgr->getExpansionLineNumber(*this, Invalid); 158 unsigned FullSourceLoc::getExpansionColumnNumber(bool *Invalid) const { 160 return SrcMgr->getExpansionColumnNumber(*this, Invalid); 163 unsigned FullSourceLoc::getSpellingLineNumber(bool *Invalid) const { 165 return SrcMgr->getSpellingLineNumber(*this, Invalid); 168 unsigned FullSourceLoc::getSpellingColumnNumber(bool *Invalid) const { 170 return SrcMgr->getSpellingColumnNumber(*this, Invalid); 173 bool FullSourceLoc::isInSystemHeader() const { 175 return SrcMgr->isInSystemHeader(*this); 178 bool FullSourceLoc::isBeforeInTranslationUnitThan(SourceLocation Loc) const { 180 return SrcMgr->isBeforeInTranslationUnit(*this, Loc); 183 LLVM_DUMP_METHOD void FullSourceLoc::dump() const { 184 SourceLocation::dump(*SrcMgr); 187 const char *FullSourceLoc::getCharacterData(bool *Invalid) const { 189 return SrcMgr->getCharacterData(*this, Invalid); 192 StringRef FullSourceLoc::getBufferData(bool *Invalid) const { 194 return SrcMgr->getBuffer(SrcMgr->getFileID(*this), Invalid)->getBuffer(); 197 std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const { 198 return SrcMgr->getDecomposedLoc(*this); Defines the SourceManager interface.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
void print(raw_ostream &OS) const override
void print(raw_ostream &OS, const SourceManager &SM) const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
bool isInvalid() const
Return true if this object is invalid or uninitialized.
unsigned getLine() const
Return the presumed line number of this location.
Represents an unpacked "presumed" location which can be presented to the user.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getColumn() const
Return the presumed column number of this location.
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
Defines the clang::SourceLocation class and associated facilities.
This class handles loading and caching of source files into memory.