Skip to content

Commit 8ed7ae9

Browse files
committed
Merge remote-tracking branch 'apple/master'
2 parents a6457b2 + d2edaee commit 8ed7ae9

File tree

488 files changed

+5385
-812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+5385
-812
lines changed

docs/DebuggingTheCompiler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Here is how to dump the IR after the main phases of the swift compiler
3737
#. **Performance SIL passes**. To print the SIL after the complete SIL
3838
optimization pipeline::
3939

40-
swiftc -emit-sil -O file-swift
40+
swiftc -emit-sil -O file.swift
4141

4242
#. **IRGen**. To print the LLVM IR after IR generation::
4343

docs/Literals.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ The StringLiteralConvertible Protocol
3636
-------------------------------------
3737

3838
Here is the StringLiteralConvertible protocol as defined in the standard
39-
library's Policy.swift::
39+
library's CompilerProtocols.swift::
4040

4141
// NOTE: the compiler has builtin knowledge of this protocol
42-
protocol StringLiteralConvertible {
42+
// Conforming types can be initialized with arbitrary string literals.
43+
public protocol StringLiteralConvertible
44+
: ExtendedGraphemeClusterLiteralConvertible {
45+
4346
typealias StringLiteralType : _BuiltinStringLiteralConvertible
44-
class func convertFromStringLiteral(value : StringLiteralType) -> Self
47+
// Create an instance initialized to `value`.
48+
init(stringLiteral value: StringLiteralType)
4549
}
4650

4751
Curiously, the protocol is not defined in terms of primitive types, but in
@@ -58,13 +62,16 @@ points could be constructed...which may be what's desired in some cases.)
5862
The _BuiltinStringLiteralConvertible Protocol
5963
---------------------------------------------
6064

61-
Policy.swift contains a second protocol::
65+
CompilerProtocols.swift contains a second protocol::
6266

6367
// NOTE: the compiler has builtin knowledge of this protocol
64-
protocol _BuiltinStringLiteralConvertible {
65-
class func _convertFromBuiltinStringLiteral(value : Builtin.RawPointer,
66-
byteSize : Builtin.Int64,
67-
isASCII: Builtin.Int1) -> Self
68+
public protocol _BuiltinStringLiteralConvertible
69+
: _BuiltinExtendedGraphemeClusterLiteralConvertible {
70+
71+
init(
72+
_builtinStringLiteral start: Builtin.RawPointer,
73+
byteSize: Builtin.Word,
74+
isASCII: Builtin.Int1)
6875
}
6976

7077
The use of builtin types makes it clear that this is *only* for use in the

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4316,7 +4316,7 @@ constant replacement but leave the function application to be serialized to
43164316
sil).
43174317

43184318
The compiler flag that influences the value of the ``assert_configuration``
4319-
funtion application is the optimization flag: at ``-Onone` the application will
4319+
function application is the optimization flag: at ``-Onone` the application will
43204320
be replaced by ``Debug`` at higher optimization levels the instruction will be
43214321
replaced by ``Release``. Optionally, the value to use for replacement can be
43224322
specified with the ``-AssertConf`` flag which overwrites the value selected by

docs/archive/LangRef.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,13 @@ <h3 id="type-optional">Optional Types</h3>
12951295
<code>T?</code>.</li>
12961296
</ul>
12971297
To support these intrinsic use cases, the library is required to
1298-
provide four functions with these exact signatures:
1298+
provide functions with these exact signatures:
12991299
<ul>
1300-
<li><code>func _preconditionOptionalHasValue<T>(inout v : T?)</code>
1300+
<li><code>func _doesOptionalHaveValueAsBool<T>(v : T?) -> Bool</code></li>
1301+
<li><code>func _diagnoseUnexpectedNilOptional()</code></li>
13011302
<li><code>func _getOptionalValue<T>(v : T?) -> T</code></li>
1303+
<li><code>func _injectValueIntoOptional<T>(v : T) -> T?</code></li>
1304+
<li><code>func _injectNothingIntoOptional<T>() -> T?</code></li>
13021305
</ul>
13031306
</p>
13041307

@@ -1317,7 +1320,7 @@ <h3 id="type-optional">Optional Types</h3>
13171320
var b : Int? = .None
13181321

13191322
<i>// Declare an array of optionals:</i>
1320-
var c : Int?[] = new Int?[4]
1323+
var c : [Int?] = [10, nil, 42]
13211324
</pre>
13221325

13231326
<!-- _____________________________________________________________________ -->

docs/proposals/Accessors.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ objects::
8787
point = point1
8888
point0.x = x
8989
point = point0
90-
90+
9191
Note that ``point.y`` is left unchanged.
9292

9393
Local analysis
@@ -157,7 +157,7 @@ through unexpected aliases::
157157
Note that, in either solution, you've introduced extra full-value
158158
loads. This may be quite expensive, and it's not guaranteed to be
159159
semantically equivalent.
160-
160+
161161
Performance
162162
~~~~~~~~~~~
163163

@@ -453,7 +453,7 @@ Nor can this be fixed with a purely local analysis; consider::
453453

454454
class C { var array: [Int] }
455455
let global_C = C()
456-
456+
457457
func assign(inout value: Int) {
458458
C.array = []
459459
value = 0
@@ -606,7 +606,7 @@ General solutions
606606
~~~~~~~~~~~~~~~~~
607607

608608
A language generally has six tools for dealing with code it considers
609-
undesireable. Some of this terminology is taken from existing
609+
undesirable. Some of this terminology is taken from existing
610610
standards, others not.
611611

612612
* The language may nonetheless take steps to ensure that the code
@@ -916,7 +916,7 @@ I'm almost ready to state the core rule about formal accesses, but
916916
first I need to build up a few more definitions.
917917

918918
An *abstract storage location* (ASL) is:
919-
919+
920920
* a global variable declaration;
921921

922922
* an ``inout`` parameter declaration, along with a reference
@@ -1106,7 +1106,7 @@ the other FA's DSN set and (2) not from a non-overlapping subobject.
11061106
Are these conditions true?
11071107

11081108
Recall that an addressor is invoked for an l-value of the form::
1109-
1109+
11101110
base.memory
11111111

11121112
or::

include/swift/AST/Decl.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,11 @@ class alignas(1 << DeclAlignInBits) Decl {
573573
unsigned : NumTypeDeclBits;
574574

575575
unsigned Recursive : 1;
576+
577+
/// Whether or not this declaration is currently being type-checked.
578+
unsigned BeingTypeChecked : 1;
576579
};
577-
enum { NumAssociatedTypeDeclBits = NumTypeDeclBits + 1 };
580+
enum { NumAssociatedTypeDeclBits = NumTypeDeclBits + 2 };
578581
static_assert(NumAssociatedTypeDeclBits <= 32, "fits in an unsigned");
579582

580583
class ImportDeclBitfields {
@@ -2605,6 +2608,14 @@ class AssociatedTypeDecl : public AbstractTypeParamDecl {
26052608
void setIsRecursive() { AssociatedTypeDeclBits.Recursive = true; }
26062609
bool isRecursive() { return AssociatedTypeDeclBits.Recursive; }
26072610

2611+
/// Whether the declaration is currently being validated.
2612+
bool isBeingTypeChecked() { return AssociatedTypeDeclBits.BeingTypeChecked; }
2613+
2614+
/// Toggle whether or not the declaration is being validated.
2615+
void setIsBeingTypeChecked(bool ibt = true) {
2616+
AssociatedTypeDeclBits.BeingTypeChecked = ibt;
2617+
}
2618+
26082619
static bool classof(const Decl *D) {
26092620
return D->getKind() == DeclKind::AssociatedType;
26102621
}

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
732732
/// \code
733733
/// struct X<T, U> { }
734734
/// extension X {
735-
/// typealias SomeArray = [T];
735+
/// typealias SomeArray = [T]
736736
/// }
737737
/// \endcode
738738
///

include/swift/Basic/ValueEnumerator.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//===--- ValueEnumerator.h --- Enumerates values ----------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_BASIC_VALUEENUMERATOR_H
14+
#define SWIFT_BASIC_VALUEENUMERATOR_H
15+
16+
#include "llvm/ADT/DenseMap.h"
17+
#include "llvm/Support/raw_ostream.h"
18+
19+
namespace swift {
20+
21+
/// / This class maps values to unique indices.
22+
template<class ValueTy, class IndexTy = size_t>
23+
class ValueEnumerator {
24+
/// A running counter to enumerate values.
25+
IndexTy counter;
26+
27+
/// Maps values to unique integers.
28+
llvm::DenseMap<ValueTy, IndexTy> ValueToIndex;
29+
30+
public:
31+
/// Return the index of value \p v.
32+
IndexTy getIndex(const ValueTy &v) {
33+
// Return the index of this Key, if we've assigned one already.
34+
auto It = ValueToIndex.find(v);
35+
if (It != ValueToIndex.end()) {
36+
return It->second;
37+
}
38+
39+
// Generate a new counter for the key.
40+
ValueToIndex[v] = ++counter;
41+
return counter;
42+
}
43+
44+
ValueEnumerator() = default;
45+
46+
/// Forget about key \p v.
47+
void invalidateValue(const ValueTy &v) { ValueToIndex.erase(v); }
48+
49+
/// Clear the enumeration state of the
50+
void clear() {
51+
ValueToIndex.clear();
52+
counter = 0;
53+
}
54+
};
55+
56+
} // end namespace swift
57+
58+
#endif

include/swift/SIL/MemLocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ using TypeExpansionMap = llvm::DenseMap<SILType, ProjectionPathList>;
363363
/// the MemLocationVault, and this in turn reduces the # of bits each basic
364364
/// block keeps.
365365
///
366-
/// Moreover, without canonicalization, its more difficult to implement the
366+
/// Moreover, without canonicalization, it's more difficult to implement the
367367
/// intersection operator in DSE/RLE?
368368
///
369369
/// We basically need to compare every pair of MemLocation and find the ones

include/swift/SIL/SILFunction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ class SILFunction
165165
const SILDebugScope *debugScope,
166166
DeclContext *DC);
167167

168-
public:
169168
static SILFunction *create(SILModule &M, SILLinkage linkage, StringRef name,
170169
CanSILFunctionType loweredType,
171170
GenericParamList *contextGenericParams,
@@ -180,6 +179,8 @@ class SILFunction
180179
SILFunction *InsertBefore = nullptr,
181180
const SILDebugScope *DebugScope = nullptr,
182181
DeclContext *DC = nullptr);
182+
183+
public:
183184
~SILFunction();
184185

185186
SILModule &getModule() const { return Module; }

include/swift/SIL/SILModule.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,23 @@ class SILModule {
443443
SILDeclRef constant,
444444
ForDefinition_t forDefinition);
445445

446+
/// \brief Return the declaration of a function, or create it if it does not
447+
/// exist.
448+
///
449+
/// This signature is a direct copy of the signature of SILFunction::create()
450+
/// in order to simplify refactoring all SILFunction creation use-sites to use
451+
/// SILModule. Eventually the uses should probably be refactored.
452+
SILFunction *getOrCreateFunction(
453+
SILLinkage linkage, StringRef name, CanSILFunctionType loweredType,
454+
GenericParamList *contextGenericParams, Optional<SILLocation> loc,
455+
IsBare_t isBareSILFunction, IsTransparent_t isTrans,
456+
IsFragile_t isFragile, IsThunk_t isThunk = IsNotThunk,
457+
SILFunction::ClassVisibility_t classVisibility = SILFunction::NotRelevant,
458+
Inline_t inlineStrategy = InlineDefault,
459+
EffectsKind EK = EffectsKind::Unspecified,
460+
SILFunction *InsertBefore = nullptr,
461+
const SILDebugScope *DebugScope = nullptr, DeclContext *DC = nullptr);
462+
446463
/// Look up the SILWitnessTable representing the lowering of a protocol
447464
/// conformance, and collect the substitutions to apply to the referenced
448465
/// witnesses, if any.

include/swift/SILAnalysis/ARCAnalysis.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_SILANALYSIS_ARCANALYSIS_H
1414
#define SWIFT_SILANALYSIS_ARCANALYSIS_H
1515

16+
#include "swift/SIL/SILArgument.h"
1617
#include "swift/SIL/SILValue.h"
1718
#include "swift/SIL/SILBasicBlock.h"
1819
#include "llvm/ADT/SmallPtrSet.h"
@@ -102,9 +103,6 @@ valueHasARCDecrementOrCheckInInstructionRange(SILValue Op,
102103
SILBasicBlock::iterator End,
103104
AliasAnalysis *AA);
104105

105-
/// Match a call to a trap BB with no ARC relevant side effects.
106-
bool isARCInertTrapBB(SILBasicBlock *BB);
107-
108106
/// A class that attempts to match owned arguments and corresponding epilogue
109107
/// releases for a specific function.
110108
///

0 commit comments

Comments
 (0)