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;
57 unsigned getHashValue()
const {
return static_cast<unsigned>(ID); }
69 int getOpaqueValue()
const {
return ID; }
113 unsigned getOffset()
const {
114 return ID & ~MacroIDBit;
118 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
125 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
127 L.ID = MacroIDBit |
ID;
135 assert(((getOffset()+Offset) & MacroIDBit) == 0 &&
"offset overflow");
185 return !(LHS == RHS);
211 return B == X.B && E == X.E;
215 return B != X.B || E != X.E;
279 assert(SrcMgr &&
"SourceManager is NULL.");
319 assert(SrcMgr == Loc.SrcMgr &&
"Loc comes from another SourceManager!");
325 FullSourceLoc, bool> {
339 LHS.SrcMgr == RHS.SrcMgr;
344 return !(LHS == RHS);
357 const char *Filename;
363 : Filename(FN), Line(Ln), Col(Co), IncludeLoc(IL) {
371 bool isValid()
const {
return Filename !=
nullptr; }
419 struct isPodLike<clang::SourceLocation> {
static const bool value =
true; };
421 struct isPodLike<clang::FileID> {
static const bool value =
true; };
433 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)
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.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
static CharSourceRange getCharRange(SourceRange R)
unsigned getHashValue() const
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
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.
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)
Ordering on two declaration names.
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
SourceRange getAsRange() const
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
Reads an AST files chain containing the contents of a translation unit.
detail::InMemoryDirectory::const_iterator E
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)
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
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