17 #include "llvm/Support/MemoryBuffer.h"
18 #include "llvm/Support/raw_ostream.h"
20 using namespace clang;
31 OS << Message <<
'\n';
40 OS <<
"<invalid loc>";
64 LLVM_DUMP_METHOD std::string
65 SourceLocation::printToString(const SourceManager &SM) const {
67 llvm::raw_string_ostream OS(S);
72 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
73 print(llvm::errs(), SM);
76 //===----------------------------------------------------------------------===//
78 //===----------------------------------------------------------------------===//
80 FileID FullSourceLoc::getFileID() const {
82 return SrcMgr->getFileID(*this);
86 FullSourceLoc FullSourceLoc::getExpansionLoc() const {
88 return FullSourceLoc(SrcMgr->getExpansionLoc(*this), *SrcMgr);
91 FullSourceLoc FullSourceLoc::getSpellingLoc() const {
93 return FullSourceLoc(SrcMgr->getSpellingLoc(*this), *SrcMgr);
96 unsigned FullSourceLoc::getExpansionLineNumber(bool *Invalid) const {
98 return SrcMgr->getExpansionLineNumber(*this, Invalid);
101 unsigned FullSourceLoc::getExpansionColumnNumber(bool *Invalid) const {
103 return SrcMgr->getExpansionColumnNumber(*this, Invalid);
106 unsigned FullSourceLoc::getSpellingLineNumber(bool *Invalid) const {
108 return SrcMgr->getSpellingLineNumber(*this, Invalid);
111 unsigned FullSourceLoc::getSpellingColumnNumber(bool *Invalid) const {
113 return SrcMgr->getSpellingColumnNumber(*this, Invalid);
116 bool FullSourceLoc::isInSystemHeader() const {
118 return SrcMgr->isInSystemHeader(*this);
121 bool FullSourceLoc::isBeforeInTranslationUnitThan(SourceLocation Loc) const {
123 return SrcMgr->isBeforeInTranslationUnit(*this, Loc);
126 LLVM_DUMP_METHOD void FullSourceLoc::dump() const {
127 SourceLocation::dump(*SrcMgr);
130 const char *FullSourceLoc::getCharacterData(bool *Invalid) const {
132 return SrcMgr->getCharacterData(*this, Invalid);
135 StringRef FullSourceLoc::getBufferData(bool *Invalid) const {
137 return SrcMgr->getBuffer(SrcMgr->getFileID(*this), Invalid)->getBuffer();
140 std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const {
141 return SrcMgr->getDecomposedLoc(*this);
unsigned getColumn() const
Return the presumed column number of this location.
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.
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
unsigned getLine() const
Return the presumed line number of this location.
Represents an unpacked "presumed" location which can be presented to the user.
void print(raw_ostream &OS, const SourceManager &SM) const
const char * getFilename() const
Return the presumed filename of this location.
bool isValid() const
Return true if this is a valid SourceLocation object.
Defines the clang::SourceLocation class and associated facilities.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.