Home | History | Annotate | Download | only in Misc
      1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
      2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -check-prefix CHECK-TU -strict-whitespace %s
      3 
      4 int TestLocation;
      5 // CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:4:1, col:5> TestLocation
      6 
      7 struct TestIndent {
      8   int x;
      9 };
     10 // CHECK:      {{^}}RecordDecl{{.*TestIndent[^()]*$}}
     11 // CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}}
     12 
     13 struct TestChildren {
     14   int x;
     15   struct y {
     16     int z;
     17   };
     18 };
     19 // CHECK:      RecordDecl{{.*}}TestChildren
     20 // CHECK-NEXT:   FieldDecl{{.*}}x
     21 // CHECK-NEXT:   RecordDecl{{.*}}y
     22 // CHECK-NEXT:     FieldDecl{{.*}}z
     23 
     24 // CHECK-TU: TranslationUnitDecl
     25 
     26 void testLabelDecl() {
     27   __label__ TestLabelDecl;
     28   TestLabelDecl: goto TestLabelDecl;
     29 }
     30 // CHECK:      LabelDecl{{.*}} TestLabelDecl
     31 
     32 typedef int TestTypedefDecl;
     33 // CHECK:      TypedefDecl{{.*}} TestTypedefDecl 'int'
     34 
     35 __module_private__ typedef int TestTypedefDeclPrivate;
     36 // CHECK:      TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__
     37 
     38 enum TestEnumDecl {
     39   testEnumDecl
     40 };
     41 // CHECK:      EnumDecl{{.*}} TestEnumDecl
     42 // CHECK-NEXT:   EnumConstantDecl{{.*}} testEnumDecl
     43 
     44 struct TestEnumDeclAnon {
     45   enum {
     46     testEnumDeclAnon
     47   } e;
     48 };
     49 // CHECK:      RecordDecl{{.*}} TestEnumDeclAnon
     50 // CHECK-NEXT:   EnumDecl{{.*>$}}
     51 
     52 enum TestEnumDeclForward;
     53 // CHECK:      EnumDecl{{.*}} TestEnumDeclForward
     54 
     55 __module_private__ enum TestEnumDeclPrivate;
     56 // CHECK:      EnumDecl{{.*}} TestEnumDeclPrivate __module_private__
     57 
     58 struct TestRecordDecl {
     59   int i;
     60 };
     61 // CHECK:      RecordDecl{{.*}} struct TestRecordDecl
     62 // CHECK-NEXT:   FieldDecl
     63 
     64 struct TestRecordDeclEmpty {
     65 };
     66 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclEmpty
     67 
     68 struct TestRecordDeclAnon1 {
     69   struct {
     70   } testRecordDeclAnon1;
     71 };
     72 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclAnon1
     73 // CHECK-NEXT:   RecordDecl{{.*}} struct
     74 
     75 struct TestRecordDeclAnon2 {
     76   struct {
     77   };
     78 };
     79 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclAnon2
     80 // CHECK-NEXT:   RecordDecl{{.*}} struct
     81 
     82 struct TestRecordDeclForward;
     83 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclForward
     84 
     85 __module_private__ struct TestRecordDeclPrivate;
     86 // CHECK:      RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__
     87 
     88 enum testEnumConstantDecl {
     89   TestEnumConstantDecl,
     90   TestEnumConstantDeclInit = 1
     91 };
     92 // CHECK:      EnumConstantDecl{{.*}} TestEnumConstantDecl 'int'
     93 // CHECK:      EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int'
     94 // CHECK-NEXT:   IntegerLiteral
     95 
     96 struct testIndirectFieldDecl {
     97   struct {
     98     int TestIndirectFieldDecl;
     99   };
    100 };
    101 // CHECK:      IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
    102 // CHECK-NEXT:   Field{{.*}} ''
    103 // CHECK-NEXT:   Field{{.*}} 'TestIndirectFieldDecl'
    104 
    105 int TestFunctionDecl(int x, enum { e } y) {
    106   return x;
    107 }
    108 // CHECK:      FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
    109 // CHECK-NEXT:   EnumDecl
    110 // CHECK-NEXT:     EnumConstantDecl{{.*}} e
    111 // CHECK-NEXT:   ParmVarDecl{{.*}} x
    112 // CHECK-NEXT:   ParmVarDecl{{.*}} y
    113 // CHECK-NEXT:   CompoundStmt
    114 
    115 int TestFunctionDeclProto(int x);
    116 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
    117 // CHECK-NEXT:   ParmVarDecl{{.*}} x
    118 
    119 extern int TestFunctionDeclSC();
    120 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
    121 
    122 inline int TestFunctionDeclInline();
    123 // CHECK:      FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline
    124 
    125 struct testFieldDecl {
    126   int TestFieldDecl;
    127   int TestFieldDeclWidth : 1;
    128   __module_private__ int TestFieldDeclPrivate;
    129 };
    130 // CHECK:      FieldDecl{{.*}} TestFieldDecl 'int'
    131 // CHECK:      FieldDecl{{.*}} TestFieldDeclWidth 'int'
    132 // CHECK-NEXT:   IntegerLiteral
    133 // CHECK:      FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__
    134 
    135 int TestVarDecl;
    136 // CHECK:      VarDecl{{.*}} TestVarDecl 'int'
    137 
    138 extern int TestVarDeclSC;
    139 // CHECK:      VarDecl{{.*}} TestVarDeclSC 'int' extern
    140 
    141 __thread int TestVarDeclThread;
    142 // CHECK:      VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
    143 
    144 __module_private__ int TestVarDeclPrivate;
    145 // CHECK:      VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
    146 
    147 int TestVarDeclInit = 0;
    148 // CHECK:      VarDecl{{.*}} TestVarDeclInit 'int'
    149 // CHECK-NEXT:   IntegerLiteral
    150 
    151 void testParmVarDecl(int TestParmVarDecl);
    152 // CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int'
    153