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