Skip to content

Commit

Permalink
Fixes after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
drexin committed Feb 25, 2022
1 parent a731c8f commit 61f3518
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 47 deletions.
25 changes: 9 additions & 16 deletions lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ static const SupportedConditionalValue SupportedConditionalCompilationEndianness
"big"
};

static const StringRef SupportedConditionalCompilationPointerBitWidths[] = {
static const SupportedConditionalValue SupportedConditionalCompilationPointerBitWidths[] = {
"_32",
"_64"
};

static const StringRef SupportedConditionalCompilationRuntimes[] = {
static const SupportedConditionalValue SupportedConditionalCompilationRuntimes[] = {
"_ObjC",
"_Native",
};
Expand Down Expand Up @@ -108,6 +108,8 @@ ArrayRef<SupportedConditionalValue> getSupportedConditionalCompilationValues(con
return SupportedConditionalCompilationArches;
case PlatformConditionKind::Endianness:
return SupportedConditionalCompilationEndianness;
case PlatformConditionKind::PointerBitWidth:
return SupportedConditionalCompilationPointerBitWidths;
case PlatformConditionKind::Runtime:
return SupportedConditionalCompilationRuntimes;
case PlatformConditionKind::CanImport:
Expand Down Expand Up @@ -362,32 +364,23 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
break;
}

// Set the "_native_word_size" platform condition.
// Set the "_pointerBitWidth" platform condition.
switch (Target.getArch()) {
default: llvm_unreachable("undefined architecture pointer bit width");
case llvm::Triple::ArchType::arm:
case llvm::Triple::ArchType::thumb:
case llvm::Triple::ArchType::aarch64_32:
case llvm::Triple::ArchType::x86:
case llvm::Triple::ArchType::wasm32:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
break;
case llvm::Triple::ArchType::aarch64:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
break;
case llvm::Triple::ArchType::ppc64:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
break;
case llvm::Triple::ArchType::ppc64le:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
break;
case llvm::Triple::ArchType::x86:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32");
break;
case llvm::Triple::ArchType::x86_64:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
break;
case llvm::Triple::ArchType::systemz:
addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64");
break;
default:
llvm_unreachable("undefined architecture pointer bit width");
}

// Set the "runtime" platform condition.
Expand Down
11 changes: 10 additions & 1 deletion lib/Parse/ParseIfConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,16 @@ class ValidateIfConfigCondition :
return E;
}

// ( 'os' | 'arch' | '_endian' | '_pointer_bit_width' | '_runtime' | 'canImport') '(' identifier ')''
if (*KindName == "canImport") {
if (!isModulePath(Arg)) {
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_argument,
"module name");
return nullptr;
}
return E;
}

// ( 'os' | 'arch' | '_endian' | '_pointerBitWidth' | '_runtime') '(' identifier ')''
auto Kind = getPlatformConditionKind(*KindName);
if (!Kind.hasValue()) {
D.diagnose(E->getLoc(), diag::unsupported_platform_condition_expression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm64) && os(Android) && _runtime(_Native) && _endian(little)
#if arch(arm64) && os(Android) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/arm64IOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/armAndroidTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_32)
#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/armIOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/armWatchOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/i386IOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/i386WatchOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32)
#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
16 changes: 8 additions & 8 deletions test/Parse/ConditionalCompilation/identifierName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
func f2(
FOO: Int,
swift: Int, _compiler_version: Int,
os: Int, arch: Int, _endian: Int, _pointer_bit_width: Int, _runtime: Int,
os: Int, arch: Int, _endian: Int, _pointerBitWidth: Int, _runtime: Int,
targetEnvironment: Int,
arm: Int, i386: Int, macOS: Int, OSX: Int, Linux: Int,
big: Int, little: Int,
Expand All @@ -22,8 +22,8 @@ func f2(
_ = arch + i386 + arm
#elseif _endian(big) && _endian(little)
_ = _endian + big + little
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
_ = _pointer_bit_width + _32 + _64
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
_ = _pointerBitWidth + _32 + _64
#elseif _runtime(_ObjC) && _runtime(_Native)
_ = _runtime + _ObjC + _Native
#elseif targetEnvironment(simulator)
Expand All @@ -37,7 +37,7 @@ func f2(
func f2() {
let
FOO = 1, swift = 1, _compiler_version = 1,
os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1,
os = 1, arch = 1, _endian = 1, _pointerBitWidth = 1, _runtime = 1,
targetEnvironment = 1,
arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1,
big = 1, little = 1,
Expand All @@ -53,8 +53,8 @@ func f2() {
_ = arch + i386 + arm
#elseif _endian(big) && _endian(little)
_ = _endian + big + little
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
_ = _pointer_bit_width + _32 + _64
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
_ = _pointerBitWidth + _32 + _64
#elseif _runtime(_ObjC) && _runtime(_Native)
_ = _runtime + _ObjC + _Native
#elseif targetEnvironment(simulator)
Expand All @@ -68,7 +68,7 @@ func f2() {
struct S {
let
FOO = 1, swift = 1, _compiler_version = 1,
os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1,
os = 1, arch = 1, _endian = 1, _pointerBitWidth = 1, _runtime = 1,
targetEnvironment = 1,
arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1,
big = 1, little = 1,
Expand All @@ -80,7 +80,7 @@ struct S {
#elseif os(macOS) && os(OSX) && os(Linux)
#elseif arch(i386) && arch(arm)
#elseif _endian(big) && _endian(little)
#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64)
#elseif _pointerBitWidth(_32) && _pointerBitWidth(_64)
#elseif _runtime(_ObjC) && _runtime(_Native)
#elseif targetEnvironment(simulator)
#elseif swift(>=1.0) && _compiler_version("4.*.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target powerpc64-unknown-linux-gnu -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64-unknown-linux-gnu

#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64)
#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target powerpc64le-unknown-linux-gnu -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64le-unknown-linux-gnu

#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/s390xLinuxTarget.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target s390x-unknown-linux-gnu -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target s390x-unknown-linux-gnu

#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64)
#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/wasm32Target.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target wasm32-unknown-wasi -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename %s -target wasm32-unknown-wasi

#if arch(wasm32) && os(WASI) && _runtime(_Native) && _endian(little)
#if arch(wasm32) && os(WASI) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_32)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64CygwinTarget.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-windows-cygnus -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus
#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-freebsd10 -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10

#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64IOSTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64LinuxTarget.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-linux-gnu -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-linux-gnu

#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
4 changes: 2 additions & 2 deletions test/Parse/ConditionalCompilation/x64OSXTarget.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// RUN: %swift -typecheck %s -verify -target x86_64-apple-macosx10.9 -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-macosx10.9

#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
var y = x


#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointerBitWidth(_64)
class CC {}
var xx = CC()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x64WindowsTarget.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-windows-msvc -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc

#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/Parse/ConditionalCompilation/x86_64PS4Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let i: Int = "Hello"
#endif

#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64)
#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointerBitWidth(_64)
class C {}
var x = C()
#endif
Expand Down

0 comments on commit 61f3518

Please sign in to comment.