14 #ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H 15 #define LLVM_CLANG_BASIC_SOURCELOCATION_H 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/Support/PointerLikeTypeTraits.h" 27 template <
typename T>
struct DenseMapInfo;
68 int getOpaqueValue()
const {
return ID; }
98 bool isFileID()
const {
return (ID & MacroIDBit) == 0; }
99 bool isMacroID()
const {
return (ID & MacroIDBit) != 0; }
111 unsigned getOffset()
const {
112 return ID & ~MacroIDBit;
116 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
123 assert((ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
125 L.ID = MacroIDBit |
ID;
133 assert(((getOffset()+Offset) & MacroIDBit) == 0 &&
"offset overflow");
164 return (
void*)(
uintptr_t)getRawEncoding();
170 return getFromRawEncoding((
unsigned)(
uintptr_t)Encoding);
188 return !(LHS == RHS);
215 return B == X.B && E == X.E;
219 return B != X.B || E != X.E;
236 bool IsTokenRange =
false;
293 : Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
300 bool isValid()
const {
return Filename !=
nullptr; }
356 bool hasSrcMgr = SrcMgr !=
nullptr;
357 assert(hasSrcMgr == isValid() &&
"FullSourceLoc has location but no manager");
363 assert(SrcMgr &&
"SourceManager is NULL.");
372 PresumedLoc getPresumedLoc(
bool UseLineDirectives =
true)
const;
373 bool isMacroArgExpansion(
FullSourceLoc *StartLoc =
nullptr)
const;
375 std::pair<FullSourceLoc, StringRef> getModuleImportLoc()
const;
376 unsigned getFileOffset()
const;
378 unsigned getExpansionLineNumber(
bool *Invalid =
nullptr)
const;
379 unsigned getExpansionColumnNumber(
bool *Invalid =
nullptr)
const;
381 unsigned getSpellingLineNumber(
bool *Invalid =
nullptr)
const;
382 unsigned getSpellingColumnNumber(
bool *Invalid =
nullptr)
const;
384 const char *getCharacterData(
bool *Invalid =
nullptr)
const;
386 unsigned getLineNumber(
bool *Invalid =
nullptr)
const;
387 unsigned getColumnNumber(
bool *Invalid =
nullptr)
const;
393 StringRef getBufferData(
bool *Invalid =
nullptr)
const;
399 std::pair<FileID, unsigned> getDecomposedLoc()
const;
401 bool isInSystemHeader()
const;
413 assert(SrcMgr == Loc.SrcMgr &&
"Loc comes from another SourceManager!");
432 LHS.SrcMgr == RHS.SrcMgr;
437 return !(LHS == RHS);
469 enum { NumLowBitsAvailable = 0 };
482 #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H
bool operator>=(const FileID &RHS) const
bool operator==(const SourceLocation &LHS, const SourceLocation &RHS)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS)
void setBegin(SourceLocation b)
bool operator<(const SourceLocation &LHS, const SourceLocation &RHS)
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
static CharSourceRange getTokenRange(SourceRange R)
bool operator>(const FileID &RHS) const
static FileID getSentinel()
void setBegin(SourceLocation b)
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
SourceLocation getBegin() const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
unsigned getHashValue() const
friend bool operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceRange(SourceLocation loc)
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E)
void setTokenRange(bool TR)
static void * getAsVoidPointer(clang::SourceLocation L)
static unsigned getHashValue(clang::FileID S)
bool operator==(const FileID &RHS) const
Represents a character-granular source range.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
const AnnotatedLine * Line
bool operator<(const FileID &RHS) const
unsigned getLine() const
Return the presumed line number of this location.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool operator!=(const SourceRange &X) const
const SourceManager & getManager() const
void setEnd(SourceLocation e)
SourceRange(SourceLocation begin, SourceLocation end)
Represents an unpacked "presumed" location which can be presented to the user.
SourceLocation getEnd() const
bool operator<=(const FileID &RHS) const
bool operator==(const SourceRange &X) const
static CharSourceRange getCharRange(SourceRange R)
const char * getFilename() const
Return the presumed filename of this location.
unsigned getColumn() const
Return the presumed column number of this location.
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
Encodes a location in the source.
bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const
Determines the order of 2 source locations in the translation unit.
Cached information about one file (either on disk or in the virtual file system). ...
static bool isEqual(clang::FileID LHS, clang::FileID RHS)
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E)
PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co, SourceLocation IL)
bool operator!=(const FileID &RHS) const
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
SourceRange getAsRange() const
Dataflow Directional Tag Classes.
static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End)
bool isValid() const
Return true if this is a valid SourceLocation object.
Reads an AST files chain containing the contents of a translation unit.
static clang::FileID getEmptyKey()
FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
Comparison function class, useful for sorting FullSourceLocs.
SourceLocation getEnd() const
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 ...
void setEnd(SourceLocation e)
static clang::FileID getTombstoneKey()
Writes an AST file containing the contents of a translation unit.
A SourceLocation and its associated SourceManager.
static clang::SourceLocation getFromVoidPointer(void *P)
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.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
SourceLocation getBegin() const
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...