14#ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
15#define LLVM_CLANG_BASIC_SOURCELOCATION_H
18#include "llvm/ADT/StringRef.h"
26class 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) };
102 bool isFileID()
const {
return (ID & MacroIDBit) == 0; }
103 bool isMacroID()
const {
return (ID & MacroIDBit) != 0; }
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.");
439 assert(SrcMgr == Loc.SrcMgr &&
"Loc comes from another SourceManager!");
458 LHS.SrcMgr == RHS.SrcMgr;
463 return !(LHS == RHS);
474 struct DenseMapInfo<
clang::FileID, void> {
484 return S.getHashValue();
495 template <>
struct DenseMapInfo<
clang::SourceLocation, void> {
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Reads an AST files chain containing the contents of a translation unit.
Writes an AST file containing the contents of a translation unit.
Represents a character-granular source range.
void setEnd(SourceLocation e)
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E)
static CharSourceRange getCharRange(SourceRange R)
void setBegin(SourceLocation b)
static CharSourceRange getTokenRange(SourceRange R)
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setTokenRange(bool TR)
CharSourceRange()=default
CharSourceRange(SourceRange R, bool ITR)
SourceRange getAsRange() const
Cached information about one file (either on disk or in the virtual file system).
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool operator<(const FileID &RHS) const
unsigned getHashValue() const
bool operator>(const FileID &RHS) const
bool operator==(const FileID &RHS) const
bool operator>=(const FileID &RHS) const
bool operator!=(const FileID &RHS) const
bool operator<=(const FileID &RHS) const
static FileID getSentinel()
A SourceLocation and its associated SourceManager.
FullSourceLoc getFileLoc() const
unsigned getColumnNumber(bool *Invalid=nullptr) const
FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
std::pair< FileID, unsigned > getDecomposedExpansionLoc() const
Decompose the underlying SourceLocation into a raw (FileID + Offset) pair, after walking through all ...
bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const
Determines the order of 2 source locations in the translation unit.
FullSourceLoc getExpansionLoc() const
unsigned getLineNumber(bool *Invalid=nullptr) const
FullSourceLoc getSpellingLoc() const
std::pair< FullSourceLoc, StringRef > getModuleImportLoc() const
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
FullSourceLoc getImmediateMacroCallerLoc() const
friend bool operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
const char * getCharacterData(bool *Invalid=nullptr) const
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
StringRef getBufferData(bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
void dump() const
Prints information about this FullSourceLoc to stderr.
friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
bool isInSystemHeader() const
const FileEntry * getFileEntry() const
unsigned getFileOffset() const
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
FullSourceLoc()=default
Creates a FullSourceLoc where isValid() returns false.
PresumedLoc getPresumedLoc(bool UseLineDirectives=true) const
bool hasManager() const
Checks whether the SourceManager is present.
bool isMacroArgExpansion(FullSourceLoc *StartLoc=nullptr) const
const SourceManager & getManager() const
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
unsigned getSpellingColumnNumber(bool *Invalid=nullptr) const
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co, SourceLocation IL)
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
Encodes a location in the source.
void * getPtrEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
std::string printToString(const SourceManager &SM) const
void dump(const SourceManager &SM) const
static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End)
bool isValid() const
Return true if this is a valid SourceLocation object.
void print(raw_ostream &OS, const SourceManager &SM) const
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
unsigned getHashValue() const
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.
A trivial tuple used to represent a source range.
SourceRange(SourceLocation loc)
bool operator==(const SourceRange &X) const
void setBegin(SourceLocation b)
bool fullyContains(const SourceRange &other) const
SourceLocation getEnd() const
SourceLocation getBegin() const
std::string printToString(const SourceManager &SM) const
bool operator!=(const SourceRange &X) const
void dump(const SourceManager &SM) const
void setEnd(SourceLocation e)
SourceRange(SourceLocation begin, SourceLocation end)
void print(raw_ostream &OS, const SourceManager &SM) const
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator!=(CanQual< T > x, CanQual< U > y)
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
YAML serialization mapping.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Comparison function class, useful for sorting FullSourceLocs.
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
static unsigned getHashValue(clang::FileID S)
static bool isEqual(clang::FileID LHS, clang::FileID RHS)
static clang::FileID getTombstoneKey()
static clang::FileID getEmptyKey()
static clang::SourceLocation getTombstoneKey()
static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS)
static clang::SourceLocation getEmptyKey()
static unsigned getHashValue(clang::SourceLocation Loc)
static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID)