ast-dump-decl.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. int TestLocation;
  4. // CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:4:1, col:5> col:5 TestLocation
  5. struct TestIndent {
  6. int x;
  7. };
  8. // CHECK: {{^}}RecordDecl{{.*TestIndent[^()]*$}}
  9. // CHECK-NEXT: {{^}}`-FieldDecl{{.*x[^()]*$}}
  10. struct TestChildren {
  11. int x;
  12. struct y {
  13. int z;
  14. };
  15. };
  16. // CHECK: RecordDecl{{.*}}TestChildren
  17. // CHECK-NEXT: FieldDecl{{.*}}x
  18. // CHECK-NEXT: RecordDecl{{.*}}y
  19. // CHECK-NEXT: FieldDecl{{.*}}z
  20. // CHECK-TU: TranslationUnitDecl
  21. void testLabelDecl() {
  22. __label__ TestLabelDecl;
  23. TestLabelDecl: goto TestLabelDecl;
  24. }
  25. // CHECK: LabelDecl{{.*}} TestLabelDecl
  26. typedef int TestTypedefDecl;
  27. // CHECK: TypedefDecl{{.*}} TestTypedefDecl 'int'
  28. __module_private__ typedef int TestTypedefDeclPrivate;
  29. // CHECK: TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__
  30. enum TestEnumDecl {
  31. testEnumDecl
  32. };
  33. // CHECK: EnumDecl{{.*}} TestEnumDecl
  34. // CHECK-NEXT: EnumConstantDecl{{.*}} testEnumDecl
  35. struct TestEnumDeclAnon {
  36. enum {
  37. testEnumDeclAnon
  38. } e;
  39. };
  40. // CHECK: RecordDecl{{.*}} TestEnumDeclAnon
  41. // CHECK-NEXT: EnumDecl{{.*> .*$}}
  42. enum TestEnumDeclForward;
  43. // CHECK: EnumDecl{{.*}} TestEnumDeclForward
  44. __module_private__ enum TestEnumDeclPrivate;
  45. // CHECK: EnumDecl{{.*}} TestEnumDeclPrivate __module_private__
  46. struct TestRecordDecl {
  47. int i;
  48. };
  49. // CHECK: RecordDecl{{.*}} struct TestRecordDecl
  50. // CHECK-NEXT: FieldDecl
  51. struct TestRecordDeclEmpty {
  52. };
  53. // CHECK: RecordDecl{{.*}} struct TestRecordDeclEmpty
  54. struct TestRecordDeclAnon1 {
  55. struct {
  56. } testRecordDeclAnon1;
  57. };
  58. // CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon1
  59. // CHECK-NEXT: RecordDecl{{.*}} struct
  60. struct TestRecordDeclAnon2 {
  61. struct {
  62. };
  63. };
  64. // CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon2
  65. // CHECK-NEXT: RecordDecl{{.*}} struct
  66. struct TestRecordDeclForward;
  67. // CHECK: RecordDecl{{.*}} struct TestRecordDeclForward
  68. __module_private__ struct TestRecordDeclPrivate;
  69. // CHECK: RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__
  70. enum testEnumConstantDecl {
  71. TestEnumConstantDecl,
  72. TestEnumConstantDeclInit = 1
  73. };
  74. // CHECK: EnumConstantDecl{{.*}} TestEnumConstantDecl 'int'
  75. // CHECK: EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int'
  76. // CHECK-NEXT: IntegerLiteral
  77. struct testIndirectFieldDecl {
  78. struct {
  79. int TestIndirectFieldDecl;
  80. };
  81. };
  82. // CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
  83. // CHECK-NEXT: Field{{.*}} ''
  84. // CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl'
  85. int TestFunctionDecl(int x, enum { e } y) {
  86. return x;
  87. }
  88. // CHECK: FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
  89. // CHECK-NEXT: EnumDecl
  90. // CHECK-NEXT: EnumConstantDecl{{.*}} e
  91. // CHECK-NEXT: ParmVarDecl{{.*}} x
  92. // CHECK-NEXT: ParmVarDecl{{.*}} y
  93. // CHECK-NEXT: CompoundStmt
  94. int TestFunctionDeclProto(int x);
  95. // CHECK: FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
  96. // CHECK-NEXT: ParmVarDecl{{.*}} x
  97. extern int TestFunctionDeclSC();
  98. // CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
  99. inline int TestFunctionDeclInline();
  100. // CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline
  101. struct testFieldDecl {
  102. int TestFieldDecl;
  103. int TestFieldDeclWidth : 1;
  104. __module_private__ int TestFieldDeclPrivate;
  105. };
  106. // CHECK: FieldDecl{{.*}} TestFieldDecl 'int'
  107. // CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int'
  108. // CHECK-NEXT: IntegerLiteral
  109. // CHECK: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__
  110. int TestVarDecl;
  111. // CHECK: VarDecl{{.*}} TestVarDecl 'int'
  112. extern int TestVarDeclSC;
  113. // CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern
  114. __thread int TestVarDeclThread;
  115. // CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
  116. __module_private__ int TestVarDeclPrivate;
  117. // CHECK: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
  118. int TestVarDeclInit = 0;
  119. // CHECK: VarDecl{{.*}} TestVarDeclInit 'int'
  120. // CHECK-NEXT: IntegerLiteral
  121. void testParmVarDecl(int TestParmVarDecl);
  122. // CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int'