|
| 1 | +; RUN: not opt -S < %s 2>&1 | FileCheck %s |
| 2 | + |
| 3 | +;; Test that extraData with MDTuple is only allowed for specific DWARF tags: |
| 4 | +;; DW_TAG_inheritance, DW_TAG_member, and DW_TAG_variable |
| 5 | + |
| 6 | +!llvm.module.flags = !{!0} |
| 7 | +!0 = !{i32 2, !"Debug Info Version", i32 3} |
| 8 | + |
| 9 | +!1 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 10 | + |
| 11 | +; Keep all metadata nodes alive so verifier can check them |
| 12 | +!named = !{!1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19} |
| 13 | +!2 = !{i32 0} |
| 14 | + |
| 15 | +; Valid: DW_TAG_inheritance with tuple extraData should be accepted |
| 16 | +!3 = !DIDerivedType(tag: DW_TAG_inheritance, baseType: !1, size: 32, extraData: !2) |
| 17 | + |
| 18 | +; Valid: DW_TAG_member with tuple extraData should be accepted |
| 19 | +!4 = !DIDerivedType(tag: DW_TAG_member, name: "field", baseType: !1, size: 32, extraData: !2) |
| 20 | + |
| 21 | +; Valid: DW_TAG_variable (static member) with tuple extraData should be accepted |
| 22 | +!5 = !DIDerivedType(tag: DW_TAG_variable, name: "var", baseType: !1, extraData: !2, flags: DIFlagStaticMember) |
| 23 | + |
| 24 | +; Invalid: DW_TAG_typedef with tuple extraData should be rejected |
| 25 | +; CHECK: extraData must be ConstantAsMetadata, MDString, DIObjCProperty, or MDTuple with single ConstantAsMetadata operand |
| 26 | +; CHECK-NEXT: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_typedef |
| 27 | +!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "IntTy", baseType: !1, extraData: !2) |
| 28 | + |
| 29 | +; Invalid: Empty tuple should be rejected |
| 30 | +!7 = !{} |
| 31 | +; CHECK: extraData must be ConstantAsMetadata, MDString, DIObjCProperty, or MDTuple with single ConstantAsMetadata operand |
| 32 | +; CHECK-NEXT: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_member |
| 33 | +!8 = !DIDerivedType(tag: DW_TAG_member, name: "field2", baseType: !1, extraData: !7) |
| 34 | + |
| 35 | +; Invalid: Tuple with multiple operands should be rejected |
| 36 | +!9 = !{i32 0, i32 1} |
| 37 | +; CHECK: extraData must be ConstantAsMetadata, MDString, DIObjCProperty, or MDTuple with single ConstantAsMetadata operand |
| 38 | +; CHECK-NEXT: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_member |
| 39 | +!10 = !DIDerivedType(tag: DW_TAG_member, name: "field3", baseType: !1, extraData: !9) |
| 40 | + |
| 41 | +; Invalid: Tuple with non-ConstantAsMetadata operand should be rejected |
| 42 | +!11 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) |
| 43 | +!12 = !{!11} |
| 44 | +; CHECK: extraData must be ConstantAsMetadata, MDString, DIObjCProperty, or MDTuple with single ConstantAsMetadata operand |
| 45 | +; CHECK-NEXT: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_member |
| 46 | +!13 = !DIDerivedType(tag: DW_TAG_member, name: "field4", baseType: !1, extraData: !12) |
| 47 | + |
| 48 | +; Valid: ConstantAsMetadata as extraData should still work for any tag |
| 49 | +!14 = !DIDerivedType(tag: DW_TAG_typedef, name: "IntTy2", baseType: !1, extraData: i32 42) |
| 50 | + |
| 51 | +; Valid: MDString as extraData should still work for any tag |
| 52 | +!15 = !DIDerivedType(tag: DW_TAG_typedef, name: "IntTy3", baseType: !1, extraData: !"some string") |
| 53 | + |
| 54 | +; Valid: DW_TAG_template_alias with proper template parameters tuple |
| 55 | +; Template aliases are handled specially and accept any MDTuple for template parameters |
| 56 | +!16 = !DITemplateTypeParameter(name: "T", type: !1) |
| 57 | +!17 = !{!16} |
| 58 | +!18 = !DIDerivedType(tag: DW_TAG_template_alias, name: "MyAlias", baseType: !1, extraData: !17) |
| 59 | + |
| 60 | +; Invalid: DW_TAG_template_alias with non-tuple extraData should fail |
| 61 | +; CHECK: invalid template parameters |
| 62 | +; CHECK-NEXT: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_template_alias |
| 63 | +!19 = !DIDerivedType(tag: DW_TAG_template_alias, name: "FailingAlias", baseType: !1, extraData: i32 42) |
| 64 | + |
| 65 | +; CHECK: warning: ignoring invalid debug info |
| 66 | + |
0 commit comments