brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 771c6ab Raw
46 lines · cpp
1// RUN: %clang_cc1 -E %s > %t.src.cpp2// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST3// RUN: clang-diff -dump-matches -s=10 %t.src.cpp %t.dst.cpp -- | FileCheck %s4//5// Test the behaviour of the matching according to the optimal tree edit6// distance, implemented with Zhang and Shasha's algorithm.7// Just for testing we use a tiny value of 10 for maxsize. Subtrees bigger than8// this size will not be processed by the optimal algorithm.9 10#ifndef DEST11 12void f1() { {;} {{;}} }13 14void f2() { {;} {{;;;;;}} }15 16void f3() { {;} {{;;;;;;}} }17 18#else19 20void f1() {21// Jaccard similarity = 3 / (5 + 4 - 3) = 3 / 6 >= 0.522// The optimal matching algorithm should move the ; into the outer block23// CHECK: Match CompoundStmt(2) to CompoundStmt(2)24// CHECK-NOT: Match CompoundStmt(3)25// CHECK-NEXT: Match NullStmt(4) to NullStmt(3)26  ; {{;}}27}28 29void f2() {30  // Jaccard similarity = 7 / (10 + 10 - 7) >= 0.531  // As none of the subtrees is bigger than 10 nodes, the optimal algorithm32  // will be run.33  // CHECK: Match NullStmt(11) to NullStmt(9)34  ;; {{;;;;;}}35}36 37void f3() {38  // Jaccard similarity = 8 / (11 + 11 - 8) >= 0.539  // As the subtrees are bigger than 10 nodes, the optimal algorithm will not40  // be run.41  // CHECK: Delete NullStmt(22)42  ;; {{;;;;;;}}43}44 45#endif46