[LLVMdev] Question about recursive types

Haohui Mai haohui.mai at gmail.com
Fri Oct 3 10:42:04 PDT 2008


Dear all,

I'm trying to run the example of recursive type construction examples  
in LLVM Programmer's Manual, here is the code:

// Create the initial outer struct
PATypeHolder StructTy = OpaqueType::get();
std::vector<const Type*> Elts;
Elts.push_back(PointerType::get(StructTy));
Elts.push_back(Type::Int32Ty);
StructType *NewSTy = StructType::get(Elts);

// At this point, NewSTy = "{ opaque*, i32 }". Tell VMCore that
// the struct and the opaque type are actually the same.
cast<OpaqueType>(StructTy.get())->refineAbstractTypeTo(NewSTy);

// NewSTy is potentially invalidated, but StructTy (a PATypeHolder) is
// kept up-to-date
NewSTy = cast<StructType>(StructTy.get());

// Add a name for the type to the module symbol table (optional)
MyModule->addTypeName("mylist", NewSTy);


However, it does not work. The compiler says that the API of  
PointerType::get(PATypeHolder &) does not exist.

It seems that the API has been removed from LLVM trunk.

I'd be very appreciated if you could tell me how to construct  
Recursive Type using the LLVM trunk API.

Thank you very much.

Best,

Haohui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081003/3104064a/attachment.html>


More information about the llvm-dev mailing list