1 // RUN: %clang_cc1 -E %s > %t.src.cpp 2 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST 3 // RUN: clang-diff %t.src.cpp %t.dst.cpp -- | FileCheck %s 4 5 #ifndef DEST 6 namespace src { 7 8 void foo() { 9 int x = 321; 10 } 11 12 void main() { foo(); }; 13 14 const char *a = "foo"; 15 16 typedef unsigned int nat; 17 18 int p = 1 * 2 * 3 * 4; 19 int squared = p * p; 20 21 class X { 22 const char *foo(int i) { 23 if (i == 0) 24 return "foo"; 25 return 0; 26 } 27 28 public: 29 X(){}; 30 31 int id(int i) { return i; } 32 }; 33 } 34 #else 35 // CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl 36 // CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst 37 namespace dst { 38 // CHECK-NOT: Match NamespaceDecl: src{{.*}} to NamespaceDecl: inner 39 namespace inner { 40 void foo() { 41 // CHECK: Match IntegerLiteral: 321{{.*}} to IntegerLiteral: 322 42 int x = 322; 43 } 44 } 45 46 // CHECK: Match DeclRefExpr: foo{{.*}} to DeclRefExpr: inner::foo 47 void main() { inner::foo(); } 48 49 // CHECK: Match StringLiteral: foo{{.*}} to StringLiteral: foo 50 const char *b = "f" "o" "o"; 51 52 // unsigned is canonicalized to unsigned int 53 // CHECK: Match TypedefDecl: nat;unsigned int;{{.*}} to TypedefDecl: nat;unsigned int; 54 typedef unsigned nat; 55 56 // CHECK: Match VarDecl: p(int){{.*}} to VarDecl: prod(double) 57 // CHECK: Match BinaryOperator: *{{.*}} to BinaryOperator: * 58 // CHECK: Update VarDecl: p(int){{.*}} to prod(double) 59 double prod = 1 * 2 * 10; 60 // CHECK: Update DeclRefExpr 61 int squared = prod * prod; 62 63 class X { 64 const char *foo(int i) { 65 if (i == 0) 66 return "Bar"; 67 // CHECK: Insert IfStmt{{.*}} into IfStmt 68 // CHECK: Insert BinaryOperator: =={{.*}} into IfStmt 69 else if (i == -1) 70 return "foo"; 71 return 0; 72 } 73 // CHECK: Delete AccessSpecDecl: public 74 X(){}; 75 // CHECK: Delete CXXMethodDecl 76 }; 77 } 78 #endif 79