58 lines · cpp
1// RUN: clang-diff -dump-matches %S/Inputs/clang-diff-basic-src.cpp %s -- | FileCheck %s2 3// CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl4// CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst5namespace dst {6// CHECK-NOT: Match NamespaceDecl: src{{.*}} to NamespaceDecl: inner7namespace inner {8void foo() {9 // CHECK: Match IntegerLiteral: 321{{.*}} to IntegerLiteral: 32210 int x = 322;11}12}13 14// CHECK: Match DeclRefExpr: :foo{{.*}} to DeclRefExpr: :inner::foo15void main() { inner::foo(); }16 17// CHECK: Match StringLiteral: foo{{.*}} to StringLiteral: foo18const char *b = "f" "o" "o";19 20// unsigned is canonicalized to unsigned int21// CHECK: Match TypedefDecl: :nat;unsigned int;{{.*}} to TypedefDecl: :nat;unsigned int;22typedef unsigned nat;23 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: *27double prod = 1 * 2 * 10;28// CHECK: Update DeclRefExpr29int squared = prod * prod;30 31class X {32 const char *foo(int i) {33 if (i == 0)34 return "Bar";35 // CHECK: Insert IfStmt{{.*}} into IfStmt36 // CHECK: Insert BinaryOperator: =={{.*}} into IfStmt37 else if (i == -1)38 return "foo";39 return 0;40 }41 X(){}42};43}44 45// CHECK: Move CompoundStmt{{.*}} into CompoundStmt46void m() { { int x = 0 + 0 + 0; } }47// CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 148int um = 1 + 7;49 50namespace {51// match with parents of different type52// CHECK: Match FunctionDecl: f1{{.*}} to FunctionDecl: (anonymous namespace)::f153void f1() {{ (void) __func__;;; }}54}55 56// CHECK: Delete AccessSpecDecl: public57// CHECK: Delete CXXMethodDecl58