[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Refactor / Extract / FromMethodToFunction.cpp
blob86bec16edfd1478ba46ef5872afd4d1ec5117f2c
1 // RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 2>&1 | grep -v CHECK | FileCheck --check-prefixes=CHECK,CHECK-INNER %s
2 // RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 -DMULTIPLE 2>&1 | grep -v CHECK | FileCheck --check-prefixes=CHECK,CHECK-OUTER %s
4 #ifdef MULTIPLE
5 class OuterClass {
6 #define PREFIX OuterClass ::
7 #else
8 #define PREFIX
9 #endif
11 class AClass {
13 int method(int x) {
14 return /*range inner=->+0:38*/1 + 2 * 2;
16 // CHECK-INNER: 1 'inner' results:
17 // CHECK-INNER: static int extracted() {
18 // CHECK-INNER-NEXT: return 1 + 2 * 2;{{$}}
19 // CHECK-INNER-NEXT: }{{[[:space:]].*}}
20 // CHECK-INNER-NEXT: class AClass {
22 // CHECK-OUTER: 1 'inner' results:
23 // CHECK-OUTER: static int extracted() {
24 // CHECK-OUTER-NEXT: return 1 + 2 * 2;{{$}}
25 // CHECK-OUTER-NEXT: }{{[[:space:]].*}}
26 // CHECK-OUTER-NEXT: class OuterClass {
28 int otherMethod(int x);
31 #ifdef MULTIPLE
33 #endif
35 int PREFIX AClass::otherMethod(int x) {
36 return /*range outofline=->+0:46*/2 * 2 - 1;
38 // CHECK: 1 'outofline' results:
39 // CHECK: static int extracted() {
40 // CHECK-NEXT: return 2 * 2 - 1;{{$}}
41 // CHECK-NEXT: }{{[[:space:]].*}}
42 // CHECK-NEXT: int PREFIX AClass::otherMethod