class Program

Declaration

class Program { /* full declaration omitted */ };

Description

The program contains and links the bytecode for all functions.

Declared at: clang/lib/AST/Interp/Program.h:40

Member Variables

private clang::interp::Context& Ctx
Reference to the VM context.
private llvm::DenseMap<const FunctionDecl*, std::unique_ptr<Function>> Funcs
Mapping from decls to cached bytecode functions.
private std::vector<std::unique_ptr<Function>> AnonFuncs
List of anonymous functions.
private llvm::DenseMap<const FunctionDecl*, std::vector<unsigned int>> Relocs
Function relocation locations.
private std::vector<const void*> NativePointers
Native pointers referenced by bytecode.
private llvm::DenseMap<const void*, unsigned int> NativePointerIndices
Cached native pointer indices.
private clang::interp::Program::PoolAllocTy Allocator
Allocator for globals.
private std::vector<Global*> Globals
Global objects.
private llvm::DenseMap<const void*, unsigned int> GlobalIndices
Cached global indices.
private llvm::DenseMap<const RecordDecl*, Record*> Records
Mapping from decls to record metadata.
private llvm::DenseMap<const ParmVarDecl*, unsigned int> DummyParams
Dummy parameter to generate pointers from.
private unsigned int LastDeclaration = 0
Last declaration ID.
private unsigned int CurrentDeclaration = NoDeclaration
Current declaration ID.
private static const unsigned int NoDeclaration = (unsigned int)-1
No declaration ID.

Method Overview

  • public Program(clang::interp::Context & Ctx)
  • private template <typename... Ts>clang::interp::Descriptor * allocateDescriptor(Ts &&... Args)
  • public clang::interp::Descriptor * createDescriptor(const clang::interp::DeclTy & D, const clang::Type * Ty, bool IsConst = false, bool IsTemporary = false, bool IsMutable = false)
  • public clang::interp::Descriptor * createDescriptor(const clang::interp::DeclTy & D, clang::interp::PrimType Type, bool IsConst = false, bool IsTemporary = false, bool IsMutable = false)
  • public template <typename... Ts>clang::interp::Function * createFunction(Ts &&... Args)
  • public template <typename... Ts>clang::interp::Function * createFunction(const clang::FunctionDecl * Def, Ts &&... Args)
  • public llvm::Optional<unsigned int> createGlobal(const clang::Expr * E)
  • private llvm::Optional<unsigned int> createGlobal(const clang::interp::DeclTy & D, clang::QualType Ty, bool IsStatic, bool IsExtern)
  • public llvm::Optional<unsigned int> createGlobal(const clang::ValueDecl * VD)
  • public unsigned int createGlobalString(const clang::StringLiteral * S)
  • public void dump(llvm::raw_ostream & OS) const
  • public void dump() const
  • private void endDeclaration()
  • public llvm::Optional<unsigned int> getCurrentDecl() const
  • public clang::interp::Function * getFunction(const clang::FunctionDecl * F)
  • public llvm::Optional<unsigned int> getGlobal(const clang::ValueDecl * VD)
  • public clang::interp::Block * getGlobal(unsigned int Idx)
  • public const void * getNativePointer(unsigned int Idx)
  • public llvm::Optional<unsigned int> getOrCreateDummy(const clang::ParmVarDecl * PD)
  • public llvm::Expected<Function *> getOrCreateFunction(const clang::FunctionDecl * F)
  • public llvm::Optional<unsigned int> getOrCreateGlobal(const clang::ValueDecl * VD)
  • public unsigned int getOrCreateNativePointer(const void * Ptr)
  • public clang::interp::Record * getOrCreateRecord(const clang::RecordDecl * RD)
  • public clang::interp::Pointer getPtrGlobal(unsigned int Idx)
  • private void startDeclaration(const clang::VarDecl * Decl)

Methods

Program(clang::interp::Context& Ctx)

Declared at: clang/lib/AST/Interp/Program.h:42

Parameters

clang::interp::Context& Ctx

template <typename... Ts>
clang::interp::Descriptor* allocateDescriptor(
    Ts&&... Args)

Description

Creates a new descriptor.

Declared at: clang/lib/AST/Interp/Program.h:197

Templates

Ts

Parameters

Ts&&... Args

clang::interp::Descriptor* createDescriptor(
    const clang::interp::DeclTy& D,
    const clang::Type* Ty,
    bool IsConst = false,
    bool IsTemporary = false,
    bool IsMutable = false)

Description

Creates a descriptor for a composite type.

Declared at: clang/lib/AST/Interp/Program.h:112

Parameters

const clang::interp::DeclTy& D
const clang::Type* Ty
bool IsConst = false
bool IsTemporary = false
bool IsMutable = false

clang::interp::Descriptor* createDescriptor(
    const clang::interp::DeclTy& D,
    clang::interp::PrimType Type,
    bool IsConst = false,
    bool IsTemporary = false,
    bool IsMutable = false)

Description

Creates a descriptor for a primitive type.

Declared at: clang/lib/AST/Interp/Program.h:104

Parameters

const clang::interp::DeclTy& D
clang::interp::PrimType Type
bool IsConst = false
bool IsTemporary = false
bool IsMutable = false

template <typename... Ts>
clang::interp::Function* createFunction(
    Ts&&... Args)

Description

Creates an anonymous function.

Declared at: clang/lib/AST/Interp/Program.h:86

Templates

Ts

Parameters

Ts&&... Args

template <typename... Ts>
clang::interp::Function* createFunction(
    const clang::FunctionDecl* Def,
    Ts&&... Args)

Description

Creates a new function from a code range.

Declared at: clang/lib/AST/Interp/Program.h:79

Templates

Ts

Parameters

const clang::FunctionDecl* Def
Ts&&... Args

llvm::Optional<unsigned int> createGlobal(
    const clang::Expr* E)

Description

Creates a global from a lifetime-extended temporary.

Declared at: clang/lib/AST/Interp/Program.h:75

Parameters

const clang::Expr* E

llvm::Optional<unsigned int> createGlobal(
    const clang::interp::DeclTy& D,
    clang::QualType Ty,
    bool IsStatic,
    bool IsExtern)

Declared at: clang/lib/AST/Interp/Program.h:136

Parameters

const clang::interp::DeclTy& D
clang::QualType Ty
bool IsStatic
bool IsExtern

llvm::Optional<unsigned int> createGlobal(
    const clang::ValueDecl* VD)

Description

Creates a global and returns its index.

Declared at: clang/lib/AST/Interp/Program.h:72

Parameters

const clang::ValueDecl* VD

unsigned int createGlobalString(
    const clang::StringLiteral* S)

Description

Emits a string literal among global data.

Declared at: clang/lib/AST/Interp/Program.h:51

Parameters

const clang::StringLiteral* S

void dump(llvm::raw_ostream& OS) const

Declared at: clang/lib/AST/Interp/Program.h:222

Parameters

llvm::raw_ostream& OS

void dump() const

Description

Dumps the disassembled bytecode to \c llvm::errs().

Declared at: clang/lib/AST/Interp/Program.h:221

void endDeclaration()

Description

Ends a global declaration.

Declared at: clang/lib/AST/Interp/Program.h:215

llvm::Optional<unsigned int> getCurrentDecl()
    const

Description

Returns the current declaration ID.

Declared at: clang/lib/AST/Interp/Program.h:127

clang::interp::Function* getFunction(
    const clang::FunctionDecl* F)

Description

Returns a function.

Declared at: clang/lib/AST/Interp/Program.h:93

Parameters

const clang::FunctionDecl* F

llvm::Optional<unsigned int> getGlobal(
    const clang::ValueDecl* VD)

Description

Finds a global's index.

Declared at: clang/lib/AST/Interp/Program.h:63

Parameters

const clang::ValueDecl* VD

clang::interp::Block* getGlobal(unsigned int Idx)

Description

Returns the value of a global.

Declared at: clang/lib/AST/Interp/Program.h:57

Parameters

unsigned int Idx

const void* getNativePointer(unsigned int Idx)

Description

Returns the value of a marshalled native pointer.

Declared at: clang/lib/AST/Interp/Program.h:48

Parameters

unsigned int Idx

llvm::Optional<unsigned int> getOrCreateDummy(
    const clang::ParmVarDecl* PD)

Description

Returns or creates a dummy value for parameters.

Declared at: clang/lib/AST/Interp/Program.h:69

Parameters

const clang::ParmVarDecl* PD

llvm::Expected<Function*> getOrCreateFunction(
    const clang::FunctionDecl* F)

Description

Returns a pointer to a function if it exists and can be compiled. If a function couldn't be compiled, an error is returned. If a function was not yet defined, a null pointer is returned.

Declared at: clang/lib/AST/Interp/Program.h:98

Parameters

const clang::FunctionDecl* F

llvm::Optional<unsigned int> getOrCreateGlobal(
    const clang::ValueDecl* VD)

Description

Returns or creates a global an creates an index to it.

Declared at: clang/lib/AST/Interp/Program.h:66

Parameters

const clang::ValueDecl* VD

unsigned int getOrCreateNativePointer(
    const void* Ptr)

Description

Marshals a native pointer to an ID for embedding in bytecode.

Declared at: clang/lib/AST/Interp/Program.h:45

Parameters

const void* Ptr

clang::interp::Record* getOrCreateRecord(
    const clang::RecordDecl* RD)

Description

Returns a record or creates one if it does not exist.

Declared at: clang/lib/AST/Interp/Program.h:101

Parameters

const clang::RecordDecl* RD

clang::interp::Pointer getPtrGlobal(
    unsigned int Idx)

Description

Returns a pointer to a global.

Declared at: clang/lib/AST/Interp/Program.h:54

Parameters

unsigned int Idx

void startDeclaration(const clang::VarDecl* Decl)

Description

Starts evaluating a declaration.

Declared at: clang/lib/AST/Interp/Program.h:209

Parameters

const clang::VarDecl* Decl