17#include "llvm/ADT/DenseMapInfo.h"
18#include "llvm/ADT/FoldingSet.h"
19#include "llvm/Support/Compiler.h"
20#include "llvm/Support/raw_ostream.h"
36 OS << Message <<
'\n';
43static_assert(std::is_trivially_destructible_v<SourceLocation>,
44 "SourceLocation must be trivially destructible because it is "
47static_assert(std::is_trivially_destructible_v<SourceRange>,
48 "SourceRange must be trivially destructible because it is "
52 return llvm::DenseMapInfo<UIntTy>::getHashValue(ID);
62 OS <<
"<invalid loc>";
79 SM.getExpansionLoc(*this).print(OS,
SM);
82 SM.getSpellingLoc(*this).print(OS,
SM);
86LLVM_DUMP_METHOD std::string
89 llvm::raw_string_ostream OS(S);
101 llvm::errs() <<
'\n';
111 OS <<
"<invalid sloc>";
145LLVM_DUMP_METHOD std::string
148 llvm::raw_string_ostream OS(S);
159 return SrcMgr->getFileID(*
this);
164 return FullSourceLoc(SrcMgr->getExpansionLoc(*
this), *SrcMgr);
168 return SrcMgr->getDecomposedExpansionLoc(*
this);
173 return FullSourceLoc(SrcMgr->getSpellingLoc(*
this), *SrcMgr);
185 return SrcMgr->getPresumedLoc(*
this, UseLineDirectives);
190 return SrcMgr->isMacroArgExpansion(*
this, StartLoc);
195 return FullSourceLoc(SrcMgr->getImmediateMacroCallerLoc(*
this), *SrcMgr);
202 std::pair<SourceLocation, StringRef> ImportLoc =
203 SrcMgr->getModuleImportLoc(*
this);
204 return std::make_pair(
FullSourceLoc(ImportLoc.first, *SrcMgr),
210 return SrcMgr->getFileOffset(*
this);
225 return SrcMgr->getFileEntryForID(
getFileID());
230 return SrcMgr->getFileEntryRefForID(
getFileID());
235 return SrcMgr->getExpansionLineNumber(*
this,
Invalid);
240 return SrcMgr->getExpansionColumnNumber(*
this,
Invalid);
245 return SrcMgr->getSpellingLineNumber(*
this,
Invalid);
250 return SrcMgr->getSpellingColumnNumber(*
this,
Invalid);
255 return SrcMgr->isInSystemHeader(*
this);
260 return SrcMgr->isBeforeInTranslationUnit(*
this, Loc);
269 return SrcMgr->getCharacterData(*
this,
Invalid);
274 return SrcMgr->getBufferData(SrcMgr->getFileID(*
this),
Invalid);
278 return SrcMgr->getDecomposedLoc(*
this);
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
static PresumedLoc PrintDifference(raw_ostream &OS, const SourceManager &SM, SourceLocation Loc, PresumedLoc Previous)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
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...
FullSourceLoc getFileLoc() const
unsigned getColumnNumber(bool *Invalid=nullptr) const
FileIDAndOffset getDecomposedExpansionLoc() const
Decompose the underlying SourceLocation into a raw (FileID + Offset) pair, after walking through all ...
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
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.
bool isInSystemHeader() const
const FileEntry * getFileEntry() const
unsigned getFileOffset() const
FullSourceLoc()=default
Creates a FullSourceLoc where isValid() returns false.
PresumedLoc getPresumedLoc(bool UseLineDirectives=true) const
FileIDAndOffset getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
bool isMacroArgExpansion(FullSourceLoc *StartLoc=nullptr) 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.
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.
void print(raw_ostream &OS) const override
Encodes a location in the source.
std::string printToString(const SourceManager &SM) const
void dump(const SourceManager &SM) const
bool isValid() const
Return true if this is a valid SourceLocation object.
void print(raw_ostream &OS, const SourceManager &SM) const
friend class SourceManager
unsigned getHashValue() const
This class handles loading and caching of source files into memory.
std::string printToString(const SourceManager &SM) const
void dump(const SourceManager &SM) const
void print(raw_ostream &OS, const SourceManager &SM) const
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
std::pair< FileID, unsigned > FileIDAndOffset