15 #ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
16 #define LLVM_CLANG_BASIC_SOURCELOCATION_H
19 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/PointerLikeTypeTraits.h"
28 template <
typename T>
struct DenseMapInfo;
29 template <
typename T>
struct isPodLike;
56 unsigned getHashValue()
const {
return static_cast<unsigned>(ID); }
68 int getOpaqueValue()
const {
return ID; }
112 unsigned getOffset()
const {
113 return ID & ~MacroIDBit;
117 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
124 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
126 L.ID = MacroIDBit |
ID;
134 assert(((getOffset()+Offset) & MacroIDBit) == 0 &&
"offset overflow");
184 return !(LHS == RHS);
210 return B == X.B && E == X.E;
214 return B != X.B || E != X.E;
278 assert(SrcMgr &&
"SourceManager is NULL.");
318 assert(SrcMgr == Loc.SrcMgr &&
"Loc comes from another SourceManager!");
324 FullSourceLoc, bool> {
338 LHS.SrcMgr == RHS.SrcMgr;
343 return !(LHS == RHS);
356 const char *Filename;
362 : Filename(FN), Line(Ln), Col(Co), IncludeLoc(IL) {
370 bool isValid()
const {
return Filename !=
nullptr; }
418 struct isPodLike<clang::SourceLocation> {
static const bool value =
true; };
420 struct isPodLike<clang::FileID> {
static const bool value =
true; };
432 enum { NumLowBitsAvailable = 0 };
SourceLocation getEnd() const
std::string printToString(const SourceManager &SM) const
SourceLocation getBegin() const
unsigned getColumn() const
Return the presumed column number of this location.
bool operator>=(const FileID &RHS) const
friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
bool operator==(CanQual< T > x, CanQual< U > y)
void setBegin(SourceLocation b)
bool isInvalid() const
Return true if this object is invalid or uninitialized.
static CharSourceRange getTokenRange(SourceRange R)
static FileID getSentinel()
const SourceManager & getManager() const
static void * getAsVoidPointer(clang::SourceLocation L)
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void setBegin(SourceLocation b)
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
friend bool operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceRange(SourceLocation loc)
void dump() const
Prints information about this FullSourceLoc to stderr.
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E)
void dump(const SourceManager &SM) const
unsigned getLine() const
Return the presumed line number of this location.
bool operator<=(const FileID &RHS) const
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
static unsigned getHashValue(clang::FileID S)
ID
Defines the set of possible language-specific address spaces.
Represents a character-granular source range.
SourceLocation getEnd() const
static clang::SourceLocation getFromVoidPointer(void *P)
PresumedLoc(const char *FN, unsigned Ln, unsigned Co, SourceLocation IL)
void setEnd(SourceLocation e)
bool operator<(const FileID &RHS) const
SourceRange(SourceLocation begin, SourceLocation end)
Represents an unpacked "presumed" location which can be presented to the user.
static CharSourceRange getCharRange(SourceRange R)
unsigned getHashValue() const
const SourceRange & getAsRange() const
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token. Return false if the end o...
void print(raw_ostream &OS, const SourceManager &SM) const
const char * getFilename() const
Return the presumed filename of this location.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
const char * getCharacterData(bool *Invalid=nullptr) const
bool isValid() const
Return true if this is a valid SourceLocation object.
FullSourceLoc()
Creates a FullSourceLoc where isValid() returns false.
bool operator>(const FileID &RHS) const
static bool isEqual(clang::FileID LHS, clang::FileID RHS)
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E)
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
SourceLocation getBegin() const
bool operator<(DeclarationName LHS, DeclarationName RHS)
bool operator!=(const SourceRange &X) const
bool isInSystemHeader() const
bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const
Determines the order of 2 source locations in the translation unit.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool operator==(const SourceRange &X) const
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
Reads an AST files chain containing the contents of a translation unit.
static clang::FileID getEmptyKey()
bool operator!=(const FileID &RHS) const
FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
bool operator==(const FileID &RHS) const
Comparison function class, useful for sorting FullSourceLocs.
CharSourceRange(SourceRange R, bool ITR)
StringRef getBufferData(bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
void setEnd(SourceLocation e)
static clang::FileID getTombstoneKey()
bool operator!=(CanQual< T > x, CanQual< U > y)
Writes an AST file containing the contents of a translation unit.
A SourceLocation and its associated SourceManager.
FullSourceLoc getExpansionLoc() const
A trivial tuple used to represent a source range.
static SourceLocation getFromPtrEncoding(const void *Encoding)
Turn a pointer encoding of a SourceLocation object back into a real SourceLocation.
This class handles loading and caching of source files into memory.
void * getPtrEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it...
FullSourceLoc getSpellingLoc() const
unsigned getSpellingColumnNumber(bool *Invalid=nullptr) const