[LLVMdev] Problems when refining type

Scott Graham scott.llvm at h4ck3r.net
Mon Sep 8 14:45:29 PDT 2008


Hi

I'm using the llvm-c wrapper, and trying to build some recursive types
(using released 2.3).

I get an assert on trying to create a second opaque pointer type after
refining a first.

The first time through creating an opaque pointer type, a new type is
created and returned from PointerType::get, but the second time,
ValueType (the opaque type) is found in the PointerTypes map, which
seems to cause problems. I sort of feel like it probably shouldn't be
found because the opaque types should be distinct, but I also don't
really understand how it ought to work, so maybe I'm way off base.

-------------
#include "Core.h"

int main()
{
    LLVMTypeRef a = LLVMPointerType(LLVMOpaqueType(), 0);
    LLVMTypeHandleRef ha = LLVMCreateTypeHandle(a);
    LLVMTypeRef atypes[1] = { LLVMResolveTypeHandle(ha) };
    LLVMRefineType(LLVMResolveTypeHandle(ha), LLVMStructType(atypes, 1, 0));

    LLVMTypeRef b = LLVMPointerType(LLVMOpaqueType(), 0);     // assert here
    ....
}
-------------
The assertion text is:

Assertion failed: isa<X>(Val) && "cast<Ty>() argument of incompatible
type!", file ...\llvm\include\llvm/Support/Casting.h, line 199

Can anyone explain what I'm doing wrong here?

thanks,
scott



More information about the llvm-dev mailing list