]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/AST/ast-dump-decl.c
Vendor import of clang trunk r338536:
[FreeBSD/FreeBSD.git] / test / AST / ast-dump-decl.c
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
4
5 int TestLocation;
6 // CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:[[@LINE-1]]:1, col:5> col:5 TestLocation
7
8 #ifdef MODULES
9 #pragma clang module begin X
10 #endif
11
12 struct TestIndent {
13   int x;
14 };
15 // CHECK:      {{^}}RecordDecl{{.*TestIndent[^()]*$}}
16 // CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}}
17
18 struct TestChildren {
19   int x;
20   struct y {
21     int z;
22   };
23 };
24 // CHECK:      RecordDecl{{.*}}TestChildren
25 // CHECK-NEXT:   FieldDecl{{.*}}x
26 // CHECK-NEXT:   RecordDecl{{.*}}y
27 // CHECK-NEXT:     FieldDecl{{.*}}z
28
29 // CHECK-TU: TranslationUnitDecl
30
31 void testLabelDecl() {
32   __label__ TestLabelDecl;
33   TestLabelDecl: goto TestLabelDecl;
34 }
35 // CHECK:      LabelDecl{{.*}} TestLabelDecl
36
37 typedef int TestTypedefDecl;
38 // CHECK:      TypedefDecl{{.*}} TestTypedefDecl 'int'
39
40 __module_private__ typedef int TestTypedefDeclPrivate;
41 // CHECK-MODULE:      TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__
42
43 enum TestEnumDecl {
44   testEnumDecl
45 };
46 // CHECK:      EnumDecl{{.*}} TestEnumDecl
47 // CHECK-NEXT:   EnumConstantDecl{{.*}} testEnumDecl
48
49 struct TestEnumDeclAnon {
50   enum {
51     testEnumDeclAnon
52   } e;
53 };
54 // CHECK:      RecordDecl{{.*}} TestEnumDeclAnon
55 // CHECK-NEXT:   EnumDecl{{.*> .*$}}
56
57 enum TestEnumDeclForward;
58 // CHECK:      EnumDecl{{.*}} TestEnumDeclForward
59
60 __module_private__ enum TestEnumDeclPrivate;
61 // CHECK-MODULE:      EnumDecl{{.*}} TestEnumDeclPrivate __module_private__
62
63 struct TestRecordDecl {
64   int i;
65 };
66 // CHECK:      RecordDecl{{.*}} struct TestRecordDecl
67 // CHECK-NEXT:   FieldDecl
68
69 struct TestRecordDeclEmpty {
70 };
71 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclEmpty
72
73 struct TestRecordDeclAnon1 {
74   struct {
75   } testRecordDeclAnon1;
76 };
77 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclAnon1
78 // CHECK-NEXT:   RecordDecl{{.*}} struct
79
80 struct TestRecordDeclAnon2 {
81   struct {
82   };
83 };
84 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclAnon2
85 // CHECK-NEXT:   RecordDecl{{.*}} struct
86
87 struct TestRecordDeclForward;
88 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclForward
89
90 __module_private__ struct TestRecordDeclPrivate;
91 // CHECK-MODULE:      RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__
92
93 enum testEnumConstantDecl {
94   TestEnumConstantDecl,
95   TestEnumConstantDeclInit = 1
96 };
97 // CHECK:      EnumConstantDecl{{.*}} TestEnumConstantDecl 'int'
98 // CHECK:      EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int'
99 // CHECK-NEXT:   ConstantExpr
100 // CHECK-NEXT:     IntegerLiteral
101
102 struct testIndirectFieldDecl {
103   struct {
104     int TestIndirectFieldDecl;
105   };
106 };
107 // CHECK:      IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
108 // CHECK-NEXT:   Field{{.*}} ''
109 // CHECK-NEXT:   Field{{.*}} 'TestIndirectFieldDecl'
110
111 // FIXME: It would be nice to dump the enum and its enumerators.
112 int TestFunctionDecl(int x, enum { e } y) {
113   return x;
114 }
115 // CHECK:      FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
116 // CHECK-NEXT:   ParmVarDecl{{.*}} x
117 // CHECK-NEXT:   ParmVarDecl{{.*}} y
118 // CHECK-NEXT:   CompoundStmt
119
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
125
126
127 int TestFunctionDeclProto(int x);
128 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
129 // CHECK-NEXT:   ParmVarDecl{{.*}} x
130
131 extern int TestFunctionDeclSC();
132 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
133
134 inline int TestFunctionDeclInline();
135 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline
136
137 struct testFieldDecl {
138   int TestFieldDecl;
139   int TestFieldDeclWidth : 1;
140   __module_private__ int TestFieldDeclPrivate;
141 };
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__
147
148 int TestVarDecl;
149 // CHECK:      VarDecl{{.*}} TestVarDecl 'int'
150
151 extern int TestVarDeclSC;
152 // CHECK:      VarDecl{{.*}} TestVarDeclSC 'int' extern
153
154 __thread int TestVarDeclThread;
155 // CHECK:      VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
156
157 __module_private__ int TestVarDeclPrivate;
158 // CHECK-MODULE:      VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
159
160 int TestVarDeclInit = 0;
161 // CHECK:      VarDecl{{.*}} TestVarDeclInit 'int'
162 // CHECK-NEXT:   IntegerLiteral
163
164 void testParmVarDecl(int TestParmVarDecl);
165 // CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int'
166
167 #ifdef MODULES
168 #pragma clang module end
169 #endif
170