[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Tooling / clang-diff-basic.cpp
bloba0c0163530ffaa015a391e6b6f2efce2016877af
1 // RUN: clang-diff -dump-matches %S/Inputs/clang-diff-basic-src.cpp %s -- | FileCheck %s
3 // CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl
4 // CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst
5 namespace dst {
6 // CHECK-NOT: Match NamespaceDecl: src{{.*}} to NamespaceDecl: inner
7 namespace inner {
8 void foo() {
9 // CHECK: Match IntegerLiteral: 321{{.*}} to IntegerLiteral: 322
10 int x = 322;
14 // CHECK: Match DeclRefExpr: :foo{{.*}} to DeclRefExpr: :inner::foo
15 void main() { inner::foo(); }
17 // CHECK: Match StringLiteral: foo{{.*}} to StringLiteral: foo
18 const char *b = "f" "o" "o";
20 // unsigned is canonicalized to unsigned int
21 // CHECK: Match TypedefDecl: :nat;unsigned int;{{.*}} to TypedefDecl: :nat;unsigned int;
22 typedef unsigned nat;
24 // CHECK: Match VarDecl: :p(int){{.*}} to VarDecl: :prod(double)
25 // CHECK: Update VarDecl: :p(int){{.*}} to :prod(double)
26 // CHECK: Match BinaryOperator: *{{.*}} to BinaryOperator: *
27 double prod = 1 * 2 * 10;
28 // CHECK: Update DeclRefExpr
29 int squared = prod * prod;
31 class X {
32 const char *foo(int i) {
33 if (i == 0)
34 return "Bar";
35 // CHECK: Insert IfStmt{{.*}} into IfStmt
36 // CHECK: Insert BinaryOperator: =={{.*}} into IfStmt
37 else if (i == -1)
38 return "foo";
39 return 0;
41 X(){}
45 // CHECK: Move CompoundStmt{{.*}} into CompoundStmt
46 void m() { { int x = 0 + 0 + 0; } }
47 // CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 1
48 int um = 1 + 7;
50 namespace {
51 // match with parents of different type
52 // CHECK: Match FunctionDecl: f1{{.*}} to FunctionDecl: (anonymous namespace)::f1
53 void f1() {{ (void) __func__;;; }}
56 // CHECK: Delete AccessSpecDecl: public
57 // CHECK: Delete CXXMethodDecl