1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -check-prefix CHECK-TU -strict-whitespace %s
3 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=X -triple x86_64-unknown-unknown -fmodule-map-file=%S/Inputs/module.modulemap -ast-dump -ast-dump-filter Test %s -DMODULES | FileCheck -check-prefix CHECK -check-prefix CHECK-MODULES -strict-whitespace %s
6 // CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:[[@LINE-1]]:1, col:5> col:5 TestLocation
9 #pragma clang module begin X
15 // CHECK: {{^}}RecordDecl{{.*TestIndent[^()]*$}}
16 // CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}}
24 // CHECK: RecordDecl{{.*}}TestChildren
25 // CHECK-NEXT: FieldDecl{{.*}}x
26 // CHECK-NEXT: RecordDecl{{.*}}y
27 // CHECK-NEXT: FieldDecl{{.*}}z
29 // CHECK-TU: TranslationUnitDecl
31 void testLabelDecl() {
32 __label__ TestLabelDecl;
33 TestLabelDecl: goto TestLabelDecl;
35 // CHECK: LabelDecl{{.*}} TestLabelDecl
37 typedef int TestTypedefDecl;
38 // CHECK: TypedefDecl{{.*}} TestTypedefDecl 'int'
40 __module_private__ typedef int TestTypedefDeclPrivate;
41 // CHECK-MODULE: TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__
46 // CHECK: EnumDecl{{.*}} TestEnumDecl
47 // CHECK-NEXT: EnumConstantDecl{{.*}} testEnumDecl
49 struct TestEnumDeclAnon {
54 // CHECK: RecordDecl{{.*}} TestEnumDeclAnon
55 // CHECK-NEXT: EnumDecl{{.*> .*$}}
57 enum TestEnumDeclForward;
58 // CHECK: EnumDecl{{.*}} TestEnumDeclForward
60 __module_private__ enum TestEnumDeclPrivate;
61 // CHECK-MODULE: EnumDecl{{.*}} TestEnumDeclPrivate __module_private__
63 struct TestRecordDecl {
66 // CHECK: RecordDecl{{.*}} struct TestRecordDecl
67 // CHECK-NEXT: FieldDecl
69 struct TestRecordDeclEmpty {
71 // CHECK: RecordDecl{{.*}} struct TestRecordDeclEmpty
73 struct TestRecordDeclAnon1 {
75 } testRecordDeclAnon1;
77 // CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon1
78 // CHECK-NEXT: RecordDecl{{.*}} struct
80 struct TestRecordDeclAnon2 {
84 // CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon2
85 // CHECK-NEXT: RecordDecl{{.*}} struct
87 struct TestRecordDeclForward;
88 // CHECK: RecordDecl{{.*}} struct TestRecordDeclForward
90 __module_private__ struct TestRecordDeclPrivate;
91 // CHECK-MODULE: RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__
93 enum testEnumConstantDecl {
95 TestEnumConstantDeclInit = 1
97 // CHECK: EnumConstantDecl{{.*}} TestEnumConstantDecl 'int'
98 // CHECK: EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int'
99 // CHECK-NEXT: ConstantExpr
100 // CHECK-NEXT: IntegerLiteral
102 struct testIndirectFieldDecl {
104 int TestIndirectFieldDecl;
107 // CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
108 // CHECK-NEXT: Field{{.*}} ''
109 // CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl'
111 // FIXME: It would be nice to dump the enum and its enumerators.
112 int TestFunctionDecl(int x, enum { e } y) {
115 // CHECK: FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
116 // CHECK-NEXT: ParmVarDecl{{.*}} x
117 // CHECK-NEXT: ParmVarDecl{{.*}} y
118 // CHECK-NEXT: CompoundStmt
120 // FIXME: It would be nice to 'Enum' and 'e'.
121 int TestFunctionDecl2(enum Enum { e } x) { return x; }
122 // CHECK: FunctionDecl{{.*}} TestFunctionDecl2 'int (enum {{.*}})'
123 // CHECK-NEXT: ParmVarDecl{{.*}} x
124 // CHECK-NEXT: CompoundStmt
127 int TestFunctionDeclProto(int x);
128 // CHECK: FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
129 // CHECK-NEXT: ParmVarDecl{{.*}} x
131 extern int TestFunctionDeclSC();
132 // CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
134 inline int TestFunctionDeclInline();
135 // CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline
137 struct testFieldDecl {
139 int TestFieldDeclWidth : 1;
140 __module_private__ int TestFieldDeclPrivate;
142 // CHECK: FieldDecl{{.*}} TestFieldDecl 'int'
143 // CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int'
144 // CHECK-NEXT: ConstantExpr
145 // CHECK-NEXT: IntegerLiteral
146 // CHECK-MODULE: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__
149 // CHECK: VarDecl{{.*}} TestVarDecl 'int'
151 extern int TestVarDeclSC;
152 // CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern
154 __thread int TestVarDeclThread;
155 // CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
157 __module_private__ int TestVarDeclPrivate;
158 // CHECK-MODULE: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
160 int TestVarDeclInit = 0;
161 // CHECK: VarDecl{{.*}} TestVarDeclInit 'int'
162 // CHECK-NEXT: IntegerLiteral
164 void testParmVarDecl(int TestParmVarDecl);
165 // CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int'
168 #pragma clang module end