[llvm-dev] StructType --> DICompositeType?
Troy Johnson via llvm-dev
llvm-dev at lists.llvm.org
Tue Jul 24 08:50:27 PDT 2018
Is there a more convenient way to obtain a DIType given a Type than matching up the strings for the names?
For example, given:
struct S {
int x, y;
} s;
void foo(S *a) {
a->x = 0;
a->y = 1;
}
There are DIType nodes for the struct Type:
!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS1S")
!7 = !{!8, !10}
!8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !3, line: 2, baseType: !9, size: 32)
!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!10 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !6, file: !3, line: 2, baseType: !9, size: 32, offset: 32)
but given just the StructType for S there is no direct way to get to the DICompositeType. I've made something work by prescanning all the DITypes in my Module and creating a map that uses type names as the key, being careful to strip "struct." prefixes and maintain scoping for nested structs (e.g., S1::S2), which works, but seems awfully complicated to need to do.
Seems like StructType should have a getMetaData() function, but I don't see one.
-Troy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180724/ccb9215e/attachment.html>
More information about the llvm-dev
mailing list