1 // RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
2 
3 
4 // CHECK: {{^}}TranslationUnitDecl(0)
5 // CHECK: {{^}} NamespaceDecl: test;(
6 namespace test {
7 
8 // CHECK: {{^}} FunctionDecl: test::f(
9 // CHECK: CompoundStmt(
10 void f() {
11   // CHECK: VarDecl: i(int)(
12   // CHECK: IntegerLiteral: 1
13   auto i = 1;
14   // CHECK: FloatingLiteral: 1.5(
15   auto r = 1.5;
16   // CHECK: CXXBoolLiteralExpr: true(
17   auto b = true;
18   // CHECK: CallExpr(
19   // CHECK-NOT: ImplicitCastExpr
20   // CHECK: DeclRefExpr: test::f(
21   f();
22   // CHECK: UnaryOperator: ++(
23   ++i;
24   // CHECK: BinaryOperator: =(
25   i = i;
26 }
27 
28 } // end namespace test
29 
30 // CHECK: UsingDirectiveDecl: test(
31 using namespace test;
32 
33 // CHECK: TypedefDecl: nat;unsigned int;(
34 typedef unsigned nat;
35 // CHECK: TypeAliasDecl: real;double;(
36 using real = double;
37 
38 class Base {
39 };
40 
41 // CHECK: CXXRecordDecl: X;X;(
42 class X : Base {
43   int m;
44   // CHECK: CXXMethodDecl: X::foo(const char *(int)
45   // CHECK: ParmVarDecl: i(int)(
46   const char *foo(int i) {
47     if (i == 0)
48       // CHECK: StringLiteral: foo(
49       return "foo";
50     // CHECK-NOT: ImplicitCastExpr
51     return 0;
52   }
53 
54   // CHECK: AccessSpecDecl: public(
55 public:
56   int not_initialized;
57   // All initialized members, bases and delegating initializers are are
58   // appended, separated by commas.
59   // CHECK: CXXConstructorDecl: X::X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})Base,X::m,(
60   X(char c, int) : Base(), m(0) {
61     // CHECK: MemberExpr: X::m(
62     int x = m;
63   }
64   // CHECK: CXXConstructorDecl: X::X(void (char){{( __attribute__\(\(thiscall\)\))?}})X,(
65   X(char s) : X(s, 4) {}
66 };
67 
68 #define M (void)1
69 #define MA(a, b) (void)a, b
70 // CHECK: FunctionDecl
71 // CHECK-NEXT: CompoundStmt
72 void macros() {
73   M;
74   MA(1, 2);
75 }
76 
77 #ifndef GUARD
78 #define GUARD
79 // CHECK-NEXT: NamespaceDecl
80 namespace world {
81 // nodes from other files are excluded, there should be no output here
82 #include "clang-diff-ast.cpp"
83 }
84 // CHECK-NEXT: FunctionDecl: sentinel
85 void sentinel();
86 #endif
87