14#ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
15#define LLVM_CLANG_BASIC_SOURCELOCATION_H
19#include "llvm/ADT/StringRef.h"
27class FoldingSetNodeID;
56 unsigned getHashValue()
const {
return static_cast<unsigned>(ID); }
70 int getOpaqueValue()
const {
return ID; }
102 enum :
UIntTy { MacroIDBit = 1ULL << (8 *
sizeof(
UIntTy) - 1) };
118 UIntTy getOffset()
const {
return ID & ~MacroIDBit; }
120 static SourceLocation getFileLoc(
UIntTy ID) {
121 assert((
ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
127 static SourceLocation getMacroLoc(
UIntTy ID) {
128 assert((
ID & MacroIDBit) == 0 &&
"Ran out of source locations!");
130 L.ID = MacroIDBit |
ID;
138 assert(((getOffset()+Offset) & MacroIDBit) == 0 &&
"offset overflow");
194 return !(LHS == RHS);
232 return B ==
X.B &&
E ==
X.E;
236 return B !=
X.B ||
E !=
X.E;
241 return B <= other.B &&
E >= other.E;
258 bool IsTokenRange =
false;
306 const char *Filename =
nullptr;
315 :
Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
384 assert(SrcMgr &&
"SourceManager is NULL.");
440 assert(
Loc.isValid());
441 assert(SrcMgr ==
Loc.SrcMgr &&
"Loc comes from another SourceManager!");
460 LHS.SrcMgr == RHS.SrcMgr;
465 return !(LHS == RHS);
476 struct DenseMapInfo<
clang::FileID, void> {
486 return S.getHashValue();
497 template <>
struct DenseMapInfo<
clang::SourceLocation, void> {
509 return Loc.getHashValue();
Defines interfaces for clang::FileEntry and clang::FileEntryRef.
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
friend class SourceManagerTestHelper
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
OptionalFileEntryRef getFileEntryRef() 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.
Serialized encoding of SourceLocations without context.
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
The JSON file list parser is used to communicate input to InstallAPI.
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.
Diagnostic wrappers for TextAPI types for error reporting.
__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)