Skip to content

Commit 3b470ef

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 71c6237 + fcf95ea commit 3b470ef

File tree

74 files changed

+4370
-1160
lines changed

Some content is hidden

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

74 files changed

+4370
-1160
lines changed

include/swift/AST/Expr.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,14 @@ class alignas(8) Expr {
566566
/// typically this will have an ErrorType.
567567
class ErrorExpr : public Expr {
568568
SourceRange Range;
569+
Expr *OriginalExpr;
569570
public:
570-
ErrorExpr(SourceRange Range, Type Ty = Type())
571-
: Expr(ExprKind::Error, /*Implicit=*/true, Ty), Range(Range) {}
571+
ErrorExpr(SourceRange Range, Type Ty = Type(), Expr *OriginalExpr = nullptr)
572+
: Expr(ExprKind::Error, /*Implicit=*/true, Ty), Range(Range),
573+
OriginalExpr(OriginalExpr) {}
572574

573575
SourceRange getSourceRange() const { return Range; }
576+
Expr *getOriginalExpr() const { return OriginalExpr; }
574577

575578
static bool classof(const Expr *E) {
576579
return E->getKind() == ExprKind::Error;

include/swift/AST/Module.h

+12
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ModuleDecl : public DeclContext, public TypeDecl {
310310
/// Add a file declaring a cross-import overlay.
311311
void addCrossImportOverlayFile(StringRef file);
312312

313+
/// If this method returns \c false, the module does not declare any
314+
/// cross-import overlays.
315+
///
316+
/// This is a quick check you can use to bail out of expensive logic early;
317+
/// however, a \c true return doesn't guarantee that the module declares
318+
/// cross-import overlays--it only means that it \em might declare some.
319+
///
320+
/// (Specifically, this method checks if the module loader found any
321+
/// swiftoverlay files, but does not load the files to see if they list any
322+
/// overlay modules.)
323+
bool mightDeclareCrossImportOverlays() const;
324+
313325
/// Append to \p overlayNames the names of all modules that this module
314326
/// declares should be imported when \p bystanderName is imported.
315327
///

include/swift/AST/Stmt.h

+19-8
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ class alignas(8) PoundAvailableInfo final :
321321
friend TrailingObjects;
322322

323323
SourceLoc PoundLoc;
324+
SourceLoc LParenLoc;
324325
SourceLoc RParenLoc;
325326

326327
// The number of queries tail allocated after this object.
@@ -338,17 +339,18 @@ class alignas(8) PoundAvailableInfo final :
338339
/// This is filled in by Sema.
339340
VersionRange VariantAvailableRange;
340341

341-
PoundAvailableInfo(SourceLoc PoundLoc, ArrayRef<AvailabilitySpec *> queries,
342-
SourceLoc RParenLoc)
343-
: PoundLoc(PoundLoc), RParenLoc(RParenLoc), NumQueries(queries.size()),
344-
AvailableRange(VersionRange::empty()),
342+
PoundAvailableInfo(SourceLoc PoundLoc, SourceLoc LParenLoc,
343+
ArrayRef<AvailabilitySpec *> queries, SourceLoc RParenLoc)
344+
: PoundLoc(PoundLoc), LParenLoc(LParenLoc), RParenLoc(RParenLoc),
345+
NumQueries(queries.size()), AvailableRange(VersionRange::empty()),
345346
VariantAvailableRange(VersionRange::empty()) {
346347
std::uninitialized_copy(queries.begin(), queries.end(),
347348
getTrailingObjects<AvailabilitySpec *>());
348349
}
349350

350351
public:
351352
static PoundAvailableInfo *create(ASTContext &ctx, SourceLoc PoundLoc,
353+
SourceLoc LParenLoc,
352354
ArrayRef<AvailabilitySpec *> queries,
353355
SourceLoc RParenLoc);
354356

@@ -357,6 +359,9 @@ class alignas(8) PoundAvailableInfo final :
357359
NumQueries);
358360
}
359361

362+
SourceLoc getLParenLoc() const { return LParenLoc; }
363+
SourceLoc getRParenLoc() const { return RParenLoc; }
364+
360365
SourceLoc getStartLoc() const { return PoundLoc; }
361366
SourceLoc getEndLoc() const;
362367
SourceLoc getLoc() const { return PoundLoc; }
@@ -771,6 +776,7 @@ class WhileStmt : public LabeledConditionalStmt {
771776

772777
SourceLoc getStartLoc() const { return getLabelLocOrKeywordLoc(WhileLoc); }
773778
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
779+
SourceLoc getWhileLoc() const { return WhileLoc; }
774780

775781
Stmt *getBody() const { return Body; }
776782
void setBody(Stmt *s) { Body = s; }
@@ -792,9 +798,10 @@ class RepeatWhileStmt : public LabeledStmt {
792798
getDefaultImplicitFlag(implicit, RepeatLoc),
793799
LabelInfo),
794800
RepeatLoc(RepeatLoc), WhileLoc(WhileLoc), Body(Body), Cond(Cond) {}
795-
801+
796802
SourceLoc getStartLoc() const { return getLabelLocOrKeywordLoc(RepeatLoc); }
797803
SourceLoc getEndLoc() const;
804+
SourceLoc getRepeatLoc() const { return RepeatLoc; }
798805

799806
Stmt *getBody() const { return Body; }
800807
void setBody(Stmt *s) { Body = s; }
@@ -819,6 +826,7 @@ class ForEachStmt : public LabeledStmt {
819826
Pattern *Pat;
820827
SourceLoc InLoc;
821828
Expr *Sequence;
829+
SourceLoc WhereLoc;
822830
Expr *WhereExpr = nullptr;
823831
BraceStmt *Body;
824832

@@ -831,12 +839,12 @@ class ForEachStmt : public LabeledStmt {
831839

832840
public:
833841
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, Pattern *Pat,
834-
SourceLoc InLoc, Expr *Sequence, Expr *WhereExpr, BraceStmt *Body,
835-
Optional<bool> implicit = None)
842+
SourceLoc InLoc, Expr *Sequence, SourceLoc WhereLoc,
843+
Expr *WhereExpr, BraceStmt *Body, Optional<bool> implicit = None)
836844
: LabeledStmt(StmtKind::ForEach, getDefaultImplicitFlag(implicit, ForLoc),
837845
LabelInfo),
838846
ForLoc(ForLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
839-
WhereExpr(WhereExpr), Body(Body) {
847+
WhereLoc(WhereLoc), WhereExpr(WhereExpr), Body(Body) {
840848
setPattern(Pat);
841849
}
842850

@@ -864,6 +872,9 @@ class ForEachStmt : public LabeledStmt {
864872

865873
/// getInLoc - Retrieve the location of the 'in' keyword.
866874
SourceLoc getInLoc() const { return InLoc; }
875+
876+
/// getWhereLoc - Retrieve the location of the 'where' keyword.
877+
SourceLoc getWhereLoc() const { return WhereLoc; }
867878

868879
/// getPattern - Retrieve the pattern describing the iteration variables.
869880
/// These variables will only be visible within the body of the loop.

include/swift/Markup/Markup.h

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MarkupContext final {
6060
LineList getLineList(swift::RawComment RC);
6161
};
6262

63+
Document *parseDocument(MarkupContext &MC, StringRef String);
6364
Document *parseDocument(MarkupContext &MC, LineList &LL);
6465

6566
} // namespace markup

include/swift/SIL/SILConstants.h

+2
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,8 @@ struct SymbolicClosure final
733733
SILType getClosureType() { return closureInst->getType(); }
734734

735735
SubstitutionMap getCallSubstitutionMap() { return substitutionMap; }
736+
737+
bool hasOnlyConstantCaptures() { return !hasNonConstantCaptures; }
736738
};
737739

738740
} // end namespace swift

lib/AST/ASTWalker.cpp

+25-16
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,31 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
327327
return false;
328328
}
329329

330+
bool visitParamDecl(ParamDecl *P) {
331+
// Don't walk into the type if the decl is implicit, or if the type is
332+
// implicit.
333+
if (!P->isImplicit()) {
334+
if (auto *repr = P->getTypeRepr()) {
335+
if (doIt(repr)) {
336+
return true;
337+
}
338+
}
339+
}
340+
if (auto *E = P->getStructuralDefaultExpr()) {
341+
auto res = doIt(E);
342+
if (!res) return true;
343+
P->setDefaultExpr(res, /*isTypeChecked*/ (bool)res->getType());
344+
}
345+
346+
if (!Walker.shouldWalkAccessorsTheOldWay()) {
347+
for (auto *AD : P->getAllAccessors())
348+
if (doIt(AD))
349+
return true;
350+
}
351+
352+
return false;
353+
}
354+
330355
bool visitSubscriptDecl(SubscriptDecl *SD) {
331356
bool WalkGenerics = visitGenericParamListIfNeeded(SD);
332357

@@ -1142,22 +1167,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
11421167
// Walk each parameter's decl and typeloc and default value.
11431168
if (doIt(P))
11441169
return true;
1145-
1146-
// Don't walk into the type if the decl is implicit, or if the type is
1147-
// implicit.
1148-
if (!P->isImplicit()) {
1149-
if (auto *repr = P->getTypeRepr()) {
1150-
if (doIt(repr)) {
1151-
return true;
1152-
}
1153-
}
1154-
}
1155-
1156-
if (auto *E = P->getStructuralDefaultExpr()) {
1157-
auto res = doIt(E);
1158-
if (!res) return true;
1159-
P->setDefaultExpr(res, /*isTypeChecked*/ (bool)res->getType());
1160-
}
11611170
}
11621171

11631172
return Walker.walkToParameterListPost(PL);

lib/AST/Module.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,10 @@ void ModuleDecl::addCrossImportOverlayFile(StringRef file) {
15641564
.push_back(new (ctx) OverlayFile(ctx.AllocateCopy(file)));
15651565
}
15661566

1567+
bool ModuleDecl::mightDeclareCrossImportOverlays() const {
1568+
return !declaredCrossImports.empty();
1569+
}
1570+
15671571
void ModuleDecl::
15681572
findDeclaredCrossImportOverlays(Identifier bystanderName,
15691573
SmallVectorImpl<Identifier> &overlayNames,

lib/AST/Stmt.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,21 @@ bool CatchStmt::isSyntacticallyExhaustive() const {
305305

306306
PoundAvailableInfo *PoundAvailableInfo::create(ASTContext &ctx,
307307
SourceLoc PoundLoc,
308+
SourceLoc LParenLoc,
308309
ArrayRef<AvailabilitySpec *> queries,
309310
SourceLoc RParenLoc) {
310311
unsigned size = totalSizeToAlloc<AvailabilitySpec *>(queries.size());
311312
void *Buffer = ctx.Allocate(size, alignof(PoundAvailableInfo));
312-
return ::new (Buffer) PoundAvailableInfo(PoundLoc, queries, RParenLoc);
313+
return ::new (Buffer) PoundAvailableInfo(PoundLoc, LParenLoc, queries,
314+
RParenLoc);
313315
}
314316

315317
SourceLoc PoundAvailableInfo::getEndLoc() const {
316318
if (RParenLoc.isInvalid()) {
317319
if (NumQueries == 0) {
318-
return PoundLoc;
320+
if (LParenLoc.isInvalid())
321+
return PoundLoc;
322+
return LParenLoc;
319323
}
320324
return getQueries()[NumQueries - 1]->getSourceRange().End;
321325
}

0 commit comments

Comments
 (0)