[LLVMdev] ConstantPointerRef and void*'s to functions

Chris Lattner sabre at nondot.org
Sat May 10 00:24:01 PDT 2003


> As I thought about this more, I realized that the problem is not as easy
> as just transmuting the FunctionType from one FunctionType to another,
> since void* is not a FunctionType.

Sure, and the real type of the function is actual a
pointer_to(function_type) anyway.

> If the strict type-checking that is happening (the assert on
> Constants.cpp:233 in the ConstantStruct constructor) is the only problem
> here, and nothing more severe, perhaps the client should be able to set
> a flag that forces a the type of a ConstantPointerRef of a Function
> equal to what is returned by PointerType::get(Type::VoidTy), or some
> such thing. :)

Ick ick ick.  :)  No, just use the constant expr cast.  You can see an
example if you do something like this with the C front-end:

void foo();
void *Ptr = &foo;

You generate ConstantExpr's programatically with the ConstantExpr::get*
methods.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list