13 #ifndef LLVM_CLANG_AST_INTERP_SOURCE_H 14 #define LLVM_CLANG_AST_INTERP_SOURCE_H 18 #include "llvm/Support/Endian.h" 35 assert(Ptr !=
nullptr && RHS.Ptr !=
nullptr &&
"Invalid code pointer");
40 assert(Ptr !=
nullptr &&
"Invalid code pointer");
47 template <
typename T> T
read() {
48 T
Value = ReadHelper<T>(Ptr);
55 CodePtr(
const char *Ptr) : Ptr(Ptr) {}
59 static typename std::enable_if<!std::is_pointer<T>::value, T>
::type 60 ReadHelper(
const char *Ptr) {
61 using namespace llvm::support;
62 return endian::read<T, endianness::native, 1>(Ptr);
66 static typename std::enable_if<std::is_pointer<T>::value, T>
::type 67 ReadHelper(
const char *Ptr) {
68 using namespace llvm::support;
69 auto Punned = endian::read<uintptr_t, endianness::native, 1>(Ptr);
70 return reinterpret_cast<T
>(Punned);
91 const Expr *asExpr()
const;
93 operator bool()
const {
return !Source.isNull(); }
96 llvm::PointerUnion<const Decl *, const Stmt *> Source;
99 using SourceMap = std::vector<std::pair<unsigned, SourceInfo>>;
bool operator!=(const CodePtr &RHS) const
int32_t operator-(const CodePtr &RHS) const
Stmt - This represents one statement.
Pointer into the code segment.
Interface for classes which map locations to sources.
Decl - This represents one declaration (or definition), e.g.
constexpr XRayInstrMask Function
Describes the statement/declaration an opcode was generated from.
CodePtr & operator+=(int32_t Offset)
T read()
Reads data and advances the pointer.
const Stmt * asStmt() const
This represents one expression.
SourceInfo(const Decl *D)
const Decl * asDecl() const
CodePtr operator-(size_t RHS) const
Encodes a location in the source.
Dataflow Directional Tag Classes.
std::vector< std::pair< unsigned, SourceInfo > > SourceMap
SourceInfo(const Stmt *E)