Skip to content

Commit ddd5479

Browse files
committed
Fixes after rebasing
1 parent f9d55e4 commit ddd5479

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
@@ -75,12 +75,12 @@ static const SupportedConditionalValue SupportedConditionalCompilationEndianness
7575
"big"
7676
};
7777

78-
static const StringRef SupportedConditionalCompilationPointerBitWidths[] = {
78+
static const SupportedConditionalValue SupportedConditionalCompilationPointerBitWidths[] = {
7979
"_32",
8080
"_64"
8181
};
8282

83-
static const StringRef SupportedConditionalCompilationRuntimes[] = {
83+
static const SupportedConditionalValue SupportedConditionalCompilationRuntimes[] = {
8484
"_ObjC",
8585
"_Native",
8686
};
@@ -110,6 +110,8 @@ ArrayRef<SupportedConditionalValue> getSupportedConditionalCompilationValues(con
110110
return SupportedConditionalCompilationArches;
111111
case PlatformConditionKind::Endianness:
112112
return SupportedConditionalCompilationEndianness;
113+
case PlatformConditionKind::PointerBitWidth:
114+
return SupportedConditionalCompilationPointerBitWidths;
113115
case PlatformConditionKind::Runtime:
114116
return SupportedConditionalCompilationRuntimes;
115117
case PlatformConditionKind::CanImport:
@@ -391,32 +393,23 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
391393
break;
392394
}
393395

394-
// Set the "_native_word_size" platform condition.
396+
// Set the "_pointerBitWidth" platform condition.
395397
switch (Target.getArch()) {
398+
default: llvm_unreachable("undefined architecture pointer bit width");
396399
case llvm::Triple::ArchType::arm:
397400
case llvm::Triple::ArchType::thumb:
401+
case llvm::Triple::ArchType::aarch64_32:
402+
case llvm::Triple::ArchType::x86:
403+
case llvm::Triple::ArchType::wasm32:
398404
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
399405
break;
400406
case llvm::Triple::ArchType::aarch64:
401-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
402-
break;
403407
case llvm::Triple::ArchType::ppc64:
404-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
405-
break;
406408
case llvm::Triple::ArchType::ppc64le:
407-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
408-
break;
409-
case llvm::Triple::ArchType::x86:
410-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
411-
break;
412409
case llvm::Triple::ArchType::x86_64:
413-
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
414-
break;
415410
case llvm::Triple::ArchType::systemz:
416411
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
417412
break;
418-
default:
419-
llvm_unreachable("undefined architecture pointer bit width");
420413
}
421414

422415
// Set the "runtime" platform condition.

lib/Parse/ParseIfConfig.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,16 @@ class ValidateIfConfigCondition :
327327
return E;
328328
}
329329

330-
// ( 'os' | 'arch' | '_endian' | '_pointer_bit_width' | '_runtime' | 'canImport') '(' identifier ')''
330+
if (*KindName == "canImport") {
331+
if (!isModulePath(Arg)) {
332+
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_argument,
333+
"module name");
334+
return nullptr;
335+
}
336+
return E;
337+
}
338+
339+
// ( 'os' | 'arch' | '_endian' | '_pointerBitWidth' | '_runtime') '(' identifier ')''
331340
if (*KindName == "hasFeature") {
332341
if (!getDeclRefStr(Arg, DeclRefKind::Ordinary)) {
333342
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_argument,

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)