71 lines · cpp
1// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++14 2>&1 | grep -v CHECK | FileCheck %s2 3 4void simpleExtractNoCaptures() {5 int i = /*range=->+0:33*/1 + 2;6}7 8// CHECK: 1 '' results:9// CHECK: static int extracted() {10// CHECK-NEXT: return 1 + 2;{{$}}11// CHECK-NEXT: }{{[[:space:]].*}}12// CHECK-NEXT: void simpleExtractNoCaptures() {13// CHECK-NEXT: int i = /*range=->+0:33*/extracted();{{$}}14// CHECK-NEXT: }15 16void simpleExtractStmtNoCaptures() {17 /*range astatement=->+1:13*/int a = 1;18 int b = 2;19}20// CHECK: 1 'astatement' results:21// CHECK: static void extracted() {22// CHECK-NEXT: int a = 1;23// CHECK-NEXT: int b = 2;{{$}}24// CHECK-NEXT: }{{[[:space:]].*}}25// CHECK-NEXT: void simpleExtractStmtNoCaptures() {26// CHECK-NEXT: /*range astatement=->+1:13*/extracted();{{$}}27// CHECK-NEXT: }28 29 30void blankRangeNoExtraction() {31 int i = /*range blank=*/1 + 2;32}33 34// CHECK: 1 'blank' results:35// CHECK-NEXT: the provided selection does not overlap with the AST nodes of interest36 37int outOfBodyCodeNoExtraction = /*range out_of_body_expr=->+0:72*/1 + 2;38 39struct OutOfBodyStuff {40 int FieldInit = /*range out_of_body_expr=->+0:58*/1 + 2;41 42 void foo(int x =/*range out_of_body_expr=->+0:58*/1 + 2);43};44 45auto inFunctionOutOfBody() -> decltype(/*range out_of_body_expr=->+0:79*/1 + 2) {46 struct OutOfBodyStuff {47 int FieldInit = /*range out_of_body_expr=->+0:60*/1 + 2;48 49 void foo(int x =/*range out_of_body_expr=->+0:60*/1 + 2);50 };51 enum E {52 X = /*range out_of_body_expr=->+0:48*/1 + 253 };54 int x = 0;55 using T = decltype(/*range out_of_body_expr=->+0:61*/x + 3);56 return x;57}58 59// CHECK: 8 'out_of_body_expr' results:60// CHECK: the selected code is not a part of a function's / method's body61 62void simpleExpressionNoExtraction() {63 int i = /*range simple_expr=->+0:41*/1 + /*range simple_expr=->+0:76*/(2);64 (void) /*range simple_expr=->+0:40*/i;65 (void)/*range simple_expr=->+0:47*/"literal";66 (void)/*range simple_expr=->+0:41*/'c';67}68 69// CHECK: 5 'simple_expr' results:70// CHECK-NEXT: the selected expression is too simple to extract71