File: disallowed-expressions.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (50 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
void disallowExtractOfSimpleExpressions(int param) {
  int var = param;
  short var2 = (short)(var);
  int x = 0;
  const char *s = "Test";
  char c = 'C';
  double y = ((2.1));
  const char *f = __func__;
}

// RUN: not clang-refactor-test initiate -action extract -selected=%s:2:13-2:18 -selected=%s:2:14-2:15 -selected=%s:2:16-2:18 %s 2>&1 | FileCheck %s
// RUN: not clang-refactor-test initiate -action extract -selected=%s:3:16-3:28 -selected=%s:4:11-4:12 -selected=%s:5:19-5:25 %s 2>&1 | FileCheck %s
// RUN: not clang-refactor-test initiate -action extract -selected=%s:6:12-6:15 -selected=%s:7:14-7:21 -selected=%s:8:19-8:27 %s 2>&1 | FileCheck %s

// CHECK: Failed to initiate the refactoring action (the selected expression is too simple)!

void allowOperationsOnSimpleExpression(int x, int y) {
  int z = x + y;
  int zz = 0 + 1;
  allowOperationsOnSimpleExpression(1, y);
}

// RUN: clang-refactor-test initiate -action extract -selected=%s:18:11-18:16 %s | FileCheck --check-prefix=CHECK1 %s
// CHECK1: Initiated the 'extract' action at 18:11 -> 18:16

// RUN: clang-refactor-test initiate -action extract -selected=%s:19:12-19:17 %s | FileCheck --check-prefix=CHECK2 %s
// CHECK2: Initiated the 'extract' action at 19:12 -> 19:17

// RUN: clang-refactor-test initiate -action extract -selected=%s:20:37-20:41 %s | FileCheck --check-prefix=CHECK3 %s
// CHECK3: Initiated the 'extract' action at 20:3 -> 20:42

void defaultParameter(int x = 0 + 1) {

}

struct Struct {
  int y = 22 + 21;

  Struct(int x) : y(x + 1) { }
};

int initializerExpression = 1 + 2;

// RUN: not clang-refactor-test initiate -action extract -selected=%s:32:31-32:36 -selected=%s:37:11-37:18 -selected=%s:39:21-39:26 -selected=%s:42:29-42:34 %s 2>&1 | FileCheck --check-prefix=NOT-IN-FUNC %s
// NOT-IN-FUNC: Failed to initiate the refactoring action (the selected expression is not in a function)!

void disallowWholeFunctionBody() {
  int x = 0;
}
// RUN: not clang-refactor-test initiate -action extract -selected=%s:47:34-49:2 %s 2>&1 | FileCheck --check-prefix=NOT-IN-FUNC %s