From f4e946c460b031923cbb24f3c3eb8ba709ed7979 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Mon, 7 Dec 2015 05:04:07 +0000 Subject: [PATCH 01/15] [Sema] Fix errors due to implicitly deleted copy constructor. --- include/swift/Sema/TypeCheckRequest.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/swift/Sema/TypeCheckRequest.h b/include/swift/Sema/TypeCheckRequest.h index b5767e54cf93b..880d5da1b2c3b 100644 --- a/include/swift/Sema/TypeCheckRequest.h +++ b/include/swift/Sema/TypeCheckRequest.h @@ -70,6 +70,7 @@ class TypeCheckRequest { /// The payload of the request, which differs based on the request kind. union PayloadType { PayloadType() { } + PayloadType(const PayloadType &) {} #define TYPE_CHECK_REQUEST_PAYLOAD(PayloadName,...) \ __VA_ARGS__ PayloadName; From 9211c7c0d484e2ebe9435d7b1f2510c43644d1e5 Mon Sep 17 00:00:00 2001 From: gregomni Date: Thu, 10 Dec 2015 23:26:18 -0800 Subject: [PATCH 02/15] Better diagnose error coming from unwrapping optional before initialized. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a check for whether the escape use is due to an UncheckedTakeEnumDataAddrInst, which accesses the memory to grab the .Some part of an Optional during “?.” or “!”. In that case, use the generic used-before-initialized diagnostic, since it isn’t actually because of closure capture. Added test cases, including specifically testing that capturing in a closure in order to unwrap the optional is still ok. --- lib/SILPasses/EarlySIL/DefiniteInitialization.cpp | 2 ++ test/SILPasses/definite_init_diagnostics.swift | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/SILPasses/EarlySIL/DefiniteInitialization.cpp b/lib/SILPasses/EarlySIL/DefiniteInitialization.cpp index f7e3dcd726ec2..8f8af66121c17 100644 --- a/lib/SILPasses/EarlySIL/DefiniteInitialization.cpp +++ b/lib/SILPasses/EarlySIL/DefiniteInitialization.cpp @@ -1094,6 +1094,8 @@ void LifetimeChecker::handleEscapeUse(const DIMemoryUse &Use) { DiagMessage = diag::variable_closure_use_uninit; else DiagMessage = diag::variable_function_use_uninit; + } else if (isa(Inst)) { + DiagMessage = diag::variable_used_before_initialized; } else { DiagMessage = diag::variable_closure_use_uninit; } diff --git a/test/SILPasses/definite_init_diagnostics.swift b/test/SILPasses/definite_init_diagnostics.swift index ad03ad2515952..96703d07ed66a 100644 --- a/test/SILPasses/definite_init_diagnostics.swift +++ b/test/SILPasses/definite_init_diagnostics.swift @@ -78,6 +78,12 @@ func test2() { takes_closure { // ok. markUsed(b3) } + + var b4 : Int? + takes_closure { // ok. + markUsed(b4!) + } + b4 = 7 // Structs var s1 : SomeStruct @@ -1184,3 +1190,9 @@ func test22436880() { x = 1 bug22436880(&x) // expected-error {{immutable value 'x' may not be passed inout}} } + +// sr-184 +let x: String? // expected-note 2 {{constant defined here}} +print(x?.characters.count) // expected-error {{constant 'x' used before being initialized}} +print(x!) // expected-error {{constant 'x' used before being initialized}} + From e799d3e93e11f8971860f1a41c7d04e3511f4af8 Mon Sep 17 00:00:00 2001 From: Justas Brazauskas Date: Fri, 11 Dec 2015 10:58:23 +0200 Subject: [PATCH 03/15] Fix typos --- CHANGELOG.md | 14 +++++++------- docs/doxygen.css | 4 ++-- include/swift/SIL/SILInstruction.h | 2 +- lib/AST/ArchetypeBuilder.cpp | 2 +- lib/AST/ConformanceLookupTable.cpp | 2 +- lib/AST/Verifier.cpp | 2 +- utils/swift-bench.py | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c303495af990b..fc79f27731e14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2891,7 +2891,7 @@ Latest @_silgen_name("foo") @objc ``` - The `,` was vestigial when the attribute syntax consisted of bracked lists. + The `,` was vestigial when the attribute syntax consisted of bracket lists. * `switch` now always requires a statement after a `case` or `default`. @@ -3106,7 +3106,7 @@ Latest inference (e.g. when passing a function argument). * Properties defined in classes are now dynamically dispatched and can be - overriden with `@override`. Currently `@override` only works with computed properties + overridden with `@override`. Currently `@override` only works with computed properties overriding other computed properties, but this will be enhanced in coming weeks. @@ -3190,7 +3190,7 @@ Latest ``` * The compiler now warns about cases where a variable is inferred to have - `AnyObject`, `AnyClass`, or `()` type, since type inferrence can turn a simple + `AnyObject`, `AnyClass`, or `()` type, since type inference can turn a simple mistake (e.g. failing to cast an `AnyObject` when you meant to) into something with ripple effects. Here is a simple example: @@ -3386,7 +3386,7 @@ Latest `#if` block. Target configurations are tested against their values via a pseudo-function - invocation expression, taking a single argument expressed as an identitifer. + invocation expression, taking a single argument expressed as an identifier. The argument represents certain static build-time information. There are currently two supported target configurations: @@ -4708,7 +4708,7 @@ Latest ``` * Attribute syntax has been redesigned (see **(rdar://10700853)** and - **(rdar://14462729)**) so that attributes now preceed the declaration and use + **(rdar://14462729)**) so that attributes now precede the declaration and use the `@` character to signify them. Where before you might have written: ```swift @@ -4830,7 +4830,7 @@ Latest ``` checks whether `object` has a value and, if so, asks for the length of - its title. `titleLength` wil have type `Int?`, and if `object` was + its title. `titleLength` will have type `Int?`, and if `object` was missing, the variable will be initialized to None. * Objects with type `id` can now be used as the receiver of property @@ -5293,5 +5293,5 @@ Latest * `POSIX.EnvironmentVariables` and `swift.CommandLineArguments` global variables were merged into a `swift.Process` variable. Now you can access command line - arguments with `Process.arguments`. In order to acces environment variables + arguments with `Process.arguments`. In order to access environment variables add `import POSIX` and use `Process.environmentVariables`. diff --git a/docs/doxygen.css b/docs/doxygen.css index 83951f673db8d..d5691ed7e62d1 100644 --- a/docs/doxygen.css +++ b/docs/doxygen.css @@ -313,8 +313,8 @@ HR { height: 1px; /* * LLVM Modifications. - * Note: Everything above here is generated with "doxygen -w htlm" command. See - * "doxygen --help" for details. What follows are CSS overrides for LLVM + * Note: Everything above here is generated with "doxygen -w html" command. See + * "doxygen --help" for details. What follows are CSS overrides for LLVM * specific formatting. We want to keep the above so it can be replaced with * subsequent doxygen upgrades. */ diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index f5fff6a3514e6..505af2a7926a9 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -864,7 +864,7 @@ class ApplyInst : public ApplyInstBase { return V->getKind() == ValueKind::ApplyInst; } - /// Returns true if the called function has an error result but is not actully + /// Returns true if the called function has an error result but is not actually /// throwing an error. bool isNonThrowing() const { return isNonThrowingApply(); diff --git a/lib/AST/ArchetypeBuilder.cpp b/lib/AST/ArchetypeBuilder.cpp index fe7aafddc3f21..f3305d27e3c48 100644 --- a/lib/AST/ArchetypeBuilder.cpp +++ b/lib/AST/ArchetypeBuilder.cpp @@ -854,7 +854,7 @@ bool ArchetypeBuilder::addSameTypeRequirementBetweenArchetypes( T1 = T1->getRepresentative(); T2 = T2->getRepresentative(); - // If the representives are already the same, we're done. + // If the representatives are already the same, we're done. if (T1 == T2) return false; diff --git a/lib/AST/ConformanceLookupTable.cpp b/lib/AST/ConformanceLookupTable.cpp index e109506048cf4..a063ac5977c9a 100644 --- a/lib/AST/ConformanceLookupTable.cpp +++ b/lib/AST/ConformanceLookupTable.cpp @@ -543,7 +543,7 @@ ConformanceLookupTable::Ordering ConformanceLookupTable::compareConformances( bool &diagnoseSuperseded) { // If one entry is fixed and the other is not, we have our answer. if (lhs->isFixed() != rhs->isFixed()) { - // If the non-fixed conformance is not replacable, we have a failure to + // If the non-fixed conformance is not replaceable, we have a failure to // diagnose. diagnoseSuperseded = (lhs->isFixed() && !isReplaceable(rhs->getRankingKind())) || diff --git a/lib/AST/Verifier.cpp b/lib/AST/Verifier.cpp index 937ecc1ac440d..3c8d0681f25e6 100644 --- a/lib/AST/Verifier.cpp +++ b/lib/AST/Verifier.cpp @@ -436,7 +436,7 @@ struct ASTNodeBase {}; return false; // We should know about archetypes corresponding to opened - // existerntial archetypes. + // existential archetypes. if (archetype->getOpenedExistentialType()) { if (OpenedExistentialArchetypes.count(archetype) == 0) { Out << "Found opened existential archetype " diff --git a/utils/swift-bench.py b/utils/swift-bench.py index 893ddbca28354..f083f12816b2a 100644 --- a/utils/swift-bench.py +++ b/utils/swift-bench.py @@ -26,7 +26,7 @@ # o When all files are compiled, the harness begins to run the tests. The # harness chooses a number of iterations for each tests to achieve the best # accuracy in the given time limit (in order to do that, it performs several -# auxiliary test runs). When the iteration number is chosen, the measurent +# auxiliary test runs). When the iteration number is chosen, the measurement # of execution time is actually performed. # o At this point everything is ready, and the harness simply reports the # results. From 37840dbc4fe500bc39d77d779bf1afa9401f5b1b Mon Sep 17 00:00:00 2001 From: halfnelson Date: Fri, 11 Dec 2015 21:57:23 +1000 Subject: [PATCH 04/15] cmark c flags should derive from cmark build type --- utils/build-script-impl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 5c2ffb69fffee..6bc8a3df0d56c 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -1229,7 +1229,7 @@ function llvm_c_flags() { function cmark_c_flags() { echo -n " $(common_cross_c_flags $1)" - if [[ $(is_cmake_release_build_type "${LLVM_BUILD_TYPE}") ]] ; then + if [[ $(is_cmake_release_build_type "${CMARK_BUILD_TYPE}") ]] ; then echo -n " -fno-stack-protector" fi } From 7730b4921edd3674459828d5263401c212b8ccaf Mon Sep 17 00:00:00 2001 From: Dylan Brown Date: Fri, 11 Dec 2015 17:19:50 +0200 Subject: [PATCH 05/15] Update README.md Update the README.md instructions for utils/update-checkout option. Should read `--clone-with-ssh`. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7e513dc5f16e..2979b70647574 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ uploading SSH keys to GitHub): git clone git@github.com:apple/swift.git cd swift - ./utils/update-checkout --clone-via-ssh + ./utils/update-checkout --clone-with-ssh [CMake](http://cmake.org) is the core infrastructure used to configure builds of Swift and its companion projects; at least version 2.8.12.2 is required. Your From 4dad7c7d3e5c460e6e6c5ef0cdb385a1c449a0ab Mon Sep 17 00:00:00 2001 From: Vincent Garrigues Date: Fri, 11 Dec 2015 16:50:19 +0100 Subject: [PATCH 06/15] Update getting started instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7e513dc5f16e..2979b70647574 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ uploading SSH keys to GitHub): git clone git@github.com:apple/swift.git cd swift - ./utils/update-checkout --clone-via-ssh + ./utils/update-checkout --clone-with-ssh [CMake](http://cmake.org) is the core infrastructure used to configure builds of Swift and its companion projects; at least version 2.8.12.2 is required. Your From 2adabe500bdba7a528bfd16a5ecbb9b80b48bf05 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 11 Dec 2015 01:06:48 -0800 Subject: [PATCH 07/15] IRGen: Fix incorrect conditional in multi-payload destructiveInjectEnumTag() witness We were checking if the tag was <= numPayloadCases, not <. Fix this and swap the order of the basic blocks so that the no-tag case is the fall through for consistency with getEnumTag(). --- lib/IRGen/GenEnum.cpp | 25 ++++++------ test/IRGen/enum_value_semantics.sil | 60 ++++++++++++++--------------- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp index 39d6ac0649348..472fac3f3ef76 100644 --- a/lib/IRGen/GenEnum.cpp +++ b/lib/IRGen/GenEnum.cpp @@ -4068,29 +4068,30 @@ namespace { return storeDynamicTag(IGF, enumAddr, tag, T); } - auto &C = IGF.IGM.getLLVMContext(); - auto payloadBB = llvm::BasicBlock::Create(C); - auto noPayloadBB = llvm::BasicBlock::Create(C); - auto endBB = llvm::BasicBlock::Create(C); - + // If there are no empty cases, don't need a conditional. if (ElementsWithNoPayload.empty()) { storePayloadTag(IGF, enumAddr, tag, T); return; } + auto &C = IGF.IGM.getLLVMContext(); + auto noPayloadBB = llvm::BasicBlock::Create(C); + auto payloadBB = llvm::BasicBlock::Create(C); + auto endBB = llvm::BasicBlock::Create(C); + llvm::Value *numPayloadCases = llvm::ConstantInt::get(IGF.IGM.Int32Ty, ElementsWithPayload.size()); - llvm::Value *cond = IGF.Builder.CreateICmpULE(tag, numPayloadCases); - IGF.Builder.CreateCondBr(cond, payloadBB, noPayloadBB); + llvm::Value *cond = IGF.Builder.CreateICmpUGE(tag, numPayloadCases); + IGF.Builder.CreateCondBr(cond, noPayloadBB, payloadBB); - IGF.Builder.emitBlock(payloadBB); - storePayloadTag(IGF, enumAddr, tag, T); + IGF.Builder.emitBlock(noPayloadBB); + llvm::Value *noPayloadTag = IGF.Builder.CreateSub(tag, numPayloadCases); + storeNoPayloadTag(IGF, enumAddr, noPayloadTag, T); IGF.Builder.CreateBr(endBB); - IGF.Builder.emitBlock(noPayloadBB); - tag = IGF.Builder.CreateSub(tag, numPayloadCases); - storeNoPayloadTag(IGF, enumAddr, tag, T); + IGF.Builder.emitBlock(payloadBB); + storePayloadTag(IGF, enumAddr, tag, T); IGF.Builder.CreateBr(endBB); IGF.Builder.emitBlock(endBB); diff --git a/test/IRGen/enum_value_semantics.sil b/test/IRGen/enum_value_semantics.sil index 4bf74df07cd7f..d56de80e57e67 100644 --- a/test/IRGen/enum_value_semantics.sil +++ b/test/IRGen/enum_value_semantics.sil @@ -358,17 +358,8 @@ bb0(%0 : $SinglePayloadNontrivial): // -- MultiPayloadTrivial destructiveInjectEnumTag // CHECK-LABEL: define linkonce_odr hidden void @_TwuiO20enum_value_semantics19MultiPayloadTrivial // CHECK: [[SELF:%.*]] = bitcast %swift.opaque* %value to %O20enum_value_semantics19MultiPayloadTrivial* -// CHECK-NEXT: [[IS_PAYLOAD:%.*]] = icmp ule i32 %tag, 2 -// CHECK-NEXT: br i1 [[IS_PAYLOAD]], label %[[HAS_PAYLOAD:.*]], label %[[HAS_NO_PAYLOAD:.*]] - -// CHECK: ;