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"
40 assert(Ptr !=
nullptr && RHS.Ptr !=
nullptr &&
"Invalid code pointer");
45 assert(Ptr !=
nullptr &&
"Invalid code pointer");
49 assert(Ptr !=
nullptr &&
"Invalid code pointer");
55 explicit operator bool()
const {
return Ptr; }
60 template <
typename T> std::enable_if_t<!std::is_pointer<T>::value,
T>
read() {
62 using namespace llvm::support;
63 T Value = endian::read<T, llvm::endianness::native>(Ptr);
71 CodePtr(
const std::byte *Ptr) : Ptr(Ptr) {}
73 const std::byte *Ptr =
nullptr;
90 operator bool()
const {
return !Source.isNull(); }
93 llvm::PointerUnion<const Decl *, const Stmt *> Source;
96using SourceMap = std::vector<std::pair<unsigned, SourceInfo>>;
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
const std::byte * operator*() const
std::enable_if_t<!std::is_pointer< T >::value, T > read()
Reads data and advances the pointer.
bool operator!=(const CodePtr &RHS) const
CodePtr & operator+=(int32_t Offset)
CodePtr operator+(ssize_t RHS) const
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
const Expr * getExpr(const Function *F, CodePtr PC) const
Returns the expression if an opcode belongs to one, null otherwise.
constexpr bool aligned(uintptr_t Value)
std::vector< std::pair< unsigned, SourceInfo > > SourceMap
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T