Home | History | Annotate | Download | only in X86
      1 /* Compile with:
      2    for FILE in `seq 3`; do
      3      clang -g -c  X86/odr-fwd-declaration2.cpp -DFILE$FILE -o Inputs/odr-fwd-declaration2/$FILE.o
      4    done
      5  */
      6 
      7 // RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-fwd-declaration2 -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
      8 
      9 #ifdef FILE1
     10 # 1 "Header.h" 1
     11 struct A {
     12   struct B;
     13   B *bPtr;
     14   B &bRef;
     15   int B::*bPtrToField;
     16 };
     17 # 3 "Source1.cpp" 2
     18 void foo() {
     19   A *ptr1 = 0;
     20 }
     21 
     22 // First we confirm that bPtr, bRef and bPtrToField reference the forward
     23 // declaration of the struct B.
     24 //
     25 // CHECK: DW_TAG_member
     26 // CHECK-NOT: {{DW_TAG|NULL}}
     27 // CHECK: AT_name{{.*}} "bPtr"
     28 // CHECK-NOT: {{DW_TAG|NULL}}
     29 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR1:[a-f0-9]*]]
     30 //
     31 // CHECK: [[STRUCT1:[a-f0-9]*]]:{{.*}}TAG_structure_type
     32 // CHECK-NOT: {{DW_TAG|NULL}}
     33 // CHECK: AT_name{{.*}} "B"
     34 // CHECK-NOT: AT_byte_size
     35 // CHECK: DW_AT_declaration
     36 //
     37 // CHECK: DW_TAG_member
     38 // CHECK: AT_name{{.*}} "bRef"
     39 // CHECK-NOT: {{DW_TAG|NULL}}
     40 // CHECK: AT_type{{.*}}0x{{0*}}[[REF1:[a-f0-9]*]]
     41 //
     42 // CHECK: TAG_member
     43 // CHECK-NOT: {{DW_TAG|NULL}}
     44 // CHECK: AT_name{{.*}} "bPtrToField"
     45 // CHECK-NOT: {{DW_TAG|NULL}}
     46 // CHECK: AT_type{{.*}}0x{{0*}}[[PTRTOMEMBER1:[a-f0-9]*]]
     47 //
     48 // CHECK: [[PTR1]]:{{.*}}TAG_pointer_type
     49 // CHECK-NOT: {{DW_TAG|NULL}}
     50 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT1]]
     51 //
     52 // CHECK: [[REF1]]:{{.*}}TAG_reference_type
     53 // CHECK-NOT: {{DW_TAG|NULL}}
     54 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT1]]
     55 //
     56 // CHECK: [[PTRTOMEMBER1]]:{{.*}}TAG_ptr_to_member_type
     57 // CHECK-NOT: {{DW_TAG|NULL}}
     58 // CHECK: AT_containing_type{{.*}}0x{{0*}}[[STRUCT1]]
     59 
     60 #elif defined(FILE2)
     61 # 1 "Header.h" 1
     62 struct A {
     63   struct B;
     64   B *bPtr;
     65   B &bRef;
     66   int B::*bPtrToField;
     67 };
     68 # 3 "Source2.cpp" 2
     69 struct A::B {
     70   int x;
     71 };
     72 void bar() {
     73   A *ptr2 = 0;
     74 }
     75 
     76 // Next we confirm that bPtr, bRef and bPtrToField reference the definition of
     77 // B, rather than its declaration.
     78 //
     79 // CHECK: [[STRUCTA:[a-f0-9]*]]:{{.*}}TAG_structure_type
     80 // CHECK-NOT: {{DW_TAG|NULL}}
     81 // CHECK: AT_name{{.*}} "A"
     82 // CHECK-NOT: AT_byte_size
     83 // CHECK: DW_AT_byte_size
     84 //
     85 // CHECK: DW_TAG_member
     86 // CHECK-NOT: {{DW_TAG|NULL}}
     87 // CHECK: AT_name{{.*}} "bPtr"
     88 // CHECK-NOT: {{DW_TAG|NULL}}
     89 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR2:[a-f0-9]*]]
     90 //
     91 // CHECK: [[STRUCT2:[a-f0-9]*]]:{{.*}}TAG_structure_type
     92 // CHECK-NOT: {{DW_TAG|NULL}}
     93 // CHECK: AT_name{{.*}} "B"
     94 // CHECK-NOT: {{DW_TAG|NULL}}
     95 // CHECK: DW_AT_byte_size
     96 //
     97 // CHECK: DW_TAG_member
     98 // CHECK: AT_name{{.*}} "bRef"
     99 // CHECK-NOT: {{DW_TAG|NULL}}
    100 // CHECK: AT_type{{.*}}0x{{0*}}[[REF2:[a-f0-9]*]]
    101 //
    102 // CHECK: TAG_member
    103 // CHECK-NOT: {{DW_TAG|NULL}}
    104 // CHECK: AT_name{{.*}} "bPtrToField"
    105 // CHECK-NOT: {{DW_TAG|NULL}}
    106 // CHECK: AT_type{{.*}}0x{{0*}}[[PTRTOMEMBER2:[a-f0-9]*]]
    107 //
    108 // CHECK: [[PTR2]]:{{.*}}TAG_pointer_type
    109 // CHECK-NOT: {{DW_TAG|NULL}}
    110 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT2]]
    111 //
    112 // CHECK: [[REF2]]:{{.*}}TAG_reference_type
    113 // CHECK-NOT: {{DW_TAG|NULL}}
    114 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT2]]
    115 //
    116 // CHECK: [[PTRTOMEMBER2]]:{{.*}}TAG_ptr_to_member_type
    117 // CHECK-NOT: {{DW_TAG|NULL}}
    118 // CHECK: AT_containing_type{{.*}}0x{{0*}}[[STRUCT2:[a-f0-9]*]]
    119 
    120 #elif defined(FILE3)
    121 # 1 "Header.h" 1
    122 struct A {
    123   struct B;
    124   B *bPtr;
    125   B &bRef;
    126   int B::*bPtrToField;
    127 };
    128 # 3 "Source2.cpp" 2
    129 struct A::B {
    130   int x;
    131 };
    132 void bar() {
    133   A *ptr2 = 0;
    134 }
    135 
    136 // Finally we confirm that uniquing isn't broken by checking that further
    137 // references to 'struct A' point to its now complete definition.
    138 //
    139 // CHECK: TAG_variable
    140 // CHECK-NOT: {{DW_TAG|NULL}}
    141 // CHECK: AT_name{{.*}} "ptr2"
    142 // CHECK-NOT: {{DW_TAG|NULL}}
    143 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR3:[a-f0-9]*]]
    144 //
    145 // CHECK: [[PTR3]]:{{.*}}TAG_pointer_type
    146 // CHECK-NOT: {{DW_TAG|NULL}}
    147 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCTA]]
    148 
    149 #else
    150 #error "You must define which file you generate"
    151 #endif
    152