xref: /llvm-project/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-anon-namespace.cpp (revision f1fdfe6888f93b9f6dfb4689e1f3206de584ff5b)
1 /* Compile with:
2    for FILE in `seq 2`; do
3      clang -g -c  odr-anon-namespace.cpp -DFILE$FILE -o odr-anon-namespace/$FILE.o
4    done
5  */
6 
7 // RUN: dsymutil --linker parallel -f \
8 // RUN:   -oso-prepend-path=%p/../../Inputs/odr-anon-namespace \
9 // RUN:   -y %p/../dummy-debug-map.map -o - | \
10 // RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
11 
12 #ifdef FILE1
13 // Currently dsymutil will unique the contents of anonymous
14 // namespaces if they are from the same file/line. Force this
15 // namespace to appear different eventhough it's the same (this
16 // uniquing is actually a bug kept for backward compatibility, see the
17 // comments in DeclContextTree::getChildDeclContext()).
18 #line 42
19 #endif
20 namespace {
21 class C {};
22 }
23 
foo()24 void foo() {
25   C c;
26 }
27 
28 // Keep the ifdef guards for FILE1 and FILE2 even if all the code is
29 // above to clearly show what the CHECK lines are testing.
30 #ifdef FILE1
31 
32 // CHECK: TAG_compile_unit
33 // CHECK-NOT: DW_TAG
34 // CHECK: AT_name{{.*}}"odr-anon-namespace.cpp"
35 
36 // CHECK: DW_TAG_variable
37 // CHECK-NOT: DW_TAG
38 // CHECK: DW_AT_name {{.*}}"c"
39 // CHECK-NOT: DW_TAG
40 // CHECK: DW_AT_type {{.*}}0x[[C_FILE1:[0-9a-f]*]]
41 
42 // CHECK: DW_TAG_namespace
43 // CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}}
44 // CHECK: 0x[[C_FILE1]]:{{.*}}DW_TAG_class_type
45 // CHECK-NOT: DW_TAG
46 // CHECK: DW_AT_name{{.*}}"C"
47 
48 #elif defined(FILE2)
49 
50 // CHECK: TAG_compile_unit
51 // CHECK-NOT: DW_TAG
52 // CHECK: AT_name{{.*}}"odr-anon-namespace.cpp"
53 
54 // CHECK: DW_TAG_variable
55 // CHECK-NOT: DW_TAG
56 // CHECK: DW_AT_name {{.*}}"c"
57 // CHECK-NOT: DW_TAG
58 // CHECK: DW_AT_type {{.*}}0x[[C_FILE2:[0-9a-f]*]]
59 
60 // CHECK: DW_TAG_namespace
61 // CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}}
62 // CHECK: 0x[[C_FILE2]]:{{.*}}DW_TAG_class_type
63 // CHECK-NOT: DW_TAG
64 // CHECK: DW_AT_name{{.*}}"C"
65 
66 #else
67 #error "You must define which file you generate"
68 #endif
69