Skip to content

Commit 70404a4

Browse files
author
Harlan Haskins
committed
---
yaml --- r: 349139 b: refs/heads/master c: bcd6b0f h: refs/heads/master i: 349137: a02a741 349135: ff1c8ae
1 parent 676dfbe commit 70404a4

File tree

72 files changed

+418
-442
lines changed

Some content is hidden

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

72 files changed

+418
-442
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4f4557ceac91a0bfce53036cae10ac8048571db0
2+
refs/heads/master: bcd6b0f2021f1634787977c1f6057afa4404c3ba
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/benchmark/single-source/UTF8Decode.swift

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ public let UTF8Decode = [
4242
name: "UTF8Decode_InitFromBytes_ascii",
4343
runFunction: run_UTF8Decode_InitFromBytes_ascii,
4444
tags: [.validation, .api, .String]),
45-
BenchmarkInfo(
46-
name: "UTF8Decode_InitFromData_ascii_as_ascii",
47-
runFunction: run_UTF8Decode_InitFromData_ascii_as_ascii,
48-
tags: [.validation, .api, .String]),
49-
BenchmarkInfo(
50-
name: "UTF8Decode_InitDecoding_ascii_as_ascii",
51-
runFunction: run_UTF8Decode_InitDecoding_ascii_as_ascii,
52-
tags: [.validation, .api, .String]),
53-
BenchmarkInfo(
54-
name: "UTF8Decode_InitFromBytes_ascii_as_ascii",
55-
runFunction: run_UTF8Decode_InitFromBytes_ascii_as_ascii,
56-
tags: [.validation, .api, .String]),
5745
]
5846

5947
// 1-byte sequences
@@ -141,26 +129,4 @@ public func run_UTF8Decode_InitFromBytes_ascii(_ N: Int) {
141129
}
142130
}
143131

144-
@inline(never)
145-
public func run_UTF8Decode_InitFromData_ascii_as_ascii(_ N: Int) {
146-
let input = asciiData
147-
for _ in 0..<1_000*N {
148-
blackHole(String(data: input, encoding: .ascii))
149-
}
150-
}
151-
@inline(never)
152-
public func run_UTF8Decode_InitDecoding_ascii_as_ascii(_ N: Int) {
153-
let input = asciiBytes
154-
for _ in 0..<1_000*N {
155-
blackHole(String(decoding: input, as: Unicode.ASCII.self))
156-
}
157-
}
158-
@inline(never)
159-
public func run_UTF8Decode_InitFromBytes_ascii_as_ascii(_ N: Int) {
160-
let input = asciiBytes
161-
for _ in 0..<1_000*N {
162-
blackHole(String(bytes: input, encoding: .ascii))
163-
}
164-
}
165-
166132

trunk/include/swift/AST/Decl.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ namespace swift {
7171
class GenericTypeParamDecl;
7272
class GenericTypeParamType;
7373
class ModuleDecl;
74-
class NamedPattern;
7574
class EnumCaseDecl;
7675
class EnumElementDecl;
7776
class ParameterList;
@@ -4774,8 +4773,6 @@ enum class PropertyWrapperSynthesizedPropertyKind {
47744773

47754774
/// VarDecl - 'var' and 'let' declarations.
47764775
class VarDecl : public AbstractStorageDecl {
4777-
NamedPattern *NamingPattern = nullptr;
4778-
47794776
public:
47804777
enum class Introducer : uint8_t {
47814778
Let = 0,
@@ -4789,6 +4786,10 @@ class VarDecl : public AbstractStorageDecl {
47894786
bool issCaptureList, SourceLoc nameLoc, Identifier name,
47904787
DeclContext *dc, StorageIsMutable_t supportsMutation);
47914788

4789+
TypeRepr *ParentRepr = nullptr;
4790+
4791+
Type typeInContext;
4792+
47924793
public:
47934794
VarDecl(bool isStatic, Introducer introducer, bool isCaptureList,
47944795
SourceLoc nameLoc, Identifier name, DeclContext *dc)
@@ -4805,10 +4806,26 @@ class VarDecl : public AbstractStorageDecl {
48054806
return hasName() ? getBaseName().getIdentifier().str() : "_";
48064807
}
48074808

4809+
/// Retrieve the TypeRepr corresponding to the parsed type of the parent
4810+
/// pattern, if it exists.
4811+
TypeRepr *getTypeRepr() const { return ParentRepr; }
4812+
void setTypeRepr(TypeRepr *repr) { ParentRepr = repr; }
4813+
4814+
bool hasType() const {
4815+
// We have a type if either the type has been computed already or if
4816+
// this is a deserialized declaration with an interface type.
4817+
return !typeInContext.isNull();
4818+
}
4819+
48084820
/// Get the type of the variable within its context. If the context is generic,
48094821
/// this will use archetypes.
48104822
Type getType() const;
48114823

4824+
/// Set the type of the variable within its context.
4825+
void setType(Type t);
4826+
4827+
void markInvalid();
4828+
48124829
/// Retrieve the source range of the variable type, or an invalid range if the
48134830
/// variable's type is not explicitly written in the source.
48144831
///
@@ -4847,14 +4864,6 @@ class VarDecl : public AbstractStorageDecl {
48474864
///
48484865
Pattern *getParentPattern() const;
48494866

4850-
/// Returns the parsed type of this variable declaration. For parameters, this
4851-
/// is the parsed type the user explicitly wrote. For variables, this is the
4852-
/// type the user wrote in the typed pattern that binds this variable.
4853-
///
4854-
/// Note that there are many cases where the user may elide types. This will
4855-
/// return null in those cases.
4856-
TypeRepr *getTypeReprOrParentPatternTypeRepr() const;
4857-
48584867
/// Return the statement that owns the pattern associated with this VarDecl,
48594868
/// if one exists.
48604869
///
@@ -4895,9 +4904,6 @@ class VarDecl : public AbstractStorageDecl {
48954904
Parent = v;
48964905
}
48974906

4898-
NamedPattern *getNamingPattern() const { return NamingPattern; }
4899-
void setNamingPattern(NamedPattern *Pat) { NamingPattern = Pat; }
4900-
49014907
/// If this is a VarDecl that does not belong to a CaseLabelItem's pattern,
49024908
/// return this. Otherwise, this VarDecl must belong to a CaseStmt's
49034909
/// CaseLabelItem. In that case, return the first case label item of the first
@@ -5152,8 +5158,6 @@ class ParamDecl : public VarDecl {
51525158
SourceLoc ArgumentNameLoc;
51535159
SourceLoc SpecifierLoc;
51545160

5155-
TypeRepr *TyRepr = nullptr;
5156-
51575161
struct StoredDefaultArgument {
51585162
PointerUnion<Expr *, VarDecl *> DefaultArg;
51595163
Initializer *InitContext = nullptr;
@@ -5199,10 +5203,6 @@ class ParamDecl : public VarDecl {
51995203

52005204
SourceLoc getSpecifierLoc() const { return SpecifierLoc; }
52015205

5202-
/// Retrieve the TypeRepr corresponding to the parsed type of the parameter, if it exists.
5203-
TypeRepr *getTypeRepr() const { return TyRepr; }
5204-
void setTypeRepr(TypeRepr *repr) { TyRepr = repr; }
5205-
52065206
DefaultArgumentKind getDefaultArgumentKind() const {
52075207
return static_cast<DefaultArgumentKind>(Bits.ParamDecl.defaultArgumentKind);
52085208
}

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,6 @@ ERROR(pattern_binds_no_variables,none,
15091509
"%select{property|global variable}0 declaration does not bind any "
15101510
"variables",
15111511
(unsigned))
1512-
ERROR(variable_bound_by_no_pattern,none,
1513-
"variable %0 is not bound by any pattern",
1514-
(DeclName))
15151512

15161513
WARNING(optional_ambiguous_case_ref,none,
15171514
"assuming you mean '%0.%2'; did you mean '%1.%2' instead?",

trunk/include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ namespace swift {
202202
/// before termination of the shrink phrase of the constraint solver.
203203
unsigned SolverShrinkUnsolvedThreshold = 10;
204204

205+
/// Enable one-way constraints in function builders.
206+
bool FunctionBuilderOneWayConstraints = true;
207+
205208
/// Disable the shrink phase of the expression type checker.
206209
bool SolverDisableShrink = false;
207210

trunk/include/swift/Option/FrontendOptions.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,14 @@ def Rmodule_interface_rebuild : Flag<["-"], "Rmodule-interface-rebuild">,
414414

415415
def solver_expression_time_threshold_EQ : Joined<["-"], "solver-expression-time-threshold=">;
416416

417+
def enable_function_builder_one_way_constraints : Flag<["-"],
418+
"enable-function-builder-one-way-constraints">,
419+
HelpText<"Enable one-way constraints in the function builder transformation">;
420+
421+
def disable_function_builder_one_way_constraints : Flag<["-"],
422+
"disable-function-builder-one-way-constraints">,
423+
HelpText<"Disable one-way constraints in the function builder transformation">;
424+
417425
def solver_disable_shrink :
418426
Flag<["-"], "solver-disable-shrink">,
419427
HelpText<"Disable the shrink phase of expression type checking">;

trunk/include/swift/SIL/SILDeclRef.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ struct SILDeclRef {
249249
bool isStoredPropertyInitializer() const {
250250
return kind == Kind::StoredPropertyInitializer;
251251
}
252-
/// True if the SILDeclRef references the initializer for the backing storage
253-
/// of a property wrapper.
254-
bool isPropertyWrapperBackingInitializer() const {
255-
return kind == Kind::PropertyWrapperBackingInitializer;
256-
}
257252

258253
/// True if the SILDeclRef references the ivar initializer or deinitializer of
259254
/// a class.

trunk/include/swift/SILOptimizer/Analysis/EscapeAnalysis.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,6 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
411411
return false;
412412
return true;
413413
}
414-
415-
/// Returns true if the node has any predecessors with link to this node
416-
/// with a defer-edge.
417-
bool hasDeferPredecessors() const {
418-
for (Predecessor Pred : Preds) {
419-
if (Pred.getInt() == EdgeType::Defer)
420-
return true;
421-
}
422-
return false;
423-
}
424414

425415
friend class CGNodeMap;
426416
friend class ConnectionGraph;
@@ -641,7 +631,19 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
641631
}
642632

643633
/// Adds an argument/instruction in which the node's value is used.
644-
int addUsePoint(CGNode *Node, SILNode *User);
634+
int addUsePoint(CGNode *Node, SILNode *User) {
635+
if (Node->getEscapeState() >= EscapeState::Global)
636+
return -1;
637+
638+
User = User->getRepresentativeSILNodeInObject();
639+
int Idx = (int)UsePoints.size();
640+
assert(UsePoints.count(User) == 0 && "value is already a use-point");
641+
UsePoints[User] = Idx;
642+
UsePointTable.push_back(User);
643+
assert(UsePoints.size() == UsePointTable.size());
644+
Node->setUsePointBit(Idx);
645+
return Idx;
646+
}
645647

646648
/// Specifies that the node's value escapes to global or unidentified
647649
/// memory.

trunk/lib/AST/ASTDumper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ namespace {
725725

726726
if (auto *var = dyn_cast<VarDecl>(VD)) {
727727
PrintWithColorRAII(OS, TypeColor) << " type='";
728-
if (auto varTy = var->hasInterfaceType())
728+
if (var->hasType())
729729
var->getType().print(PrintWithColorRAII(OS, TypeColor).getOS());
730730
else
731731
PrintWithColorRAII(OS, TypeColor) << "<null type>";
@@ -954,11 +954,13 @@ namespace {
954954
PrintWithColorRAII(OS, IdentifierColor)
955955
<< " apiName=" << P->getArgumentName();
956956

957-
if (P->hasInterfaceType()) {
957+
if (P->hasType()) {
958958
PrintWithColorRAII(OS, TypeColor) << " type='";
959959
P->getType().print(PrintWithColorRAII(OS, TypeColor).getOS());
960960
PrintWithColorRAII(OS, TypeColor) << "'";
961+
}
961962

963+
if (P->hasInterfaceType()) {
962964
PrintWithColorRAII(OS, InterfaceTypeColor) << " interface type='";
963965
P->getInterfaceType().print(
964966
PrintWithColorRAII(OS, InterfaceTypeColor).getOS());

trunk/lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
25242524
if (decl->hasInterfaceType()) {
25252525
Printer << ": ";
25262526
TypeLoc tyLoc;
2527-
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr())
2527+
if (auto *repr = decl->getTypeRepr())
25282528
tyLoc = TypeLoc(repr, decl->getInterfaceType());
25292529
else
25302530
tyLoc = TypeLoc::withoutLoc(decl->getInterfaceType());

trunk/lib/AST/Decl.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,7 @@ OpaqueReturnTypeRepr *ValueDecl::getOpaqueResultTypeRepr() const {
25952595
}
25962596
}
25972597
} else {
2598-
returnRepr = VD->getTypeReprOrParentPatternTypeRepr();
2598+
returnRepr = VD->getTypeRepr();
25992599
}
26002600
} else if (auto *FD = dyn_cast<FuncDecl>(this)) {
26012601
returnRepr = FD->getBodyResultTypeLoc().getTypeRepr();
@@ -5007,7 +5007,24 @@ VarDecl::VarDecl(DeclKind kind, bool isStatic, VarDecl::Introducer introducer,
50075007
}
50085008

50095009
Type VarDecl::getType() const {
5010-
return getDeclContext()->mapTypeIntoContext(getInterfaceType());
5010+
if (!typeInContext) {
5011+
const_cast<VarDecl *>(this)->typeInContext =
5012+
getDeclContext()->mapTypeIntoContext(
5013+
getInterfaceType());
5014+
}
5015+
5016+
return typeInContext;
5017+
}
5018+
5019+
void VarDecl::setType(Type t) {
5020+
assert(t.isNull() || !t->is<InOutType>());
5021+
typeInContext = t;
5022+
}
5023+
5024+
void VarDecl::markInvalid() {
5025+
auto &Ctx = getASTContext();
5026+
setType(ErrorType::get(Ctx));
5027+
setInterfaceType(ErrorType::get(Ctx));
50115028
}
50125029

50135030
/// Returns whether the var is settable in the specified context: this
@@ -5252,6 +5269,9 @@ Pattern *VarDecl::getParentPattern() const {
52525269
if (pat->containsVarDecl(this))
52535270
return pat;
52545271
}
5272+
5273+
//stmt->dump();
5274+
assert(0 && "Unknown parent pattern statement?");
52555275
}
52565276

52575277
// Otherwise, check if we have to walk our case stmt's var decl list to find
@@ -5265,16 +5285,6 @@ Pattern *VarDecl::getParentPattern() const {
52655285
return nullptr;
52665286
}
52675287

5268-
TypeRepr *VarDecl::getTypeReprOrParentPatternTypeRepr() const {
5269-
if (auto *param = dyn_cast<ParamDecl>(this))
5270-
return param->getTypeRepr();
5271-
5272-
if (auto *parentPattern = dyn_cast_or_null<TypedPattern>(getParentPattern()))
5273-
return parentPattern->getTypeRepr();
5274-
5275-
return nullptr;
5276-
}
5277-
52785288
NullablePtr<VarDecl>
52795289
VarDecl::getCorrespondingFirstCaseLabelItemVarDecl() const {
52805290
if (!hasName())

trunk/lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,7 @@ applyPropertyOwnership(VarDecl *prop,
21102110
if (attrs & clang::ObjCPropertyDecl::OBJC_PR_weak) {
21112111
prop->getAttrs().add(new (ctx)
21122112
ReferenceOwnershipAttr(ReferenceOwnership::Weak));
2113+
prop->setType(WeakStorageType::get(prop->getType(), ctx));
21132114
prop->setInterfaceType(WeakStorageType::get(
21142115
prop->getInterfaceType(), ctx));
21152116
return;
@@ -2118,6 +2119,7 @@ applyPropertyOwnership(VarDecl *prop,
21182119
(attrs & clang::ObjCPropertyDecl::OBJC_PR_unsafe_unretained)) {
21192120
prop->getAttrs().add(
21202121
new (ctx) ReferenceOwnershipAttr(ReferenceOwnership::Unmanaged));
2122+
prop->setType(UnmanagedStorageType::get(prop->getType(), ctx));
21212123
prop->setInterfaceType(UnmanagedStorageType::get(
21222124
prop->getInterfaceType(), ctx));
21232125
return;

trunk/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
443443

444444
if (Args.getLastArg(OPT_solver_disable_shrink))
445445
Opts.SolverDisableShrink = true;
446+
Opts.FunctionBuilderOneWayConstraints =
447+
Args.hasFlag(OPT_enable_function_builder_one_way_constraints,
448+
OPT_disable_function_builder_one_way_constraints,
449+
/*Default=*/true);
446450

447451
if (const Arg *A = Args.getLastArg(OPT_value_recursion_threshold)) {
448452
unsigned threshold;

0 commit comments

Comments
 (0)