13#ifndef LLVM_CLANG_AST_INTERP_SOURCE_H
14#define LLVM_CLANG_AST_INTERP_SOURCE_H
19#include "llvm/ADT/PointerUnion.h"
20#include "llvm/Support/Endian.h"
42 assert(Ptr !=
nullptr && RHS.Ptr !=
nullptr &&
"Invalid code pointer");
47 assert(Ptr !=
nullptr &&
"Invalid code pointer");
53 explicit operator bool()
const {
return Ptr; }
59 template <
typename T> std::enable_if_t<!std::is_pointer<T>::value, T>
read() {
61 using namespace llvm::support;
62 T
Value = endian::read<T, llvm::endianness::native>(Ptr);
63 Ptr +=
align(
sizeof(T));
70 CodePtr(
const std::byte *Ptr) : Ptr(Ptr) {}
72 const std::byte *Ptr =
nullptr;
86 return dyn_cast_if_present<const Stmt *>(Source);
89 return dyn_cast_if_present<const Decl *>(Source);
93 operator bool()
const {
return !Source.isNull(); }
96 llvm::PointerUnion<const Decl *, const Stmt *> Source;
98static_assert(
sizeof(SourceInfo) ==
sizeof(
void *));
100using SourceMap = std::vector<std::pair<unsigned, SourceInfo>>;
Expr * getExpr()
Get 'expr' part of the associated expression/statement.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Pointer into the code segment.
bool operator<=(const CodePtr &RHS) const
bool operator==(const CodePtr RHS) const
const std::byte * operator*() const
std::enable_if_t<!std::is_pointer< T >::value, T > read()
Reads data and advances the pointer.
CodePtr operator+(int32_t Offset)
bool operator!=(const CodePtr &RHS) const
CodePtr & operator+=(int32_t Offset)
int32_t operator-(const CodePtr &RHS) const
bool operator>=(const CodePtr &RHS) const
CodePtr operator-(size_t RHS) const
Describes the statement/declaration an opcode was generated from.
SourceInfo(const Decl *D)
const Decl * asDecl() const
const Expr * asExpr() const
const Stmt * asStmt() const
SourceLocation getLoc() const
SourceRange getRange() const
SourceInfo(const Stmt *E)
Interface for classes which map locations to sources.
virtual SourceInfo getSource(const Function *F, CodePtr PC) const =0
Returns source information for a given PC in a function.
SourceLocation getLocation(const Function *F, CodePtr PC) const
Returns the location from which an opcode originates.
SourceRange getRange(const Function *F, CodePtr PC) const
constexpr bool aligned(uintptr_t Value)
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
std::vector< std::pair< unsigned, SourceInfo > > SourceMap
The JSON file list parser is used to communicate input to InstallAPI.
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 int32_t