Skip to content

Commit d2c11a0

Browse files
committed
---
yaml --- r: 278397 b: refs/heads/swift-5.1-old-llvm-branch c: 846ae44 h: refs/heads/master i: 278395: 155e951
1 parent 4e4e7f2 commit d2c11a0

File tree

14 files changed

+87
-66
lines changed

14 files changed

+87
-66
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
12411241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
12421242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
12431243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244-
refs/heads/swift-5.1-old-llvm-branch: e80c4d1959ebb9b1ec68ec7d23ce0a7e2f80b7c8
1244+
refs/heads/swift-5.1-old-llvm-branch: 846ae44a1fc25509985b5b6a132bb3ccb13af9eb
12451245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
12461246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
12471247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e

branches/swift-5.1-old-llvm-branch/lib/Sema/CSSimplify.cpp

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,10 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
12281228
llvm_unreachable("Not a relational constraint");
12291229
}
12301230

1231+
// Input types can be contravariant (or equal).
1232+
auto argumentLocator =
1233+
locator.withPathElement(ConstraintLocator::FunctionArgument);
1234+
12311235
TypeMatchOptions subflags = getDefaultDecompositionOptions(flags);
12321236

12331237
SmallVector<AnyFunctionType::Param, 8> func1Params;
@@ -1254,8 +1258,23 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
12541258
auto implodeParams = [&](SmallVectorImpl<AnyFunctionType::Param> &params) {
12551259
auto input = AnyFunctionType::composeInput(getASTContext(), params,
12561260
/*canonicalVararg=*/false);
1261+
12571262
params.clear();
1258-
params.emplace_back(input);
1263+
// If fixes are disabled let's do an easy thing and implode
1264+
// tuple directly into parameters list.
1265+
if (!shouldAttemptFixes()) {
1266+
params.emplace_back(input);
1267+
return;
1268+
}
1269+
1270+
// Synthesize new argument and bind it to tuple formed from existing
1271+
// arguments, this makes it easier to diagnose cases where we attempt
1272+
// a single tuple element formed when no arguments were present.
1273+
auto argLoc = argumentLocator.withPathElement(
1274+
LocatorPathElt::getSynthesizedArgument(0));
1275+
auto *typeVar = createTypeVariable(getConstraintLocator(argLoc));
1276+
params.emplace_back(typeVar);
1277+
assignFixedType(typeVar, input);
12591278
};
12601279

12611280
{
@@ -1323,10 +1342,6 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
13231342
}
13241343
}
13251344

1326-
// Input types can be contravariant (or equal).
1327-
auto argumentLocator = locator.withPathElement(
1328-
ConstraintLocator::FunctionArgument);
1329-
13301345
int diff = func1Params.size() - func2Params.size();
13311346
if (diff != 0) {
13321347
if (!shouldAttemptFixes())
@@ -1796,6 +1811,46 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
17961811

17971812
auto &elt = path.back();
17981813
switch (elt.getKind()) {
1814+
case ConstraintLocator::FunctionArgument: {
1815+
auto *argLoc = cs.getConstraintLocator(
1816+
locator.withPathElement(LocatorPathElt::getSynthesizedArgument(0)));
1817+
1818+
// Let's drop the last element which points to a single argument
1819+
// and see if this is a contextual mismatch.
1820+
path.pop_back();
1821+
if (path.empty() ||
1822+
!(path.back().getKind() == ConstraintLocator::ApplyArgToParam ||
1823+
path.back().getKind() == ConstraintLocator::ContextualType))
1824+
return;
1825+
1826+
auto arg = llvm::find_if(cs.getTypeVariables(),
1827+
[&argLoc](const TypeVariableType *typeVar) {
1828+
return typeVar->getImpl().getLocator() == argLoc;
1829+
});
1830+
1831+
// What we have here is a form or tuple splat with no arguments
1832+
// demonstrated by following example:
1833+
//
1834+
// func foo<T: P>(_: T, _: (T.Element) -> Int) {}
1835+
// foo { 42 }
1836+
//
1837+
// In cases like this `T.Element` might be resolved to `Void`
1838+
// which means that we have to try a single empty tuple argument
1839+
// as a narrow exception to SE-0110, see `matchFunctionTypes`.
1840+
//
1841+
// But if `T.Element` didn't get resolved to `Void` we'd like
1842+
// to diagnose this as a missing argument which can't be ignored.
1843+
if (arg != cs.getTypeVariables().end()) {
1844+
auto fnType = FunctionType::get({FunctionType::Param(lhs)},
1845+
cs.getASTContext().TheEmptyTupleType);
1846+
conversionsOrFixes.push_back(AddMissingArguments::create(
1847+
cs, fnType, {FunctionType::Param(*arg)},
1848+
cs.getConstraintLocator(anchor, path,
1849+
/*summaryFlags=*/0)));
1850+
}
1851+
break;
1852+
}
1853+
17991854
case ConstraintLocator::TypeParameterRequirement:
18001855
case ConstraintLocator::ConditionalRequirement: {
18011856
if (auto *fix = fixRequirementFailure(cs, lhs, rhs, anchor, path))
@@ -5707,7 +5762,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
57075762

57085763
case FixKind::SkipSameTypeRequirement:
57095764
case FixKind::SkipSuperclassRequirement:
5710-
case FixKind::ContextualMismatch: {
5765+
case FixKind::ContextualMismatch:
5766+
case FixKind::AddMissingArguments: {
57115767
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
57125768
}
57135769

@@ -5723,7 +5779,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
57235779
case FixKind::AllowTypeOrInstanceMember:
57245780
case FixKind::AllowInvalidPartialApplication:
57255781
case FixKind::AllowInvalidInitRef:
5726-
case FixKind::AddMissingArguments:
57275782
llvm_unreachable("handled elsewhere");
57285783
}
57295784

branches/swift-5.1-old-llvm-branch/stdlib/public/Darwin/os/os.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
if (_os_log_encode(buf, fmt, args, saved_errno, &ob)) {
8888
if (os_log_pack_send) {
8989
size_t sz = _os_log_pack_size(ob.ob_len);
90-
uint8_t _Alignas(os_log_pack_s) pack[sz];
91-
os_log_pack_t p = (os_log_pack_t)pack;
90+
uint8_t _Alignas(os_log_pack_s) buf[sz];
91+
os_log_pack_t p = (os_log_pack_t)buf;
9292
/*
9393
* _os_log_encode has already packed `saved_errno` into a
9494
* OSLF_CMD_TYPE_SCALAR command as the OSLF_CMD_TYPE_ERRNO does not
@@ -136,8 +136,8 @@
136136
_os_log_encode(buf, fmt, args, saved_errno, &ob);
137137
if (encoded) {
138138
size_t sz = _os_log_pack_size(ob.ob_len);
139-
uint8_t _Alignas(os_log_pack_s) pack[sz];
140-
os_log_pack_t p = (os_log_pack_t)pack;
139+
uint8_t _Alignas(os_log_pack_s) buf[sz];
140+
os_log_pack_t p = (os_log_pack_t)buf;
141141
uint8_t *ptr = _os_signpost_pack_fill(p, sz, saved_errno, dso,
142142
fmt, spnm, spid);
143143
p->olp_pc = ra;

branches/swift-5.1-old-llvm-branch/stdlib/public/SwiftShims/GlobalObjects.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ static_assert(
102102
4 * sizeof(__swift_intptr_t) + sizeof(__swift_int64_t),
103103
"_SwiftSetBodyStorage has unexpected size");
104104

105+
static_assert(std::is_pod<_SwiftEmptyArrayStorage>::value,
106+
"empty array type should be POD");
107+
static_assert(std::is_pod<_SwiftEmptyDictionarySingleton>::value,
108+
"empty dictionary type should be POD");
109+
static_assert(std::is_pod<_SwiftEmptySetSingleton>::value,
110+
"empty set type should be POD");
111+
105112
}} // extern "C", namespace swift
106113
#endif
107114

branches/swift-5.1-old-llvm-branch/stdlib/public/SwiftShims/HeapObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ __swift_size_t swift_weakRetainCount(HeapObject *obj);
9393
#endif
9494

9595
#ifdef __cplusplus
96+
static_assert(swift::IsTriviallyConstructible<HeapObject>::value,
97+
"HeapObject must be trivially initializable");
9698
static_assert(std::is_trivially_destructible<HeapObject>::value,
9799
"HeapObject must be trivially destructible");
98100

branches/swift-5.1-old-llvm-branch/stdlib/public/SwiftShims/RefCount.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,8 @@ class RefCounts {
11881188
typedef RefCounts<InlineRefCountBits> InlineRefCounts;
11891189
typedef RefCounts<SideTableRefCountBits> SideTableRefCounts;
11901190

1191+
static_assert(swift::IsTriviallyConstructible<InlineRefCounts>::value,
1192+
"InlineRefCounts must be trivially initializable");
11911193
static_assert(std::is_trivially_destructible<InlineRefCounts>::value,
11921194
"InlineRefCounts must be trivially destructible");
11931195

branches/swift-5.1-old-llvm-branch/stdlib/public/core/Optional.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ func _diagnoseUnexpectedNilOptional(_filenameStart: Builtin.RawPointer,
300300
_filenameIsASCII: Builtin.Int1,
301301
_line: Builtin.Word,
302302
_isImplicitUnwrap: Builtin.Int1) {
303-
// Cannot use _preconditionFailure as the file and line info would not be
304-
// printed.
305-
preconditionFailure(
303+
_preconditionFailure(
306304
Bool(_isImplicitUnwrap)
307305
? "Unexpectedly found nil while implicitly unwrapping an Optional value"
308306
: "Unexpectedly found nil while unwrapping an Optional value",

branches/swift-5.1-old-llvm-branch/stdlib/public/runtime/HeapObject.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ static HeapObject *_swift_allocObject_(HeapMetadata const *metadata,
8484
assert(isAlignmentMask(requiredAlignmentMask));
8585
auto object = reinterpret_cast<HeapObject *>(
8686
swift_slowAlloc(requiredSize, requiredAlignmentMask));
87-
88-
// NOTE: this relies on the C++17 guaranteed semantics of no null-pointer
89-
// check on the placement new allocator which we have observed on Windows,
90-
// Linux, and macOS.
91-
new (object) HeapObject(metadata);
87+
// FIXME: this should be a placement new but that adds a null check
88+
object->metadata = metadata;
89+
object->refCounts.init();
9290

9391
// If leak tracking is enabled, start tracking this object.
9492
SWIFT_LEAKS_START_TRACKING_OBJECT(object);

branches/swift-5.1-old-llvm-branch/test/Constraints/closures.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,8 @@ do {
894894
}
895895

896896
func foo(_ arr: [Int]) {
897-
// FIXME: This behavior related to tuple splat being allowed
898-
// in conversion between a single dependent member
899-
// parameter and empty parameter functions e.g.
900-
// () -> Void `convertable to` (T.V) -> Void.
901897
_ = S(arr, id: \.self_) {
902-
// expected-error@-1 {{type '_' has no member 'self_'}}
898+
// expected-error@-1 {{contextual type for closure argument list expects 1 argument, which cannot be implicitly ignored}} {{30-30=_ in }}
903899
return 42
904900
}
905901
}

branches/swift-5.1-old-llvm-branch/test/IDE/complete_override.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
// RUN: %target-swift-ide-test -enable-objc-interop -code-completion -source-filename %s -code-completion-token=OMIT_KEYWORD9_LET -code-completion-keywords=false | %FileCheck %s -check-prefix=OMIT_KEYWORD4
111111
// RUN: %target-swift-ide-test -enable-objc-interop -code-completion -source-filename %s -code-completion-token=OMIT_KEYWORD10 -code-completion-keywords=false | %FileCheck %s -check-prefix=WITH_PA_NO_PROTOFUNCA
112112

113-
// RUN: %target-swift-ide-test -enable-objc-interop -code-completion -source-filename %s -code-completion-token=SR2560_WHERE_CLAUSE -code-completion-keywords=false | %FileCheck %s -check-prefix=SR2560_WHERE_CLAUSE
114113
// RUN: %target-swift-ide-test -enable-objc-interop -code-completion -source-filename %s -code-completion-token=HAS_THROWING -code-completion-keywords=false | %FileCheck %s -check-prefix=HAS_THROWING
115114
// RUN: %target-swift-ide-test -enable-objc-interop -code-completion -source-filename %s -code-completion-token=ASSOC_TYPE1 -code-completion-keywords=false | %FileCheck %s -check-prefix=ASSOC_TYPE1
116115

@@ -524,17 +523,6 @@ class OmitKW10: ProtocolA {
524523
// WITH_PA
525524
}
526525

527-
protocol SR2560Proto {
528-
func foo<S : Sequence>(x: S) where S.Iterator.Element == Int
529-
}
530-
class SR2560Class: SR2560Proto {
531-
#^SR2560_WHERE_CLAUSE^#
532-
}
533-
534-
// SR2560_WHERE_CLAUSE: Begin completions
535-
// SR2560_WHERE_CLAUSE: Decl[InstanceMethod]/Super: func foo<S>(x: S) where S : Sequence, S.Element == Int {|};
536-
// SR2560_WHERE_CLAUSE: End completions
537-
538526
protocol HasThrowingProtocol {
539527
func foo() throws
540528
}

branches/swift-5.1-old-llvm-branch/test/stdlib/OptionalTraps.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,7 @@ OptionalTraps.test("UnwrapNone")
2525
{ _isFastAssertConfiguration() },
2626
reason: "this trap is not guaranteed to happen in -Ounchecked"))
2727
.code {
28-
let a: AnyObject? = returnNil()
29-
expectCrashLater()
30-
let unwrapped: AnyObject = a!
31-
_blackHole(unwrapped)
32-
}
33-
34-
OptionalTraps.test("UnwrapNone/location")
35-
.skip(.custom(
36-
{ _isFastAssertConfiguration() },
37-
reason: "this trap is not guaranteed to happen in -Ounchecked"))
38-
.crashOutputMatches(_isDebugAssertConfiguration()
39-
? "test/stdlib/OptionalTraps.swift, line 45"
40-
: "")
41-
.code {
42-
expectCrashLater()
43-
let a: AnyObject? = returnNil()
28+
var a: AnyObject? = returnNil()
4429
expectCrashLater()
4530
let unwrapped: AnyObject = a!
4631
_blackHole(unwrapped)

branches/swift-5.1-old-llvm-branch/unittests/runtime/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
22
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
33

4-
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
5-
# Do nothing
6-
elseif(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
4+
if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
75
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
86
message(FATAL_ERROR "Building the swift runtime is not supported with ${CMAKE_C_COMPILER_ID}. Use the just-built clang instead.")
7+
else()
8+
message(WARNING "Building the swift runtime using the host compiler, and not the just-built clang.")
99
endif()
1010
else()
11-
message(WARNING "Building the swift runtime using the host compiler, and not the just-built clang.")
12-
1311
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
1412
# with the frontend of Clang or Clang++.
1513
if(SWIFT_COMPILER_IS_MSVC_LIKE)

branches/swift-5.1-old-llvm-branch/validation-test/stdlib/Collection/FlattenCollection.swift.gyb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// RUN: %target-run-simple-swiftgyb
33
// REQUIRES: executable_test
44

5-
// FIXME: the test is too slow when the standard library is not optimized.
6-
// rdar://problem/46878013
7-
// REQUIRES: optimized_stdlib
8-
95
import SwiftPrivate
106
import StdlibUnittest
117
import StdlibCollectionUnittest

branches/swift-5.1-old-llvm-branch/validation-test/stdlib/Collection/LazyFilterCollection.swift.gyb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// RUN: %target-run-simple-swiftgyb
33
// REQUIRES: executable_test
44

5-
// FIXME: the test is too slow when the standard library is not optimized.
6-
// rdar://problem/46878013
7-
// REQUIRES: optimized_stdlib
8-
95
import SwiftPrivate
106
import StdlibUnittest
117
import StdlibCollectionUnittest

0 commit comments

Comments
 (0)