| 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 | void TestFunctionDeclNoProto(); |
| 132 | // CHECK: FunctionDecl{{.*}} TestFunctionDeclNoProto 'void ()' |
| 133 | |
| 134 | extern int TestFunctionDeclSC(); |
| 135 | // CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern |
| 136 | |
| 137 | inline int TestFunctionDeclInline(); |
| 138 | // CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline |
| 139 | |
| 140 | struct testFieldDecl { |
| 141 | int TestFieldDecl; |
| 142 | int TestFieldDeclWidth : 1; |
| 143 | __module_private__ int TestFieldDeclPrivate; |
| 144 | }; |
| 145 | // CHECK: FieldDecl{{.*}} TestFieldDecl 'int' |
| 146 | // CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int' |
| 147 | // CHECK-NEXT: ConstantExpr |
| 148 | // CHECK-NEXT: IntegerLiteral |
| 149 | // CHECK-MODULE: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__ |
| 150 | |
| 151 | int TestVarDecl; |
| 152 | // CHECK: VarDecl{{.*}} TestVarDecl 'int' |
| 153 | |
| 154 | extern int TestVarDeclSC; |
| 155 | // CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern |
| 156 | |
| 157 | __thread int TestVarDeclThread; |
| 158 | // CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}} |
| 159 | |
| 160 | __module_private__ int TestVarDeclPrivate; |
| 161 | // CHECK-MODULE: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__ |
| 162 | |
| 163 | int TestVarDeclInit = 0; |
| 164 | // CHECK: VarDecl{{.*}} TestVarDeclInit 'int' |
| 165 | // CHECK-NEXT: IntegerLiteral |
| 166 | |
| 167 | void testParmVarDecl(int TestParmVarDecl); |
| 168 | // CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int' |
| 169 | |
| 170 | #ifdef MODULES |
| 171 | #pragma clang module end |
| 172 | #endif |
| 173 | |
| 174 | |