Skip to content

Commit e2c65fd

Browse files
authored
---
yaml --- r: 349204 b: refs/heads/master-next c: 02b5e56 h: refs/heads/master
1 parent c15129b commit e2c65fd

File tree

97 files changed

+5345
-1100
lines changed

Some content is hidden

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

97 files changed

+5345
-1100
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 8c4df3b4c24f4d6f2ffec16f026fcec0605a5c2a
3+
refs/heads/master-next: 02b5e5632785f06c149850a9754474840bae1d0c
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/AST/ASTTypeIDs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "swift/Basic/TypeID.h"
2222
namespace swift {
2323

24+
class AbstractFunctionDecl;
25+
class BraceStmt;
2426
class CustomAttr;
2527
class Decl;
2628
class GenericParamList;

branches/master-next/include/swift/AST/Decl.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6329,9 +6329,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
63296329

63306330
/// The raw value literal for the enum element, or null.
63316331
LiteralExpr *RawValueExpr;
6332-
/// The type-checked raw value expression.
6333-
Expr *TypeCheckedRawValueExpr = nullptr;
6334-
6332+
63356333
public:
63366334
EnumElementDecl(SourceLoc IdentifierLoc, DeclName Name,
63376335
ParameterList *Params,
@@ -6364,13 +6362,6 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
63646362
bool hasRawValueExpr() const { return RawValueExpr; }
63656363
LiteralExpr *getRawValueExpr() const { return RawValueExpr; }
63666364
void setRawValueExpr(LiteralExpr *e) { RawValueExpr = e; }
6367-
6368-
Expr *getTypeCheckedRawValueExpr() const {
6369-
return TypeCheckedRawValueExpr;
6370-
}
6371-
void setTypeCheckedRawValueExpr(Expr *e) {
6372-
TypeCheckedRawValueExpr = e;
6373-
}
63746365

63756366
/// Return the containing EnumDecl.
63766367
EnumDecl *getParentEnum() const {

branches/master-next/include/swift/AST/DiagnosticEngine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
#ifndef SWIFT_BASIC_DIAGNOSTICENGINE_H
1919
#define SWIFT_BASIC_DIAGNOSTICENGINE_H
2020

21-
#include "swift/AST/Attr.h"
2221
#include "swift/AST/TypeLoc.h"
2322
#include "swift/AST/DeclNameLoc.h"
2423
#include "swift/AST/DiagnosticConsumer.h"
2524
#include "llvm/ADT/StringMap.h"
2625
#include "llvm/Support/Allocator.h"
26+
#include "llvm/Support/VersionTuple.h"
2727

2828
namespace swift {
2929
class Decl;
30+
class DeclAttribute;
3031
class DiagnosticEngine;
3132
class SourceManager;
3233
class ValueDecl;

branches/master-next/include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,8 @@ ERROR(missing_argument_named,none,
11161116
"missing argument for parameter %0 in call", (Identifier))
11171117
ERROR(missing_argument_positional,none,
11181118
"missing argument for parameter #%0 in call", (unsigned))
1119+
ERROR(missing_arguments_in_call,none,
1120+
"missing arguments for parameters %0 in call", (StringRef))
11191121
ERROR(extra_argument_named,none,
11201122
"extra argument %0 in call", (Identifier))
11211123
ERROR(extra_argument_positional,none,
@@ -3493,6 +3495,10 @@ ERROR(single_tuple_parameter_mismatch_normal,none,
34933495
(DescriptiveDeclKind, DeclBaseName, Type, StringRef))
34943496
ERROR(unknown_single_tuple_parameter_mismatch,none,
34953497
"single parameter of type %0 is expected in call", (Type))
3498+
ERROR(cannot_convert_single_tuple_into_multiple_arguments,none,
3499+
"%0 %select{%1 |}2expects %3 separate arguments"
3500+
"%select{|; remove extra parentheses to change tuple into separate arguments}4",
3501+
(DescriptiveDeclKind, DeclName, bool, unsigned, bool))
34963502

34973503
ERROR(enum_element_pattern_assoc_values_mismatch,none,
34983504
"pattern with associated values does not match enum case %0",

branches/master-next/include/swift/AST/Expr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
#include "swift/AST/CaptureInfo.h"
2121
#include "swift/AST/ConcreteDeclRef.h"
22+
#include "swift/AST/DeclContext.h"
2223
#include "swift/AST/DeclNameLoc.h"
2324
#include "swift/AST/FunctionRefKind.h"
2425
#include "swift/AST/ProtocolConformanceRef.h"
2526
#include "swift/AST/TrailingCallArguments.h"
2627
#include "swift/AST/TypeAlignments.h"
2728
#include "swift/AST/TypeLoc.h"
28-
#include "swift/AST/TypeRepr.h"
2929
#include "swift/AST/Availability.h"
3030
#include "swift/Basic/InlineBitfield.h"
3131
#include "llvm/Support/TrailingObjects.h"
@@ -40,7 +40,9 @@ namespace swift {
4040
class ArchetypeType;
4141
class ASTContext;
4242
class AvailabilitySpec;
43+
class IdentTypeRepr;
4344
class Type;
45+
class TypeRepr;
4446
class ValueDecl;
4547
class Decl;
4648
class DeclRefExpr;

branches/master-next/include/swift/Parse/ASTGen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "llvm/ADT/DenseMap.h"
2222

2323
namespace swift {
24+
class ComponentIdentTypeRepr;
25+
class TupleTypeRepr;
26+
2427
/// Generates AST nodes from Syntax nodes.
2528
class Parser;
2629
class ASTGen {

branches/master-next/include/swift/Remote/MetadataReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ class MetadataReader {
794794
baseSize = sizeof(TargetAnonymousContextDescriptor<Runtime>);
795795
if (AnonymousContextDescriptorFlags(flags.getKindSpecificFlags())
796796
.hasMangledName()) {
797-
baseSize += sizeof(TargetMangledContextName<Runtime>);
797+
metadataInitSize = sizeof(TargetMangledContextName<Runtime>);
798798
}
799799
break;
800800
case ContextDescriptorKind::Class:

branches/master-next/include/swift/SIL/OwnershipUtils.h

Lines changed: 98 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,86 @@ bool isOwnershipForwardingInst(SILInstruction *i);
200200

201201
bool isGuaranteedForwardingInst(SILInstruction *i);
202202

203-
struct BorrowScopeIntroducerKind {
203+
struct BorrowScopeOperandKind {
204+
using UnderlyingKindTy = std::underlying_type<SILInstructionKind>::type;
205+
206+
enum Kind : UnderlyingKindTy {
207+
BeginBorrow = UnderlyingKindTy(SILInstructionKind::BeginBorrowInst),
208+
BeginApply = UnderlyingKindTy(SILInstructionKind::BeginApplyInst),
209+
};
210+
211+
Kind value;
212+
213+
BorrowScopeOperandKind(Kind newValue) : value(newValue) {}
214+
BorrowScopeOperandKind(const BorrowScopeOperandKind &other)
215+
: value(other.value) {}
216+
operator Kind() const { return value; }
217+
218+
static Optional<BorrowScopeOperandKind> get(SILInstructionKind kind) {
219+
switch (kind) {
220+
default:
221+
return None;
222+
case SILInstructionKind::BeginBorrowInst:
223+
return BorrowScopeOperandKind(BeginBorrow);
224+
case SILInstructionKind::BeginApplyInst:
225+
return BorrowScopeOperandKind(BeginApply);
226+
}
227+
}
228+
229+
void print(llvm::raw_ostream &os) const;
230+
LLVM_ATTRIBUTE_DEPRECATED(void dump() const, "only for use in the debugger");
231+
};
232+
233+
/// An operand whose user instruction introduces a new borrow scope for the
234+
/// operand's value. The value of the operand must be considered as implicitly
235+
/// borrowed until the user's corresponding end scope instruction.
236+
struct BorrowScopeOperand {
237+
BorrowScopeOperandKind kind;
238+
Operand *op;
239+
240+
BorrowScopeOperand(Operand *op)
241+
: kind(*BorrowScopeOperandKind::get(op->getUser()->getKind())), op(op) {}
242+
243+
/// If value is a borrow introducer return it after doing some checks.
244+
static Optional<BorrowScopeOperand> get(Operand *op) {
245+
auto *user = op->getUser();
246+
auto kind = BorrowScopeOperandKind::get(user->getKind());
247+
if (!kind)
248+
return None;
249+
return BorrowScopeOperand(*kind, op);
250+
}
251+
252+
void visitEndScopeInstructions(function_ref<void(Operand *)> func) const {
253+
switch (kind) {
254+
case BorrowScopeOperandKind::BeginBorrow:
255+
for (auto *use : cast<BeginBorrowInst>(op->getUser())->getUses()) {
256+
if (isa<EndBorrowInst>(use->getUser())) {
257+
func(use);
258+
}
259+
}
260+
return;
261+
case BorrowScopeOperandKind::BeginApply: {
262+
auto *user = cast<BeginApplyInst>(op->getUser());
263+
for (auto *use : user->getTokenResult()->getUses()) {
264+
func(use);
265+
}
266+
return;
267+
}
268+
}
269+
llvm_unreachable("Covered switch isn't covered");
270+
}
271+
272+
private:
273+
/// Internal constructor for failable static constructor. Please do not expand
274+
/// its usage since it assumes the code passed in is well formed.
275+
BorrowScopeOperand(BorrowScopeOperandKind kind, Operand *op)
276+
: kind(kind), op(op) {}
277+
};
278+
279+
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
280+
BorrowScopeOperandKind kind);
281+
282+
struct BorrowScopeIntroducingValueKind {
204283
using UnderlyingKindTy = std::underlying_type<ValueKind>::type;
205284

206285
/// Enum we use for exhaustive pattern matching over borrow scope introducers.
@@ -210,23 +289,23 @@ struct BorrowScopeIntroducerKind {
210289
SILFunctionArgument = UnderlyingKindTy(ValueKind::SILFunctionArgument),
211290
};
212291

213-
static Optional<BorrowScopeIntroducerKind> get(ValueKind kind) {
292+
static Optional<BorrowScopeIntroducingValueKind> get(ValueKind kind) {
214293
switch (kind) {
215294
default:
216295
return None;
217296
case ValueKind::LoadBorrowInst:
218-
return BorrowScopeIntroducerKind(LoadBorrow);
297+
return BorrowScopeIntroducingValueKind(LoadBorrow);
219298
case ValueKind::BeginBorrowInst:
220-
return BorrowScopeIntroducerKind(BeginBorrow);
299+
return BorrowScopeIntroducingValueKind(BeginBorrow);
221300
case ValueKind::SILFunctionArgument:
222-
return BorrowScopeIntroducerKind(SILFunctionArgument);
301+
return BorrowScopeIntroducingValueKind(SILFunctionArgument);
223302
}
224303
}
225304

226305
Kind value;
227306

228-
BorrowScopeIntroducerKind(Kind newValue) : value(newValue) {}
229-
BorrowScopeIntroducerKind(const BorrowScopeIntroducerKind &other)
307+
BorrowScopeIntroducingValueKind(Kind newValue) : value(newValue) {}
308+
BorrowScopeIntroducingValueKind(const BorrowScopeIntroducingValueKind &other)
230309
: value(other.value) {}
231310
operator Kind() const { return value; }
232311

@@ -238,10 +317,10 @@ struct BorrowScopeIntroducerKind {
238317
/// of the scope.
239318
bool isLocalScope() const {
240319
switch (value) {
241-
case BorrowScopeIntroducerKind::BeginBorrow:
242-
case BorrowScopeIntroducerKind::LoadBorrow:
320+
case BorrowScopeIntroducingValueKind::BeginBorrow:
321+
case BorrowScopeIntroducingValueKind::LoadBorrow:
243322
return true;
244-
case BorrowScopeIntroducerKind::SILFunctionArgument:
323+
case BorrowScopeIntroducingValueKind::SILFunctionArgument:
245324
return false;
246325
}
247326
llvm_unreachable("Covered switch isnt covered?!");
@@ -252,7 +331,7 @@ struct BorrowScopeIntroducerKind {
252331
};
253332

254333
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
255-
BorrowScopeIntroducerKind kind);
334+
BorrowScopeIntroducingValueKind kind);
256335

257336
/// A higher level construct for working with values that represent the
258337
/// introduction of a new borrow scope.
@@ -271,26 +350,26 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
271350
/// borrow introducers can not have guaranteed results that are not creating a
272351
/// new borrow scope. No such instructions exist today.
273352
struct BorrowScopeIntroducingValue {
274-
BorrowScopeIntroducerKind kind;
353+
BorrowScopeIntroducingValueKind kind;
275354
SILValue value;
276355

277356
BorrowScopeIntroducingValue(LoadBorrowInst *lbi)
278-
: kind(BorrowScopeIntroducerKind::LoadBorrow), value(lbi) {}
357+
: kind(BorrowScopeIntroducingValueKind::LoadBorrow), value(lbi) {}
279358
BorrowScopeIntroducingValue(BeginBorrowInst *bbi)
280-
: kind(BorrowScopeIntroducerKind::BeginBorrow), value(bbi) {}
359+
: kind(BorrowScopeIntroducingValueKind::BeginBorrow), value(bbi) {}
281360
BorrowScopeIntroducingValue(SILFunctionArgument *arg)
282-
: kind(BorrowScopeIntroducerKind::SILFunctionArgument), value(arg) {
361+
: kind(BorrowScopeIntroducingValueKind::SILFunctionArgument), value(arg) {
283362
assert(arg->getOwnershipKind() == ValueOwnershipKind::Guaranteed);
284363
}
285364

286365
BorrowScopeIntroducingValue(SILValue v)
287-
: kind(*BorrowScopeIntroducerKind::get(v->getKind())), value(v) {
366+
: kind(*BorrowScopeIntroducingValueKind::get(v->getKind())), value(v) {
288367
assert(v.getOwnershipKind() == ValueOwnershipKind::Guaranteed);
289368
}
290369

291370
/// If value is a borrow introducer return it after doing some checks.
292371
static Optional<BorrowScopeIntroducingValue> get(SILValue value) {
293-
auto kind = BorrowScopeIntroducerKind::get(value->getKind());
372+
auto kind = BorrowScopeIntroducingValueKind::get(value->getKind());
294373
if (!kind || value.getOwnershipKind() != ValueOwnershipKind::Guaranteed)
295374
return None;
296375
return BorrowScopeIntroducingValue(*kind, value);
@@ -334,7 +413,8 @@ struct BorrowScopeIntroducingValue {
334413
private:
335414
/// Internal constructor for failable static constructor. Please do not expand
336415
/// its usage since it assumes the code passed in is well formed.
337-
BorrowScopeIntroducingValue(BorrowScopeIntroducerKind kind, SILValue value)
416+
BorrowScopeIntroducingValue(BorrowScopeIntroducingValueKind kind,
417+
SILValue value)
338418
: kind(kind), value(value) {}
339419
};
340420

branches/master-next/include/swift/SIL/Projection.h

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
#ifndef SWIFT_SIL_PROJECTION_H
2323
#define SWIFT_SIL_PROJECTION_H
2424

25+
#include "swift/AST/TypeAlignments.h"
2526
#include "swift/Basic/NullablePtr.h"
2627
#include "swift/Basic/PointerIntEnum.h"
27-
#include "swift/AST/TypeAlignments.h"
28-
#include "swift/SIL/SILValue.h"
28+
#include "swift/Basic/STLExtras.h"
2929
#include "swift/SIL/SILInstruction.h"
30+
#include "swift/SIL/SILValue.h"
3031
#include "swift/SILOptimizer/Analysis/ARCAnalysis.h"
3132
#include "swift/SILOptimizer/Analysis/RCIdentityAnalysis.h"
3233
#include "llvm/ADT/Hashing.h"
@@ -751,15 +752,17 @@ class ProjectionTreeNode {
751752
~ProjectionTreeNode() = default;
752753
ProjectionTreeNode(const ProjectionTreeNode &) = default;
753754

754-
llvm::ArrayRef<unsigned> getChildProjections() {
755-
return llvm::makeArrayRef(ChildProjections);
755+
bool isLeaf() const { return ChildProjections.empty(); }
756+
757+
ArrayRef<unsigned> getChildProjections() const {
758+
return llvm::makeArrayRef(ChildProjections);
756759
}
757760

758-
llvm::Optional<Projection> &getProjection() { return Proj; }
761+
Optional<Projection> &getProjection() { return Proj; }
759762

760-
llvm::SmallVector<Operand *, 4> getNonProjUsers() const {
761-
return NonProjUsers;
762-
};
763+
const ArrayRef<Operand *> getNonProjUsers() const {
764+
return llvm::makeArrayRef(NonProjUsers);
765+
}
763766

764767
SILType getType() const { return NodeType; }
765768

@@ -914,6 +917,24 @@ class ProjectionTree {
914917
return false;
915918
}
916919

920+
void getAllLeafTypes(llvm::SmallVectorImpl<SILType> &outArray) const {
921+
llvm::SmallVector<const ProjectionTreeNode *, 32> worklist;
922+
worklist.push_back(getRoot());
923+
924+
while (!worklist.empty()) {
925+
auto *node = worklist.pop_back_val();
926+
// If we have a leaf node, add its type.
927+
if (node->isLeaf()) {
928+
outArray.push_back(node->getType());
929+
continue;
930+
}
931+
932+
// Otherwise, add the nodes children to the worklist.
933+
transform(node->getChildProjections(), std::back_inserter(worklist),
934+
[&](unsigned idx) { return getNode(idx); });
935+
}
936+
}
937+
917938
void getLiveLeafTypes(llvm::SmallVectorImpl<SILType> &OutArray) const {
918939
for (unsigned LeafIndex : LiveLeafIndices) {
919940
const ProjectionTreeNode *Node = getNode(LeafIndex);
@@ -940,7 +961,9 @@ class ProjectionTree {
940961
void
941962
replaceValueUsesWithLeafUses(SILBuilder &B, SILLocation Loc,
942963
llvm::SmallVectorImpl<SILValue> &Leafs);
943-
964+
965+
void getUsers(SmallPtrSetImpl<SILInstruction *> &users) const;
966+
944967
private:
945968
void createRoot(SILType BaseTy) {
946969
assert(ProjectionTreeNodes.empty() &&

0 commit comments

Comments
 (0)