Skip to content

Commit 3383392

Browse files
authored
---
yaml --- r: 348953 b: refs/heads/master c: efa3139 h: refs/heads/master i: 348951: f7f6582
1 parent 7a4cb52 commit 3383392

File tree

25 files changed

+338
-181
lines changed

25 files changed

+338
-181
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: c9f9350e74e2aef13f95e6c35b62abb960f8963f
2+
refs/heads/master: efa3139f84cd2584344ea37f4c183467a511404e
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/cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ function(_compile_swift_files
333333
"-emit-module-interface-path" "${interface_file}")
334334
endif()
335335

336+
if (NOT SWIFTFILE_IS_STDLIB_CORE)
337+
list(APPEND swift_module_flags
338+
"-Xfrontend" "-experimental-skip-non-inlinable-function-bodies")
339+
endif()
340+
336341
# If we have extra regexp flags, check if we match any of the regexps. If so
337342
# add the relevant flags to our swift_flags.
338343
if (SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS OR SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS)

trunk/include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ ERROR(expected_expr_throw,PointsToFirstBadToken,
970970
// Yield Statment
971971
ERROR(expected_expr_yield,PointsToFirstBadToken,
972972
"expected expression in 'yield' statement", ())
973+
ERROR(unexpected_arg_label_yield,none,
974+
"unexpected argument label in 'yield' statement", ())
973975

974976
// Defer Statement
975977
ERROR(expected_lbrace_after_defer,PointsToFirstBadToken,

trunk/include/swift/Parse/ASTGen.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ASTGen {
8787
Expr *generate(const syntax::SuperRefExprSyntax &Expr, const SourceLoc Loc);
8888
Expr *generate(const syntax::ArrayExprSyntax &Expr, const SourceLoc Loc);
8989
Expr *generate(const syntax::DictionaryExprSyntax &Expr, const SourceLoc Loc);
90+
Expr *generate(const syntax::TupleExprSyntax &E, const SourceLoc Loc);
9091
Expr *generate(const syntax::EditorPlaceholderExprSyntax &Expr,
9192
const SourceLoc Loc);
9293
Expr *generate(const syntax::SpecializeExprSyntax &Expr, const SourceLoc Loc);
@@ -112,6 +113,12 @@ class ASTGen {
112113
const Optional<syntax::DeclNameArgumentsSyntax> &args,
113114
const SourceLoc Loc);
114115

116+
void generateExprTupleElementList(const syntax::TupleExprElementListSyntax &elements,
117+
const SourceLoc Loc, bool isForCallArguments,
118+
SmallVectorImpl<Expr *> &exprs,
119+
SmallVectorImpl<Identifier> &exprLabels,
120+
SmallVectorImpl<SourceLoc> &exprLabelLocs);
121+
115122
private:
116123
void validateCollectionElement(Expr *elementExpr);
117124

trunk/include/swift/Parse/Parser.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,11 @@ class Parser {
15581558
SourceLoc &inLoc);
15591559

15601560
Expr *parseExprAnonClosureArg();
1561-
ParserResult<Expr> parseExprList(tok LeftTok, tok RightTok,
1562-
syntax::SyntaxKind Kind);
1561+
ParserResult<Expr> parseExprParenOrTuple();
1562+
ParsedSyntaxResult<ParsedExprSyntax> parseExprTupleSyntax();
1563+
ParserStatus parseExprTupleElementListSyntax(
1564+
SmallVectorImpl<ParsedTupleExprElementSyntax> &elements,
1565+
llvm::function_ref<bool()> isAtCloseTok);
15631566

15641567
/// Parse an expression list, keeping all of the pieces separated.
15651568
ParserStatus parseExprList(tok leftTok, tok rightTok,
@@ -1570,8 +1573,7 @@ class Parser {
15701573
SmallVectorImpl<Identifier> &exprLabels,
15711574
SmallVectorImpl<SourceLoc> &exprLabelLocs,
15721575
SourceLoc &rightLoc,
1573-
Expr *&trailingClosure,
1574-
syntax::SyntaxKind Kind);
1576+
Expr *&trailingClosure);
15751577

15761578
ParserResult<Expr> parseTrailingClosure(SourceRange calleeRange);
15771579

trunk/lib/IRGen/LoadableByAddress.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,20 @@ static void convertBBArgType(SILBuilder &argBuilder, SILType newSILType,
14261426
}
14271427
}
14281428

1429+
static bool containsFunctionType(CanType ty) {
1430+
if (auto tuple = dyn_cast<TupleType>(ty)) {
1431+
for (auto elt : tuple.getElementTypes()) {
1432+
if (containsFunctionType(elt))
1433+
return true;
1434+
}
1435+
return false;
1436+
}
1437+
if (auto optionalType = ty.getOptionalObjectType()) {
1438+
return containsFunctionType(optionalType);
1439+
}
1440+
return isa<SILFunctionType>(ty);
1441+
}
1442+
14291443
void LoadableStorageAllocation::convertApplyResults() {
14301444
for (auto &BB : *pass.F) {
14311445
for (auto &II : BB) {
@@ -1450,16 +1464,7 @@ void LoadableStorageAllocation::convertApplyResults() {
14501464
auto numFuncTy = llvm::count_if(origSILFunctionType->getResults(),
14511465
[](const SILResultInfo &origResult) {
14521466
auto resultStorageTy = origResult.getSILStorageType();
1453-
// Check if it is a function type
1454-
if (resultStorageTy.is<SILFunctionType>()) {
1455-
return true;
1456-
}
1457-
// Check if it is an optional function type
1458-
auto optionalType = resultStorageTy.getOptionalObjectType();
1459-
if (optionalType && optionalType.is<SILFunctionType>()) {
1460-
return true;
1461-
}
1462-
return false;
1467+
return containsFunctionType(resultStorageTy.getASTType());
14631468
});
14641469
assert(numFuncTy != 0 &&
14651470
"Expected a SILFunctionType inside the result Type");

trunk/lib/Parse/ASTGen.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ Expr *ASTGen::generate(const ExprSyntax &E, const SourceLoc Loc) {
248248
result = generate(*arrayExpr, Loc);
249249
else if (auto dictionaryExpr = E.getAs<DictionaryExprSyntax>())
250250
result = generate(*dictionaryExpr, Loc);
251+
else if (auto tupleExpr = E.getAs<TupleExprSyntax>())
252+
result = generate(*tupleExpr, Loc);
251253
else if (auto integerLiteralExpr = E.getAs<IntegerLiteralExprSyntax>())
252254
result = generate(*integerLiteralExpr, Loc);
253255
else if (auto floatLiteralExpr = E.getAs<FloatLiteralExprSyntax>())
@@ -526,6 +528,72 @@ Expr *ASTGen::generate(const DictionaryExprSyntax &E, const SourceLoc Loc) {
526528
RSquareLoc);
527529
}
528530

531+
Expr *ASTGen::generate(const TupleExprSyntax &E, const SourceLoc Loc) {
532+
SmallVector<Expr *, 2> exprs;
533+
SmallVector<Identifier, 2> exprLabels;
534+
SmallVector<SourceLoc, 2> exprLabelLocs;
535+
generateExprTupleElementList(E.getElementList(), Loc,
536+
/*isForCallArguments=*/false, exprs, exprLabels,
537+
exprLabelLocs);
538+
539+
SourceLoc leftLoc = advanceLocBegin(Loc, E.getLeftParen());
540+
SourceLoc rightLoc = advanceLocEnd(Loc, E);
541+
542+
// A tuple with a single, unlabeled element is just parentheses.
543+
if (exprs.size() == 1 && exprLabels.empty()) {
544+
return new (Context) ParenExpr(leftLoc, exprs[0], rightLoc,
545+
/*hasTrailingClosure=*/false);
546+
}
547+
548+
return TupleExpr::create(Context, leftLoc, exprs, exprLabels, exprLabelLocs,
549+
rightLoc, /*HasTrailingClosure=*/false,
550+
/*Implicit=*/false);
551+
}
552+
553+
void ASTGen::generateExprTupleElementList(const TupleExprElementListSyntax &elements,
554+
const SourceLoc Loc, bool isForCallArguments,
555+
SmallVectorImpl<Expr *> &exprs,
556+
SmallVectorImpl<Identifier> &exprLabels,
557+
SmallVectorImpl<SourceLoc> &exprLabelLocs) {
558+
auto isFirst = true;
559+
for (auto elem : elements) {
560+
auto *subExpr = generate(elem.getExpression(), Loc);
561+
if (!subExpr)
562+
continue;
563+
564+
// Handle call arguments specially because it may need argument labels.
565+
if (P.CodeCompletion && isForCallArguments && !elem.getLabel())
566+
if (auto CCExpr = elem.getExpression().getAs<CodeCompletionExprSyntax>())
567+
if (!CCExpr->getBase() && !CCExpr->getPeriodOrParen())
568+
P.CodeCompletion->completeCallArg(cast<CodeCompletionExpr>(subExpr),
569+
isFirst);
570+
isFirst = false;
571+
572+
Identifier fieldName;
573+
SourceLoc fieldNameLoc;
574+
if (auto label = elem.getLabel()) {
575+
fieldNameLoc = advanceLocBegin(Loc, *label);
576+
if (label->getTokenKind() == tok::identifier)
577+
fieldName = Context.getIdentifier(label->getIdentifierText());
578+
}
579+
580+
// Don't populate label vectors unless we see at least one label.
581+
if (!exprLabels.empty()) {
582+
exprLabels.push_back(fieldName);
583+
exprLabelLocs.push_back(fieldNameLoc);
584+
} else if (fieldNameLoc.isValid()) {
585+
exprLabels.resize(exprs.size());
586+
exprLabelLocs.resize(exprs.size());
587+
exprLabels.push_back(fieldName);
588+
exprLabelLocs.push_back(fieldNameLoc);
589+
}
590+
exprs.push_back(subExpr);
591+
}
592+
assert((exprLabels.size() == 0 || exprs.size() == exprLabels.size()) &&
593+
exprLabels.size() == exprLabelLocs.size());
594+
}
595+
596+
529597
Expr *ASTGen::generate(const IntegerLiteralExprSyntax &Expr,
530598
const SourceLoc Loc) {
531599
auto Digits = Expr.getDigits();

trunk/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,8 +1784,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc At
17841784
status |= parseExprList(tok::l_paren, tok::r_paren,
17851785
/*isPostfix=*/false, /*isExprBasic=*/true,
17861786
lParenLoc, args, argLabels, argLabelLocs,
1787-
rParenLoc, trailingClosure,
1788-
SyntaxKind::TupleExprElementList);
1787+
rParenLoc, trailingClosure);
17891788
assert(!trailingClosure && "Cannot parse a trailing closure here");
17901789
hasInitializer = true;
17911790
}

0 commit comments

Comments
 (0)