[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Tooling / clang-diff-ast.cpp
bloba8efda50a4052ec53c17dd7f8603fc104f9ea710
1 // RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
4 // CHECK: {{^}}TranslationUnitDecl(0)
5 // CHECK: {{^}} NamespaceDecl: test;(
6 namespace test {
8 // CHECK: {{^}} FunctionDecl: :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: :f(
21 f();
22 // CHECK: UnaryOperator: ++(
23 ++i;
24 // CHECK: BinaryOperator: =(
25 i = i;
28 } // end namespace test
30 // CHECK: UsingDirectiveDecl: test(
31 using namespace test;
33 // CHECK: TypedefDecl: nat;unsigned int;(
34 typedef unsigned nat;
35 // CHECK: TypeAliasDecl: real;double;(
36 using real = double;
38 class Base {
41 // CHECK: CXXRecordDecl: X;X;(
42 class X : Base {
43 int m;
44 // CHECK: CXXMethodDecl: :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;
54 // CHECK: AccessSpecDecl: public(
55 public:
56 int 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
64 X(char s, int) : Base(), m(0) {
65 // CHECK-NEXT: CompoundStmt
66 // CHECK: MemberExpr: :m(
67 int x = m;
69 // CHECK: CXXConstructorDecl: :X(void (char){{( __attribute__\(\(thiscall\)\))?}})(
70 // CHECK: CXXCtorInitializer: X
71 X(char s) : X(s, 4) {}
74 #define M (void)1
75 #define MA(a, b) (void)a, b
76 // CHECK: FunctionDecl
77 // CHECK-NEXT: CompoundStmt
78 void macros() {
80 MA(1, 2);
83 #ifndef GUARD
84 #define GUARD
85 // CHECK-NEXT: NamespaceDecl
86 namespace world {
87 // nodes from other files are excluded, there should be no output here
88 #include "clang-diff-ast.cpp"
90 // CHECK-NEXT: FunctionDecl: sentinel
91 void sentinel();
92 #endif