[LLVMdev] ConstantBuilder proposal

Frits van Bommel fvbommel at gmail.com
Fri Feb 4 14:12:29 PST 2011


If you remove all the 'static's from the member functions, it'd work
more like IRBuilder.
It would also allow you to take the LLVMContext& as a constructor
parameter, so that methods like this:

On Fri, Feb 4, 2011 at 6:57 PM, Talin <viridia at gmail.com> wrote:
>   /// GetStruct - return a constant struct given a context and a vector
>   /// of elements.
>   static Constant *GetStruct(
>     LLVMContext &Context,
>     const std::vector<Constant*> &V,
>     bool Packed = false) {
>     return ConstantStruct::get(Context, V, Packed);
>   }

can remove it from their parameter list. It's probably pretty unlikely
a given ConstantBuilder instance would be used with multiple
LLVMContexts.

Making this a class you need an instance of would likely also allow
typing to be reduced a bit because said instance can be given a
shorter name than 'ConstantBuilder'. For example: 'cb.GetStruct(...)'
instead of 'ConstantBuilder::GetStruct(MyContext, ...)'.




More information about the llvm-dev mailing list