Go to the documentation of this file.
14 #ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
15 #define LLVM_CLANG_BASIC_SOURCELOCATION_H
18 #include "llvm/ADT/StringRef.h"
26 class FoldingSetNodeID;
55 unsigned getHashValue()
const {
return static_cast<unsigned>(ID); }
68 int getOpaqueValue()
const {
return ID; }
99 enum :
UIntTy { MacroIDBit = 1ULL << (8 *
sizeof(
UIntTy) - 1) };
115 UIntTy getOffset()
const {
return ID & ~MacroIDBit; }
117 static SourceLocation getFileLoc(
UIntTy ID) {
118 assert((
ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
124 static SourceLocation getMacroLoc(
UIntTy ID) {
125 assert((
ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
127 L.ID = MacroIDBit |
ID;
135 assert(((getOffset()+
Offset) & MacroIDBit) == 0 &&
"offset overflow");
191 return !(LHS == RHS);
229 return B ==
X.B && E ==
X.E;
233 return B !=
X.B || E !=
X.E;
238 return B <= other.B && E >= other.E;
255 bool IsTokenRange =
false;
291 bool isValid()
const {
return Range.isValid(); }
303 const char *Filename =
nullptr;
312 :
Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
383 assert(SrcMgr &&
"SourceManager is NULL.");
433 assert(SrcMgr == Loc.SrcMgr &&
"Loc comes from another SourceManager!");
452 LHS.SrcMgr == RHS.SrcMgr;
457 return !(LHS == RHS);
468 struct DenseMapInfo<
clang::FileID, void> {
478 return S.getHashValue();
489 template <>
struct DenseMapInfo<
clang::SourceLocation, void> {
516 #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H
bool operator!=(CanQual< T > x, CanQual< U > y)
void setBegin(SourceLocation b)
bool isMacroArgExpansion(FullSourceLoc *StartLoc=nullptr) const
const SourceManager & getManager() const
bool hasManager() const
Checks whether the SourceManager is present.
static bool isEqual(clang::FileID LHS, clang::FileID RHS)
YAML serialization mapping.
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E)
SourceLocation getBegin() const
void * getPtrEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it.
bool operator!=(const SourceRange &X) const
const FileEntry * getFileEntry() const
A SourceLocation and its associated SourceManager.
A trivial tuple used to represent a source range.
unsigned getLine() const
Return the presumed line number of this location.
static SourceLocation getFromPtrEncoding(const void *Encoding)
Turn a pointer encoding of a SourceLocation object back into a real SourceLocation.
CharSourceRange(SourceRange R, bool ITR)
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
static FileID getSentinel()
void dump(const SourceManager &SM) const
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceLocation getBegin() const
std::pair< FullSourceLoc, StringRef > getModuleImportLoc() const
bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const
Determines the order of 2 source locations in the translation unit.
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E)
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
std::string printToString(const SourceManager &SM) const
PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co, SourceLocation IL)
static clang::SourceLocation getEmptyKey()
static clang::SourceLocation getTombstoneKey()
void setTokenRange(bool TR)
SourceRange(SourceLocation begin, SourceLocation end)
This class handles loading and caching of source files into memory.
unsigned getHashValue() const
unsigned getFileOffset() const
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
static CharSourceRange getCharRange(SourceRange R)
StringRef getBufferData(bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
bool operator>(const FileID &RHS) const
void print(raw_ostream &OS, const SourceManager &SM) const
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
SourceRange getAsRange() const
const char * getFilename() const
Return the presumed filename of this location.
SourceLocation getEnd() const
FullSourceLoc getSpellingLoc() const
bool operator!=(const FileID &RHS) const
unsigned getSpellingColumnNumber(bool *Invalid=nullptr) const
CharSourceRange()=default
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool Zero(InterpState &S, CodePtr OpPC)
unsigned getHashValue() const
bool operator==(const FileID &RHS) const
void setEnd(SourceLocation e)
unsigned getColumn() const
Return the presumed column number of this location.
FullSourceLoc()=default
Creates a FullSourceLoc where isValid() returns false.
Writes an AST file containing the contents of a translation unit.
static unsigned getHashValue(clang::SourceLocation Loc)
void dump(const SourceManager &SM) const
Cached information about one file (either on disk or in the virtual file system).
friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
static clang::FileID getTombstoneKey()
bool isInvalid() const
Return true if this object is invalid or uninitialized.
bool operator>=(const FileID &RHS) const
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
FullSourceLoc getExpansionLoc() const
bool fullyContains(const SourceRange &other) const
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
FullSourceLoc getImmediateMacroCallerLoc() const
static CharSourceRange getTokenRange(SourceRange R)
static clang::FileID getEmptyKey()
static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End)
void dump() const
Prints information about this FullSourceLoc to stderr.
Represents a character-granular source range.
bool isInSystemHeader() const
FullSourceLoc getFileLoc() const
Comparison function class, useful for sorting FullSourceLocs.
SourceLocation getEnd() const
void setBegin(SourceLocation b)
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Reads an AST files chain containing the contents of a translation unit.
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
bool operator<=(const FileID &RHS) const
friend bool operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
SourceRange(SourceLocation loc)
static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS)
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isValid() const
Return true if this is a valid SourceLocation object.
bool operator<(const FileID &RHS) const
static unsigned getHashValue(clang::FileID S)
PresumedLoc getPresumedLoc(bool UseLineDirectives=true) const
Represents an unpacked "presumed" location which can be presented to the user.
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
unsigned getLineNumber(bool *Invalid=nullptr) const
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
bool operator==(const SourceRange &X) const
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
void print(raw_ostream &OS, const SourceManager &SM) const
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
void setEnd(SourceLocation e)
const char * getCharacterData(bool *Invalid=nullptr) const
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
std::string printToString(const SourceManager &SM) const
unsigned getColumnNumber(bool *Invalid=nullptr) const