brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · b275ead Raw
190 lines · cpp
1/* Compile with:2   clang -g -c  odr-uniquing.cpp -o odr-uniquing/1.o3   cp odr-uniquing/1.o odr-uniquing/2.o4   The aim of these test is to check that all the 'type types' that5   should be uniqued through the ODR really are.6   7   The resulting object file is linked against itself using a fake8   debug map. The end result is:9    - with ODR uniquing: all types (expect for the union for now) in10   the second CU should point back to the types of the first CU.11    - without ODR uniquing: all types are re-emited in the second CU12 */13 14// RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -v -debug-info - | FileCheck -check-prefixes=ODR,CHECK %s15// RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -no-odr -o - | llvm-dwarfdump -v -debug-info - | FileCheck -check-prefixes=NOODR,CHECK %s16 17// RUN: dsymutil --linker parallel -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -no-odr -o - | llvm-dwarfdump -v -debug-info - | FileCheck -check-prefixes=NOODR,CHECK %s18 19// The first compile unit contains all the types:20// CHECK: TAG_compile_unit21// CHECK-NOT: DW_TAG22// CHECK: AT_name{{.*}}"odr-uniquing.cpp"23 24struct S {25  struct Nested {};26};27 28// CHECK: 0x[[S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type29// CHECK-NEXT: DW_AT_name{{.*}}"S"30// CHECK-NOT: NULL31// CHECK: 0x[[NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type32// CHECK-NOT: DW_TAG33// CHECK: DW_AT_name{{.*}}"Nested"34// CHECK: NULL35 36namespace N {37class C {};38}39 40// CHECK: DW_TAG_namespace41// CHECK-NEXT: DW_AT_name{{.*}}"N"42// CHECK-NOT: NULL43// CHECK: 0x[[NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type44// CHECK-NEXT: DW_AT_name{{.*}}"C"45// CHECK: NULL46 47union U {48  class C {} C;49  struct S {} S;50};51 52// CHECK:  0x[[U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type53// CHECK-NEXT: DW_AT_name{{.*}}"U"54// CHECK-NOT: NULL55// CHECK:  0x[[UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type56// CHECK-NOT: NULL57// CHECK:  0x[[US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type58// CHECK: NULL59 60typedef S AliasForS;61 62// CHECK: 0x[[ALIASFORS:[0-9a-f]*]]:{{.*}}DW_TAG_typedef63// CHECK-NEXT: DW_AT_type{{.*}}[[S]]64// CHECK-NEXT: DW_AT_name{{.*}}"AliasForS"65 66namespace {67class AnonC {};68}69 70// CHECK: DW_TAG_namespace71// CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}}72// CHECK: 0x[[ANONC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type73// CHECK-NEXT: DW_AT_name{{.*}}"AnonC"74 75// This function is only here to hold objects that refer to the above types.76void foo() {77  AliasForS s;78  S::Nested n;79  N::C nc;80  AnonC ac;81  U u;82}83 84// The second CU contents depend on whether we disabled ODR uniquing or85// not.86 87// CHECK: TAG_compile_unit88// CHECK-NOT: DW_TAG89// CHECK: AT_name{{.*}}"odr-uniquing.cpp"90 91// The union itself is not uniqued for now (for dsymutil-compatibility),92// but the types defined inside it should be.93// ODR: DW_TAG_union_type94// ODR-NEXT: DW_AT_name{{.*}}"U"95// ODR: DW_TAG_member96// ODR-NEXT: DW_AT_name{{.*}}"C"97// ODR-NOT: DW_TAG98// ODR: DW_AT_type{{.*}}[[UC]]99// ODR: DW_TAG_member100// ODR-NEXT: DW_AT_name{{.*}}"S"101// ODR-NOT: DW_TAG102// ODR: DW_AT_type{{.*}}[[US]]103 104// Check that the variables point to the right type105// ODR: DW_TAG_subprogram106// ODR-NOT: DW_TAG107// ODR: DW_AT_name{{.*}}"foo"108// ODR-NOT: NULL109// ODR: DW_TAG_variable110// ODR-NOT: DW_TAG111// ODR: DW_AT_name{{.*}}"s"112// ODR-NOT: DW_TAG113// ODR: DW_AT_type{{.*}}[[ALIASFORS]]114// ODR: DW_AT_name{{.*}}"n"115// ODR-NOT: DW_TAG116// ODR: DW_AT_type{{.*}}[[NESTED]]117// ODR: DW_TAG_variable118// ODR-NOT: DW_TAG119// ODR: DW_AT_name{{.*}}"nc"120// ODR-NOT: DW_TAG121// ODR: DW_AT_type{{.*}}[[NC]]122// ODR: DW_TAG_variable123// ODR-NOT: DW_TAG124// ODR: DW_AT_name{{.*}}"ac"125// ODR-NOT: DW_TAG126// ODR: DW_AT_type{{.*}}[[ANONC]]127 128// With no ODR uniquing, we should get copies of all the types:129 130// This is "struct S"131// NOODR: 0x[[DUP_S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type132// NOODR-NEXT: DW_AT_name{{.*}}"S"133// NOODR-NOT: NULL134// NOODR: 0x[[DUP_NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type135// NOODR-NOT: DW_TAG136// NOODR: DW_AT_name{{.*}}"Nested"137 138// This is "class N::C"139// NOODR: DW_TAG_namespace140// NOODR-NEXT: DW_AT_name{{.*}}"N"141// NOODR: 0x[[DUP_NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type142// NOODR-NEXT: DW_AT_name{{.*}}"C"143 144// This is "union U"145// NOODR:  0x[[DUP_U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type146// NOODR-NEXT: DW_AT_name{{.*}}"U"147// NOODR-NOT: NULL148// NOODR:  0x[[DUP_UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type149// NOODR-NOT: NULL150// NOODR:  0x[[DUP_US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type151// NOODR: NULL152 153// Check that the variables point to the right type154// NOODR: DW_TAG_subprogram155// NOODR-NOT: DW_TAG156// NOODR: DW_AT_name{{.*}}"foo"157// NOODR-NOT: NULL158// NOODR: DW_TAG_variable159// NOODR-NOT: DW_TAG160// NOODR: DW_AT_name{{.*}}"s"161// NOODR-NOT: DW_TAG162// NOODR: DW_AT_type{{.*}}0x[[DUP_ALIASFORS:[0-9a-f]*]]163// NOODR: DW_TAG_variable164// NOODR-NOT: DW_TAG165// NOODR: DW_AT_name{{.*}}"n"166// NOODR-NOT: DW_TAG167// NOODR: DW_AT_type{{.*}}[[DUP_NESTED]]168// NOODR: DW_TAG_variable169// NOODR-NOT: DW_TAG170// NOODR: DW_AT_name{{.*}}"nc"171// NOODR-NOT: DW_TAG172// NOODR: DW_AT_type{{.*}}[[DUP_NC]]173// NOODR: DW_TAG_variable174// NOODR-NOT: DW_TAG175// NOODR: DW_AT_name{{.*}}"ac"176// NOODR-NOT: DW_TAG177// NOODR: DW_AT_type{{.*}}0x[[DUP_ANONC:[0-9a-f]*]]178 179// This is "AliasForS"180// NOODR: 0x[[DUP_ALIASFORS]]:{{.*}}DW_TAG_typedef181// NOODR-NOT: DW_TAG182// NOODR: DW_AT_name{{.*}}"AliasForS"183 184// This is "(anonymous namespace)::AnonC"185// NOODR: DW_TAG_namespace186// NOODR-NOT: {{DW_AT_name|NULL|DW_TAG}}187// NOODR: 0x[[DUP_ANONC]]:{{.*}}DW_TAG_class_type188// NOODR-NEXT: DW_AT_name{{.*}}"AnonC"189 190