[LLVMdev] [un]wrapping llvm:DITypeRef

Rodney M. Bates
Tue, 28 Jul 2015 23:11:43 -0000

On 07/27/2015 10:55 PM, Duncan P. N. Exon Smith wrote:
>
>> On 2015-Jul-25, at 15:44, Rodney M. Bates <rodney_bates at
lcwb.coop> wrote:
>>
>> In trying to write a C binding for DIBuilder of llvm 3.6.1, I can't
see a way to unwrap
>> llvm::DITypeRef, declared in include/llvm/IR/DebugInfo.h.  This is a
class with one
>> data member, a pointer to Metadata.
>>
>> If I try to make my C type a struct with one pointer, I can't cast
it to DITypeRef.
>> If I try to go inside the classes and use the pointer, I can cast, but
can't construct
>> a DITypeRef when unwrapping, as both its pointer field 'Val'
and the constructor are
>> private.
>
> This was probably an oversight.  Frankly, I'm not sure DITypeRef should
> really be in the DIBuilder API -- frontends should probably just pass
> in a DIType.
>
> Note that in ToT, DITypeRef has completely changed; it's a typedef from
> `TypedDINodeRef<DIType>` and has a public constructor from
`Metadata*`.
>
> I suggest you just make the constructor public in your local copy of
> LLVM; even better, work off of the LLVM 3.7 branch (better still, work
> off of ToT).
>

Thanks, that helps.