1/* Compile with: 2 cat >modules.modulemap <<EOF 3 module Foo { 4 header "Foo.h" 5 export * 6 } 7 module Bar { 8 header "Bar.h" 9 export * 10 } 11EOF 12 clang -D BAR_H -E -o Bar.h modules.m 13 clang -D FOO_H -E -o Foo.h modules.m 14 clang -D ODR_VIOLATION_C -E -o odr_violation.c modules.m 15 clang -c -fmodules -fmodule-map-file=modules.modulemap \ 16 -g -gmodules -fmodules-cache-path=. \ 17 -Xclang -fdisable-module-hash modules.m -o 1.o 18 clang -c -g odr_violation.c -o 2.o 19*/ 20 21// RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/modules \ 22// RUN: -y %p/dummy-debug-map.map -o - \ 23// RUN: | llvm-dwarfdump -v --debug-info - | FileCheck %s 24 25// RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/modules -y \ 26// RUN: %p/dummy-debug-map.map -o %t 2>&1 | FileCheck --check-prefix=WARN %s 27 28// WARN-NOT: warning: hash mismatch 29 30// --------------------------------------------------------------------- 31#ifdef BAR_H 32// --------------------------------------------------------------------- 33// CHECK: DW_TAG_compile_unit 34// CHECK-NOT: DW_TAG 35// CHECK: DW_TAG_module 36// CHECK-NEXT: DW_AT_name{{.*}}"Bar" 37// CHECK: 0x0[[BAR:.*]]: DW_TAG_structure_type 38// CHECK-NOT: DW_TAG 39// CHECK: DW_AT_name {{.*}}"Bar" 40// CHECK-NOT: DW_TAG 41// CHECK: DW_TAG_member 42// CHECK: DW_AT_name {{.*}}"value" 43// CHECK: DW_TAG_structure_type 44// CHECK-NOT: DW_TAG 45// CHECK: DW_AT_name {{.*}}"PruneMeNot" 46 47struct Bar { 48 int value; 49}; 50 51struct PruneMeNot; 52 53#else 54// --------------------------------------------------------------------- 55#ifdef FOO_H 56// --------------------------------------------------------------------- 57// CHECK: DW_TAG_compile_unit 58// CHECK-NOT: DW_TAG 59// CHECK: 0x0[[FOO:.*]]: DW_TAG_module 60// CHECK-NEXT: DW_AT_name{{.*}}"Foo" 61// CHECK-NOT: DW_TAG 62// CHECK: 0x0[[BARTD:.*]]: DW_TAG_typedef 63// CHECK-NOT: DW_TAG 64// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{0*}}[[BAR]] 65// CHECK: DW_TAG_structure_type 66// CHECK-NEXT: DW_AT_name{{.*}}"S" 67// CHECK-NOT: DW_TAG 68// CHECK: 0x0[[INTERFACE:.*]]: DW_TAG_structure_type 69// CHECK-NEXT: DW_AT_name{{.*}}"Foo" 70 71@import Bar; 72typedef struct Bar Bar; 73struct S {}; 74 75@interface Foo { 76 int ivar; 77} 78@end 79 80#else 81// --------------------------------------------------------------------- 82#ifdef ODR_VIOLATION_C 83// --------------------------------------------------------------------- 84 85struct Bar { 86 int i; 87}; 88typedef struct Bar Bar; 89Bar odr_violation = { 42 }; 90 91// --------------------------------------------------------------------- 92#else 93// --------------------------------------------------------------------- 94 95// CHECK: DW_TAG_compile_unit 96// CHECK: DW_AT_low_pc 97// CHECK-NOT: DW_TAG_module 98// CHECK-NOT: DW_TAG_typedef 99// 100// CHECK: DW_TAG_imported_declaration 101// CHECK-NOT: DW_TAG 102// CHECK: DW_AT_import [DW_FORM_ref_addr] (0x{{0*}}[[FOO]] 103// 104// CHECK: DW_TAG_subprogram 105// CHECK: DW_AT_name {{.*}}"main" 106// 107// CHECK: DW_TAG_variable 108// CHECK-NOT: DW_TAG 109// CHECK: DW_AT_name{{.*}}"bar" 110// CHECK-NOT: DW_TAG 111// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{0*}}[[BARTD]] 112// CHECK: DW_TAG_variable 113// CHECK-NOT: DW_TAG 114// CHECK: DW_AT_name{{.*}}"foo" 115// CHECK-NOT: DW_TAG 116// CHECK: DW_AT_type {{.*}}{0x{{0*}}[[PTR:.*]]} 117// 118// CHECK: 0x{{0*}}[[PTR]]: DW_TAG_pointer_type 119// CHECK-NEXT DW_AT_type [DW_FORM_ref_addr] {0x{{0*}}[[INTERFACE]] 120extern int odr_violation; 121 122@import Foo; 123int main(int argc, char **argv) { 124 Bar bar; 125 Foo *foo = 0; 126 bar.value = odr_violation; 127 return bar.value; 128} 129#endif 130#endif 131#endif 132 133// CHECK: DW_TAG_compile_unit 134// CHECK: DW_AT_name {{.*}}"odr_violation.c" 135// CHECK: DW_TAG_variable 136// CHECK: DW_AT_name {{.*}}"odr_violation" 137// CHECK: DW_AT_type [DW_FORM_ref4] ({{.*}}{0x{{0*}}[[BAR2:.*]]} 138// CHECK: 0x{{0*}}[[BAR2]]: DW_TAG_typedef 139// CHECK: DW_AT_type [DW_FORM_ref4] ({{.*}}{0x{{0*}}[[BAR3:.*]]} 140// CHECK: DW_AT_name {{.*}}"Bar" 141// CHECK: 0x{{0*}}[[BAR3]]: DW_TAG_structure_type 142// CHECK-NEXT: DW_AT_name {{.*}}"Bar" 143