File: ProhibitedDeclarations.cpp

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (72 lines) | stat: -rw-r--r-- 3,536 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
void dontRenameBuiltins(int x) {
  __builtin_assume(x != 0);
  __builtin_trap();
}

// RUN: not clang-refactor-test rename-initiate -at=%s:2:3 -at=%s:3:3 -new-name=foo %s 2>&1 | FileCheck %s
// CHECK: error: could not rename symbol at the given location

// RUN: not clang-refactor-test list-actions -at=%s:2:3 %s 2>&1 | FileCheck --check-prefix=CHECK-BUILTIN %s
// CHECK-BUILTIN: Failed to initiate 1 actions because:
// CHECK-BUILTIN-NEXT: Rename: '__builtin_assume' is a builtin function that cannot be renamed
// CHECK-BUILTIN-NEXT: No refactoring actions are available at the given location

#include <system-header.h>

void dontRenameSystemSymbols() {
  systemFunction();
}
// RUN: not clang-refactor-test rename-initiate -at=%s:17:3 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM %s
// CHECK-SYSTEM: 'systemFunction' cannot be renamed because it is declared in a system header

struct External {
  static void foo();
} __attribute__((external_source_symbol(language="Swift")));

void dontRenameExternalSourceSymbols() {
  External::foo();
}
// RUN: not clang-refactor-test rename-initiate -at=%s:27:3 -new-name=foo %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-EXTERNAL1 %s
// CHECK-EXTERNAL1: 'External' is declared in a Swift file; rename can be initiated in a Swift file only

// RUN: not clang-refactor-test rename-initiate -at=%s:27:13 -new-name=foo %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-EXTERNAL2 %s
// CHECK-EXTERNAL2: 'foo' is declared in a Swift file; rename can be initiated in a Swift file only

// Ensure that operators can't be renamed:
struct Stream {
};

Stream &operator <<(Stream &, int);

void renameArgsNotOperator(Stream x) { // CHECK-OP-X: rename local [[@LINE]]:35 -> [[@LINE]]:36
  int y = 0; // CHECK-OP-Y: rename local [[@LINE]]:7 -> [[@LINE]]:8
  x << // CHECK-OP-X: rename local [[@LINE]]:3 -> [[@LINE]]:4
  y << // CHECK-OP-Y: rename local [[@LINE]]:3 -> [[@LINE]]:4
  y; // CHECK-OP-Y: rename local [[@LINE]]:3 -> [[@LINE]]:4
}
// RUN: clang-refactor-test rename-initiate -at=%s:43:3 -new-name=foo %s | FileCheck --check-prefixes=CHECK-OP-X %s
// RUN: clang-refactor-test rename-initiate -at=%s:44:3 -at=%s:45:3 -new-name=foo %s | FileCheck --check-prefixes=CHECK-OP-Y %s

struct SystemStruct;

// RUN: not clang-refactor-test rename-initiate -at=%s:50:8 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM2 %s
// CHECK-SYSTEM2: 'SystemStruct' cannot be renamed because it is declared in a system header

typedef struct SystemStruct SystemTypedef;

// RUN: not clang-refactor-test rename-initiate -at=%s:55:29 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM3 %s
// CHECK-SYSTEM3: 'SystemTypedef' cannot be renamed because it is declared in a system header

enum SystemEnum;

// RUN: not clang-refactor-test rename-initiate -at=%s:60:6 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM4 %s
// CHECK-SYSTEM4: 'SystemEnum' cannot be renamed because it is declared in a system header

void systemFunction();

// RUN: not clang-refactor-test rename-initiate -at=%s:65:6 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM %s

int systemVariable;

// RUN: not clang-refactor-test rename-initiate -at=%s:69:5 -new-name=foo %s -isystem %S/Inputs 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYSTEM5 %s
// CHECK-SYSTEM5: 'systemVariable' cannot be renamed because it is declared in a system header