Skip to content

Commit 61f3518

Browse files
committed
Fixes after rebasing
1 parent a731c8f commit 61f3518

24 files changed

+49
-47
lines changed

lib/Basic/LangOptions.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ static const SupportedConditionalValue SupportedConditionalCompilationEndianness
7373
"big"
7474
};
7575

76-
static const StringRef SupportedConditionalCompilationPointerBitWidths[] = {
76+
static const SupportedConditionalValue SupportedConditionalCompilationPointerBitWidths[] = {
7777
"_32",
7878
"_64"
7979
};
8080

81-
static const StringRef SupportedConditionalCompilationRuntimes[] = {
81+
static const SupportedConditionalValue SupportedConditionalCompilationRuntimes[] = {
8282
"_ObjC",
8383
"_Native",
8484
};
@@ -108,6 +108,8 @@ ArrayRef<SupportedConditionalValue> getSupportedConditionalCompilationValues(con
108108
return SupportedConditionalCompilationArches;
109109
case PlatformConditionKind::Endianness:
110110
return SupportedConditionalCompilationEndianness;
111+
case PlatformConditionKind::PointerBitWidth:
112+
return SupportedConditionalCompilationPointerBitWidths;
111113
case PlatformConditionKind::Runtime:
112114
return SupportedConditionalCompilationRuntimes;
113115
case PlatformConditionKind::CanImport:
@@ -362,32 +364,23 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
362364
break;
363365
}
364366

365-
// Set the "_native_word_size" platform condition.
367+
// Set the "_pointerBitWidth" platform condition.
366368
switch (Target.getArch()) {
369+
default: llvm_unreachable("undefined architecture pointer bit width");
367370
case llvm::Triple::ArchType::arm:
368371
case llvm::Triple::ArchType::thumb:
372+
case llvm::Triple::ArchType::aarch64_32:
373+
case llvm::Triple::ArchType::x86:
374+
case llvm::Triple::ArchType::wasm32:
369375
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
370376
break;
371377
case llvm::Triple::ArchType::aarch64:
372-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
373-
break;
374378
case llvm::Triple::ArchType::ppc64:
375-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
376-
break;
377379
case llvm::Triple::ArchType::ppc64le:
378-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
379-
break;
380-
case llvm::Triple::ArchType::x86:
381-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
382-
break;
383380
case llvm::Triple::ArchType::x86_64:
384-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
385-
break;
386381
case llvm::Triple::ArchType::systemz:
387382
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
388383
break;
389-
default:
390-
llvm_unreachable("undefined architecture pointer bit width");
391384
}
392385

393386
// Set the "runtime" platform condition.

lib/Parse/ParseIfConfig.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,16 @@ class ValidateIfConfigCondition :
324324
return E;
325325
}
326326

327-
// ( 'os' | 'arch' | '_endian' | '_pointer_bit_width' | '_runtime' | 'canImport') '(' identifier ')''
327+
if (*KindName == "canImport") {
328+
if (!isModulePath(Arg)) {
329+
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_argument,
330+
"module name");
331+
return nullptr;
332+
}
333+
return E;
334+
}
335+
336+
// ( 'os' | 'arch' | '_endian' | '_pointerBitWidth' | '_runtime') '(' identifier ')''
328337
auto Kind = getPlatformConditionKind(*KindName);
329338
if (!Kind.hasValue()) {
330339
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_expression);

test/Parse/ConditionalCompilation/aarch64AndroidTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm64) && os(Android) && _runtime(_Native) && _endian(little)
10+
#if arch(arm64) && os(Android) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
10+
#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/arm64IOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
10+
#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/armAndroidTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/armIOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/armWatchOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/i386IOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/i386WatchOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
10+
#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/identifierName.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
func f2(
66
FOO: Int,
77
swift: Int, _compiler_version: Int,
8-
os: Int, arch: Int, _endian: Int, _pointer_bit_width: Int, _runtime: Int,
8+
os: Int, arch: Int, _endian: Int, _pointerBitWidth: Int, _runtime: Int,
99
targetEnvironment: Int,
1010
arm: Int, i386: Int, macOS: Int, OSX: Int, Linux: Int,
1111
big: Int, little: Int,
@@ -22,8 +22,8 @@ func f2(
2222
_ = arch + i386 + arm
2323
#elseif _endian(big) && _endian(little)
2424
_ = _endian + big + little
25-
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
26-
_ = _pointer_bit_width + _32 + _64
25+
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
26+
_ = _pointerBitWidth + _32 + _64
2727
#elseif _runtime(_ObjC) && _runtime(_Native)
2828
_ = _runtime + _ObjC + _Native
2929
#elseif targetEnvironment(simulator)
@@ -37,7 +37,7 @@ func f2(
3737
func f2() {
3838
let
3939
FOO = 1, swift = 1, _compiler_version = 1,
40-
os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1,
40+
os = 1, arch = 1, _endian = 1, _pointerBitWidth = 1, _runtime = 1,
4141
targetEnvironment = 1,
4242
arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1,
4343
big = 1, little = 1,
@@ -53,8 +53,8 @@ func f2() {
5353
_ = arch + i386 + arm
5454
#elseif _endian(big) && _endian(little)
5555
_ = _endian + big + little
56-
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
57-
_ = _pointer_bit_width + _32 + _64
56+
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
57+
_ = _pointerBitWidth + _32 + _64
5858
#elseif _runtime(_ObjC) && _runtime(_Native)
5959
_ = _runtime + _ObjC + _Native
6060
#elseif targetEnvironment(simulator)
@@ -68,7 +68,7 @@ func f2() {
6868
struct S {
6969
let
7070
FOO = 1, swift = 1, _compiler_version = 1,
71-
os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1,
71+
os = 1, arch = 1, _endian = 1, _pointerBitWidth = 1, _runtime = 1,
7272
targetEnvironment = 1,
7373
arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1,
7474
big = 1, little = 1,
@@ -80,7 +80,7 @@ struct S {
8080
#elseif os(macOS) && os(OSX) && os(Linux)
8181
#elseif arch(i386) && arch(arm)
8282
#elseif _endian(big) && _endian(little)
83-
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
83+
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
8484
#elseif _runtime(_ObjC) && _runtime(_Native)
8585
#elseif targetEnvironment(simulator)
8686
#elseif swift(>=1.0) && _compiler_version("4.*.0")

test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target powerpc64-unknown-linux-gnu -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64-unknown-linux-gnu
33

4-
#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64)
4+
#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target powerpc64le-unknown-linux-gnu -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64le-unknown-linux-gnu
33

4-
#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
4+
#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/s390xLinuxTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target s390x-unknown-linux-gnu -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target s390x-unknown-linux-gnu
33

4-
#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64)
4+
#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/wasm32Target.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target wasm32-unknown-wasi -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename %s -target wasm32-unknown-wasi
33

4-
#if arch(wasm32) && os(WASI) && _runtime(_Native) && _endian(little)
4+
#if arch(wasm32) && os(WASI) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_32)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
10+
#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/x64CygwinTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-windows-cygnus -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus
3-
#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
3+
#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
44
class C {}
55
var x = C()
66
#endif

test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-freebsd10 -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10
33

4-
#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
4+
#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/x64IOSTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
10+
#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

test/Parse/ConditionalCompilation/x64LinuxTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-linux-gnu -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-linux-gnu
33

4-
#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
4+
#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/x64OSXTarget.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-apple-macosx10.9 -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-macosx10.9
33

4-
#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
4+
#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif
88
var y = x
99

1010

11-
#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
11+
#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
1212
class CC {}
1313
var xx = CC()
1414
#endif

test/Parse/ConditionalCompilation/x64WindowsTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-windows-msvc -disable-objc-interop -parse-stdlib
22
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc
33

4-
#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
4+
#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
55
class C {}
66
var x = C()
77
#endif

test/Parse/ConditionalCompilation/x86_64PS4Target.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let i: Int = "Hello"
88
#endif
99

10-
#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
10+
#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
1111
class C {}
1212
var x = C()
1313
#endif

0 commit comments

Comments
 (0)