| 1 |
// Test without serialization: |
| 2 |
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-strict-prototypes -ast-dump -ast-dump-filter Test %s \ |
| 3 |
// RUN: | FileCheck --strict-whitespace %s |
| 4 |
// |
| 5 |
// Test with serialization: |
| 6 |
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-strict-prototypes -emit-pch -o %t %s |
| 7 |
// RUN: %clang_cc1 -x c -triple x86_64-unknown-unknown -Wno-strict-prototypes -include-pch %t \ |
| 8 |
// RUN: -ast-dump-all -ast-dump-filter Test /dev/null \ |
| 9 |
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \ |
| 10 |
// RUN: | FileCheck --strict-whitespace %s |
| 11 |
// |
| 12 |
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-strict-prototypes -ast-dump %s \ |
| 13 |
// RUN: | FileCheck -check-prefix CHECK-TU --strict-whitespace %s |
| 14 |
// |
| 15 |
// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=X \ |
| 16 |
// RUN: -triple x86_64-unknown-unknown -Wno-strict-prototypes -fmodule-map-file=%S/Inputs/module.modulemap \ |
| 17 |
// RUN: -ast-dump -ast-dump-filter Test %s -DMODULES \ |
| 18 |
// RUN: | FileCheck -check-prefix CHECK -check-prefix CHECK-MODULES --strict-whitespace %s |
| 19 |
|
| 20 |
int TestLocation; |
| 21 |
// CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:[[@LINE-1]]:1, col:5> col:5 TestLocation |
| 22 |
|
| 23 |
#ifdef MODULES |
| 24 |
#pragma clang module begin X |
| 25 |
#endif |
| 26 |
|
| 27 |
struct TestIndent { |
| 28 |
int x; |
| 29 |
}; |
| 30 |
// CHECK: {{^}}RecordDecl{{.*TestIndent[^()]*$}} |
| 31 |
// CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}} |
| 32 |
|
| 33 |
struct TestChildren { |
| 34 |
int x; |
| 35 |
struct y { |
| 36 |
int z; |
| 37 |
}; |
| 38 |
}; |
| 39 |
// CHECK: RecordDecl{{.*}}TestChildren |
| 40 |
// CHECK-NEXT: FieldDecl{{.*}}x |
| 41 |
// CHECK-NEXT: RecordDecl{{.*}}y |
| 42 |
// CHECK-NEXT: FieldDecl{{.*}}z |
| 43 |
|
| 44 |
// CHECK-TU: TranslationUnitDecl |
| 45 |
|
| 46 |
void testLabelDecl(void) { |
| 47 |
__label__ TestLabelDecl; |
| 48 |
TestLabelDecl: goto TestLabelDecl; |
| 49 |
} |
| 50 |
// CHECK: LabelDecl{{.*}} TestLabelDecl |
| 51 |
|
| 52 |
typedef int TestTypedefDecl; |
| 53 |
// CHECK: TypedefDecl{{.*}} TestTypedefDecl 'int' |
| 54 |
|
| 55 |
__module_private__ typedef int TestTypedefDeclPrivate; |
| 56 |
// CHECK-MODULES: TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__ |
| 57 |
|
| 58 |
enum TestEnumDecl { |
| 59 |
testEnumDecl |
| 60 |
}; |
| 61 |
// CHECK: EnumDecl{{.*}} TestEnumDecl |
| 62 |
// CHECK-NEXT: EnumConstantDecl{{.*}} testEnumDecl |
| 63 |
|
| 64 |
struct TestEnumDeclAnon { |
| 65 |
enum { |
| 66 |
testEnumDeclAnon |
| 67 |
} e; |
| 68 |
}; |
| 69 |
// CHECK: RecordDecl{{.*}} TestEnumDeclAnon |
| 70 |
// CHECK-NEXT: EnumDecl{{.*> .*$}} |
| 71 |
|
| 72 |
enum TestEnumDeclForward; |
| 73 |
// CHECK: EnumDecl{{.*}} TestEnumDeclForward |
| 74 |
|
| 75 |
__module_private__ enum TestEnumDeclPrivate; |
| 76 |
// CHECK-MODULE: EnumDecl{{.*}} TestEnumDeclPrivate __module_private__ |
| 77 |
|
| 78 |
struct TestRecordDecl { |
| 79 |
int i; |
| 80 |
}; |
| 81 |
// CHECK: RecordDecl{{.*}} struct TestRecordDecl |
| 82 |
// CHECK-NEXT: FieldDecl |
| 83 |
|
| 84 |
struct TestRecordDeclEmpty { |
| 85 |
}; |
| 86 |
// CHECK: RecordDecl{{.*}} struct TestRecordDeclEmpty |
| 87 |
|
| 88 |
struct TestRecordDeclAnon1 { |
| 89 |
struct { |
| 90 |
} testRecordDeclAnon1; |
| 91 |
}; |
| 92 |
// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon1 |
| 93 |
// CHECK-NEXT: RecordDecl{{.*}} struct |
| 94 |
|
| 95 |
struct TestRecordDeclAnon2 { |
| 96 |
struct { |
| 97 |
}; |
| 98 |
}; |
| 99 |
// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon2 |
| 100 |
// CHECK-NEXT: RecordDecl{{.*}} struct |
| 101 |
|
| 102 |
struct TestRecordDeclForward; |
| 103 |
// CHECK: RecordDecl{{.*}} struct TestRecordDeclForward |
| 104 |
|
| 105 |
__module_private__ struct TestRecordDeclPrivate; |
| 106 |
// CHECK-MODULE: RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__ |
| 107 |
|
| 108 |
enum testEnumConstantDecl { |
| 109 |
TestEnumConstantDecl, |
| 110 |
TestEnumConstantDeclInit = 1 |
| 111 |
}; |
| 112 |
// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDecl 'int' |
| 113 |
// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int' |
| 114 |
// CHECK-NEXT: ConstantExpr |
| 115 |
// CHECK-NEXT: value: Int 1 |
| 116 |
// CHECK-NEXT: IntegerLiteral |
| 117 |
|
| 118 |
struct testIndirectFieldDecl { |
| 119 |
struct { |
| 120 |
int TestIndirectFieldDecl; |
| 121 |
}; |
| 122 |
}; |
| 123 |
// CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int' |
| 124 |
// CHECK-NEXT: Field{{.*}} field_index 0 |
| 125 |
// CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl' |
| 126 |
|
| 127 |
// FIXME: It would be nice to dump the enum and its enumerators. |
| 128 |
int TestFunctionDecl(int x, enum { e } y) { |
| 129 |
return x; |
| 130 |
} |
| 131 |
// CHECK: FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})' |
| 132 |
// CHECK-NEXT: ParmVarDecl{{.*}} x |
| 133 |
// CHECK-NEXT: ParmVarDecl{{.*}} y |
| 134 |
// CHECK-NEXT: CompoundStmt |
| 135 |
|
| 136 |
// FIXME: It would be nice to 'Enum' and 'e'. |
| 137 |
int TestFunctionDecl2(enum Enum { e } x) { return x; } |
| 138 |
// CHECK: FunctionDecl{{.*}} TestFunctionDecl2 'int (enum {{.*}})' |
| 139 |
// CHECK-NEXT: ParmVarDecl{{.*}} x |
| 140 |
// CHECK-NEXT: CompoundStmt |
| 141 |
|
| 142 |
|
| 143 |
int TestFunctionDeclProto(int x); |
| 144 |
// CHECK: FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)' |
| 145 |
// CHECK-NEXT: ParmVarDecl{{.*}} x |
| 146 |
|
| 147 |
void TestFunctionDeclNoProto(); |
| 148 |
// CHECK: FunctionDecl{{.*}} TestFunctionDeclNoProto 'void ()' |
| 149 |
|
| 150 |
extern int TestFunctionDeclSC(void); |
| 151 |
// CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int (void)' extern |
| 152 |
|
| 153 |
inline int TestFunctionDeclInline(void); |
| 154 |
// CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int (void)' inline |
| 155 |
|
| 156 |
struct testFieldDecl { |
| 157 |
int TestFieldDecl; |
| 158 |
int TestFieldDeclWidth : 1; |
| 159 |
__module_private__ int TestFieldDeclPrivate; |
| 160 |
}; |
| 161 |
// CHECK: FieldDecl{{.*}} TestFieldDecl 'int' |
| 162 |
// CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int' |
| 163 |
// CHECK-NEXT: ConstantExpr |
| 164 |
// CHECK-NEXT: value: Int 1 |
| 165 |
// CHECK-NEXT: IntegerLiteral |
| 166 |
// CHECK-MODULE: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__ |
| 167 |
|
| 168 |
int TestVarDecl; |
| 169 |
// CHECK: VarDecl{{.*}} TestVarDecl 'int' |
| 170 |
|
| 171 |
extern int TestVarDeclSC; |
| 172 |
// CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern |
| 173 |
|
| 174 |
__thread int TestVarDeclThread; |
| 175 |
// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}} |
| 176 |
|
| 177 |
__module_private__ int TestVarDeclPrivate; |
| 178 |
// CHECK-MODULE: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__ |
| 179 |
|
| 180 |
int TestVarDeclInit = 0; |
| 181 |
// CHECK: VarDecl{{.*}} TestVarDeclInit 'int' |
| 182 |
// CHECK-NEXT: IntegerLiteral |
| 183 |
|
| 184 |
void testParmVarDecl(int TestParmVarDecl); |
| 185 |
// CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int' |
| 186 |
|
| 187 |
#ifdef MODULES |
| 188 |
#pragma clang module end |
| 189 |
#endif |
| 190 |
|