class ConstantInitBuilderBase

Declaration

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

Description

A convenience builder class for complex constant initializers, especially for anonymous global structures used by various language runtimes. The basic usage pattern is expected to be something like: ConstantInitBuilder builder(CGM); auto toplevel = builder.beginStruct(); toplevel.addInt(CGM.SizeTy, widgets.size()); auto widgetArray = builder.beginArray(); for (auto &widget : widgets) { auto widgetDesc = widgetArray.beginStruct(); widgetDesc.addInt(CGM.SizeTy, widget.getPower()); widgetDesc.add(CGM.GetAddrOfConstantString(widget.getName())); widgetDesc.add(CGM.GetAddrOfGlobal(widget.getInitializerDecl())); widgetDesc.finishAndAddTo(widgetArray); } widgetArray.finishAndAddTo(toplevel); auto global = toplevel.finishAndCreateGlobal("WIDGET_LIST", Align, /*constant*/ true);

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:51

Member Variables

private clang::CodeGen::CodeGenModule& CGM
private llvm::SmallVector<llvm::Constant*, 16> Buffer
private std::vector<SelfReference> SelfReferences
private bool Frozen = false

Method Overview

  • protected ConstantInitBuilderBase(clang::CodeGen::CodeGenModule & CGM)
  • private void abandon(size_t newEnd)
  • private clang::CodeGen::ConstantInitFuture createFuture(llvm::Constant * initializer)
  • private llvm::GlobalVariable * createGlobal(llvm::Constant * initializer, const llvm::Twine & name, clang::CharUnits alignment, bool constant = false, llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage, unsigned int addressSpace = 0)
  • private void resolveSelfReferences(llvm::GlobalVariable * GV)
  • private void setGlobalInitializer(llvm::GlobalVariable * GV, llvm::Constant * initializer)
  • protected ~ConstantInitBuilderBase()

Methods

ConstantInitBuilderBase(
    clang::CodeGen::CodeGenModule& CGM)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:69

Parameters

clang::CodeGen::CodeGenModule& CGM

void abandon(size_t newEnd)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:92

Parameters

size_t newEnd

clang::CodeGen::ConstantInitFuture createFuture(
    llvm::Constant* initializer)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:85

Parameters

llvm::Constant* initializer

llvm::GlobalVariable* createGlobal(
    llvm::Constant* initializer,
    const llvm::Twine& name,
    clang::CharUnits alignment,
    bool constant = false,
    llvm::GlobalValue::LinkageTypes linkage =
        llvm::GlobalValue::InternalLinkage,
    unsigned int addressSpace = 0)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:77

Parameters

llvm::Constant* initializer
const llvm::Twine& name
clang::CharUnits alignment
bool constant = false
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage
unsigned int addressSpace = 0

void resolveSelfReferences(
    llvm::GlobalVariable* GV)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:90

Parameters

llvm::GlobalVariable* GV

void setGlobalInitializer(
    llvm::GlobalVariable* GV,
    llvm::Constant* initializer)

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:87

Parameters

llvm::GlobalVariable* GV
llvm::Constant* initializer

~ConstantInitBuilderBase()

Declared at: clang/include/clang/CodeGen/ConstantInitBuilder.h:71