Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
90e8740
Update 5.3 to build with Xcode 12 beta
shahmishal Jun 22, 2020
b731e9a
[SDK] Remove obsolete overlay code
lorentey Jun 22, 2020
f6aea0c
[README] Update the Xcode version.
shahmishal Jun 22, 2020
a890d8b
Merge pull request #32503 from apple/update-5.3-xcode-12-beta
shahmishal Jun 23, 2020
9e84948
[CodeCompletion] Fallback to nominal member completion after trailing…
rintaro Jun 23, 2020
9ef0b11
Use a shorter example string.
amartini51 Jun 24, 2020
bbe1811
Use the correct argument label.
amartini51 Jun 24, 2020
baa317a
Match example in docs to current/correct API.
amartini51 Jun 24, 2020
98399fa
Remove stray argument label.
amartini51 Jun 24, 2020
e3d93ef
Revert "[Sema] Fix leak of implementation-only imported types in SPI …
xymus May 22, 2020
eeafb55
[SourceKit/Indentation] Fix over-indent after function declaration wi…
Jun 23, 2020
064749e
[CodeCompletion] Assume non-'isSimpleDidSet' in code completion
rintaro Jun 24, 2020
0ab4e11
Merge pull request #32532 from rintaro/5.3-ide-completion-rdar64699286
tkremenek Jun 25, 2020
213b598
Merge pull request #32526 from rintaro/5.3-ide-completion-rdar64650782
tkremenek Jun 25, 2020
3998644
Merge pull request #32533 from nathawes/fix-indentation-after-incompl…
tkremenek Jun 25, 2020
32514b4
[Function builders] Run syntactic diagnostics for function bodies.
DougGregor Jun 24, 2020
1d23ca7
Merge pull request #32556 from amartini51/release/5.3
amartini51 Jun 26, 2020
5deb3e7
test: xfail Driver/SourceRanges/range-lifecycle.swift
nkcsgexi Jun 26, 2020
ca3172a
Merge pull request #32570 from nkcsgexi/64812676
nkcsgexi Jun 26, 2020
0a0843b
[Function builders] Update change for Swift 5.3 branch.
DougGregor Jun 26, 2020
0c824ea
Merge pull request #32552 from xymus/revert-ioi-in-spi-check-5.3
shahmishal Jun 26, 2020
553f2fa
[SourceKit] Enable ASTContext caching in other completion-like requests
rintaro Jun 26, 2020
88d0747
[SourceKit/CodeFormat] Fix multi-line array literal elements not inde…
Jun 27, 2020
7985c77
Merge pull request #32566 from DougGregor/function-builder-syntactic-…
DougGregor Jun 28, 2020
829238c
Merge pull request #32583 from nathawes/array-literal-sub-expr-indent…
akyrtzi Jun 29, 2020
7b54c83
[SourceKit] Report 'key.reusingastcontext' in completion like requests
rintaro Jun 29, 2020
5256e0a
[SourceKit/CursorInfo] Still print implicit decls in cursorinfo to ha…
Jun 26, 2020
e6f224c
[Function Builders] Record constraint generation failures in
hborla Jun 29, 2020
f46d14f
[NFC] Add a test for constraint generation failures in a pattern binding
hborla Jun 29, 2020
7323cab
Merge pull request #32603 from nathawes/fix-no-quickhelp-for-shorthan…
akyrtzi Jun 29, 2020
a1002c7
[SouceKit] Make "ASTContext reusing" optional
rintaro Jun 29, 2020
e4e6684
Merge pull request #32608 from hborla/5.3-function-builder-csgen-failure
hborla Jun 30, 2020
946b7b4
test: xfail Driver/loaded_module_trace_swiftinterface.swift. rdar://6…
nkcsgexi Jun 30, 2020
90ff09e
Merge pull request #32619 from nkcsgexi/64941662
nkcsgexi Jun 30, 2020
8ebc214
Merge pull request #32579 from rintaro/5.3-sourcekit-fast-completionl…
akyrtzi Jun 30, 2020
7aa283d
[CSGen] Handle incorrect patterns (e.g. referencing unknown types)
xedin Jun 29, 2020
5053380
Merge pull request #32624 from xedin/rdar-64844584-5.3
xedin Jun 30, 2020
e6a3215
[CodeCompletion] Force apply a viable solution even if ambiguous
rintaro Jun 26, 2020
0cb3e3d
[5.3][RemoteMirror] Gracefully handle a NULL TypeInfo passed to conve…
mikeash Jul 1, 2020
f6ccefe
Loosen a CopyForwarding assert: store instead of deinit. (#32641)
atrick Jul 1, 2020
d2eca7e
Merge pull request #32650 from rintaro/5.3-ide-completion-forceapply-…
akyrtzi Jul 1, 2020
410ea56
Use Formal Access To Compute Override Elision Check
CodaFi Jul 1, 2020
e2c5630
[5.3] [stdlib] Performance fixes for removeFirst and removeLast (#32647)
natecook1000 Jul 1, 2020
d26abce
[5.3] Fix NULL deref for invalid mangled input (#31878) (#31979)
tbkka Jul 2, 2020
0e314e6
Merge pull request #32663 from CodaFi/overrydels-cycles
CodaFi Jul 2, 2020
ab24e70
Merge branch 'release/5.3' of github.com:swiftwasm/swift into maxd/5.…
MaxDesiatov Jul 2, 2020
25529bf
Use Xcode 12 beta when building for macOS
MaxDesiatov Jul 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ jobs:
path: ../build-cache
key: ${{ runner.os }}-sccache-v5-5.3
- name: Build macOS installable archive
run: ./utils/webassembly/ci.sh
run: |
sudo xcode-select --switch /Applications/Xcode_12_beta.app/Contents/Developer/
./utils/webassembly/ci.sh
- name: Upload macOS installable archive
uses: actions/upload-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.

#### macOS

To build for macOS, you need [Xcode 11.4](https://developer.apple.com/xcode/resources/).
To build for macOS, you need [Xcode 12 beta](https://developer.apple.com/xcode/resources/).
The required version of Xcode changes frequently, and is often a beta release.
Check this document or the host information on <https://ci.swift.org> for the
current required version.
Expand Down
3 changes: 3 additions & 0 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,11 @@ function (swift_benchmark_compile_archopts)
"-m${triple_platform}-version-min=${ver}"
"-lobjc"
"-L${SWIFT_LIBRARY_PATH}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}"
"-L${sdk}/usr/lib/swift"
"-Xlinker" "-rpath"
"-Xlinker" "${SWIFT_LINK_RPATH}"
"-Xlinker" "-rpath"
"-Xlinker" "/usr/lib/swift"
${bench_library_objects}
${bench_driver_objects}
${ld64_add_ast_path_opts}
Expand Down
2 changes: 2 additions & 0 deletions include/swift/IDE/ConformingMethodList.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ConformingMethodListConsumer {
public:
virtual ~ConformingMethodListConsumer() {}
virtual void handleResult(const ConformingMethodListResult &result) = 0;
virtual void setReusingASTContext(bool flag) = 0;
};

/// Printing consumer
Expand All @@ -53,6 +54,7 @@ class PrintingConformingMethodListConsumer
PrintingConformingMethodListConsumer(llvm::raw_ostream &OS) : OS(OS) {}

void handleResult(const ConformingMethodListResult &result) override;
void setReusingASTContext(bool flag) override {}
};

/// Create a factory for code completion callbacks.
Expand Down
2 changes: 2 additions & 0 deletions include/swift/IDE/TypeContextInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TypeContextInfoConsumer {
public:
virtual ~TypeContextInfoConsumer() {}
virtual void handleResults(ArrayRef<TypeContextInfoItem>) = 0;
virtual void setReusingASTContext(bool flag) = 0;
};

/// Printing consumer
Expand All @@ -48,6 +49,7 @@ class PrintingTypeContextInfoConsumer : public TypeContextInfoConsumer {
PrintingTypeContextInfoConsumer(llvm::raw_ostream &OS) : OS(OS) {}

void handleResults(ArrayRef<TypeContextInfoItem>) override;
void setReusingASTContext(bool flag) override {}
};

/// Create a factory for code completion callbacks.
Expand Down
5 changes: 4 additions & 1 deletion lib/AST/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,11 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
if (auto *VD = dyn_cast<ValueDecl>(D)) {
if (auto *BD = VD->getOverriddenDecl()) {
if (!BD->hasClangNode() &&
VD->isEffectiveLinkageMoreVisibleThan(BD))
!BD->getFormalAccessScope(VD->getDeclContext(),
/*treatUsableFromInlineAsPublic*/ true)
.isPublic()) {
return false;
}
}
}
break;
Expand Down
2 changes: 2 additions & 0 deletions lib/Demangling/Demangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,8 @@ NodePointer Demangler::demangleArchetype() {
if (!demangleBoundGenerics(boundGenericArgs, retroactiveConformances))
return nullptr;
auto Name = popNode();
if (!Name)
return nullptr;
auto opaque = createWithChildren(Node::Kind::OpaqueType, Name,
createNode(Node::Kind::Index, index));
auto boundGenerics = createNode(Node::Kind::TypeList);
Expand Down
30 changes: 22 additions & 8 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6158,15 +6158,29 @@ void CodeCompletionCallbacksImpl::doneParsing() {
if (IsAtStartOfLine) {
// foo() {}
// <HERE>
// Global completion.

auto &Sink = CompletionContext.getResultSink();
addDeclKeywords(Sink);
addStmtKeywords(Sink, MaybeFuncBody);
addSuperKeyword(Sink);
addLetVarKeywords(Sink);
addExprKeywords(Sink);
addAnyTypeKeyword(Sink, CurDeclContext->getASTContext().TheAnyType);
DoPostfixExprBeginning();
if (isa<Initializer>(CurDeclContext))
CurDeclContext = CurDeclContext->getParent();

if (CurDeclContext->isTypeContext()) {
// Override completion (CompletionKind::NominalMemberBeginning).
addDeclKeywords(Sink);
addLetVarKeywords(Sink);
SmallVector<StringRef, 0> ParsedKeywords;
CompletionOverrideLookup OverrideLookup(Sink, Context, CurDeclContext,
ParsedKeywords, SourceLoc());
OverrideLookup.getOverrideCompletions(SourceLoc());
} else {
// Global completion (CompletionKind::PostfixExprBeginning).
addDeclKeywords(Sink);
addStmtKeywords(Sink, MaybeFuncBody);
addSuperKeyword(Sink);
addLetVarKeywords(Sink);
addExprKeywords(Sink);
addAnyTypeKeyword(Sink, Context.TheAnyType);
DoPostfixExprBeginning();
}
} else {
// foo() {} <HERE>
// Member completion.
Expand Down
18 changes: 16 additions & 2 deletions lib/IDE/Formatting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,11 @@ class FormatWalker : public ASTWalker {
return Aligner.getContextAndSetAlignment(CtxOverride);
}

// There are no parens at this point, so if there are no parameters either,
// this shouldn't be a context (it's an implicit parameter list).
if (!PL->size())
return None;

ListAligner Aligner(SM, TargetLocation, ContextLoc, Range.Start);
for (auto *PD: *PL)
Aligner.updateAlignment(PD->getSourceRange(), PD);
Expand Down Expand Up @@ -2336,8 +2341,17 @@ class FormatWalker : public ASTWalker {
return None;

ListAligner Aligner(SM, TargetLocation, L, L, R, true);
for (auto *Elem: AE->getElements())
Aligner.updateAlignment(Elem->getStartLoc(), Elem->getEndLoc(), Elem);
for (auto *Elem: AE->getElements()) {
SourceRange ElemRange = Elem->getSourceRange();
Aligner.updateAlignment(ElemRange, Elem);
if (isTargetContext(ElemRange)) {
Aligner.setAlignmentIfNeeded(CtxOverride);
return IndentContext {
ElemRange.Start,
!OutdentChecker::hasOutdent(SM, ElemRange, Elem)
};
}
}
return Aligner.getContextAndSetAlignment(CtxOverride);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3228,7 +3228,7 @@ Parser::parseTrailingClosures(bool isExprBasic, SourceRange calleeRange,
if (CodeCompletion)
CodeCompletion->completeLabeledTrailingClosure(CCExpr, Tok.isAtStartOfLine());
consumeToken(tok::code_complete);
result.hasCodeCompletion();
result.setHasCodeCompletion();
closures.push_back({Identifier(), SourceLoc(), CCExpr});
continue;
}
Expand Down
24 changes: 16 additions & 8 deletions lib/SILOptimizer/Transforms/CopyForwarding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ namespace {
/// This returns false and sets Oper to a valid operand if the instruction is a
/// projection of the value at the given address. The assumption is that we
/// cannot deinitialize memory via projections.
///
/// This returns true with Oper == nullptr for trivial stores (without a proper
/// deinit).
class AnalyzeForwardUse
: public SILInstructionVisitor<AnalyzeForwardUse, bool> {
public:
Expand Down Expand Up @@ -352,7 +355,10 @@ class AnalyzeForwardUse
return true;
}
bool visitStoreInst(StoreInst *Store) {
llvm_unreachable("illegal reinitialization or store of an address");
// Trivial values may be stored prior to the next deinit. A store is an
// implicit "deinit" with no operand to replace.
assert(Store->getOperand(0)->getType().isTrivial(*Store->getFunction()));
return true;
}
bool visitDestroyAddrInst(DestroyAddrInst *UserInst) {
Oper = &UserInst->getOperandRef();
Expand Down Expand Up @@ -1011,15 +1017,17 @@ bool CopyForwarding::forwardPropagateCopy() {
continue;

AnalyzeForwardUse AnalyzeUse(CopyDest);
bool seenDeinit = AnalyzeUse.visit(UserInst);
// If this use cannot be analyzed, then abort.
bool seenDeinitOrStore = AnalyzeUse.visit(UserInst);
if (AnalyzeUse.Oper)
ValueUses.push_back(AnalyzeUse.Oper);

// If this is a deinit or store, we're done searching.
if (seenDeinitOrStore)
break;

// If this non-deinit instruction wasn't fully analyzed, bail-out.
if (!AnalyzeUse.Oper)
return false;
// Otherwise record the operand.
ValueUses.push_back(AnalyzeUse.Oper);
// If this is a deinit, we're done searching.
if (seenDeinit)
break;
}
if (SI == SE)
return false;
Expand Down
64 changes: 63 additions & 1 deletion lib/Sema/BuilderTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ class BuilderClosureVisitor
auto target = SolutionApplicationTarget::forInitialization(
patternBinding->getInit(index), dc, patternType, pattern,
/*bindPatternVarsOneWay=*/true);
if (cs->generateConstraints(target, FreeTypeVariableBinding::Disallow))
if (cs->generateConstraints(target, FreeTypeVariableBinding::Disallow)) {
hadError = true;
continue;
}

// Keep track of this binding entry.
applied.patternBindingEntries.insert({{patternBinding, index}, target});
Expand Down Expand Up @@ -1223,6 +1225,65 @@ BraceStmt *swift::applyFunctionBuilderTransform(
captured.first, captured.second)));
}

/// Produce any additional syntactic diagnostics for the body of a
static void performAddOnDiagnostics(BraceStmt *stmt, DeclContext *dc) {
class AddOnDiagnosticWalker : public ASTWalker {
SmallVector<DeclContext *, 4> dcStack;

public:
AddOnDiagnosticWalker(DeclContext *dc) {
dcStack.push_back(dc);
}

std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
performSyntacticExprDiagnostics(
expr, dcStack.back(), /*isExprStmt=*/false);

if (auto closure = dyn_cast<ClosureExpr>(expr)) {
if (!closure->hasSingleExpressionBody() &&
!closure->hasAppliedFunctionBuilder()) {
dcStack.push_back(closure);
return { true, expr };
}
}

return { false, expr };
}

Expr *walkToExprPost(Expr *expr) override {
if (auto closure = dyn_cast<ClosureExpr>(expr)) {
if (!closure->hasSingleExpressionBody() &&
!closure->hasAppliedFunctionBuilder()) {
assert(dcStack.back() == closure);
dcStack.pop_back();
}
}

return expr;
}

std::pair<bool, Stmt *> walkToStmtPre(Stmt *stmt) override {
performStmtDiagnostics(dcStack.back()->getASTContext(), stmt);
return { true, stmt };
}

std::pair<bool, Pattern*> walkToPatternPre(Pattern *pattern) override {
return { false, pattern };
}

bool walkToTypeLocPre(TypeLoc &typeLoc) override { return false; }

bool walkToTypeReprPre(TypeRepr *typeRepr) override { return false; }

bool walkToParameterListPre(ParameterList *params) override {
return false;
}
};

AddOnDiagnosticWalker walker(dc);
stmt->walk(walker);
}

Optional<BraceStmt *> TypeChecker::applyFunctionBuilderBodyTransform(
FuncDecl *func, Type builderType) {
// Pre-check the body: pre-check any expressions in it and look
Expand Down Expand Up @@ -1363,6 +1424,7 @@ Optional<BraceStmt *> TypeChecker::applyFunctionBuilderBodyTransform(
if (auto result = cs.applySolution(
solutions.front(),
SolutionApplicationTarget(func))) {
performAddOnDiagnostics(result->getFunctionBody(), func);
return result->getFunctionBody();
}

Expand Down
42 changes: 28 additions & 14 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,18 +1180,24 @@ namespace {
TVO_CanBindToLValue |
TVO_CanBindToNoEscape);

// Defaults to the type of the base expression if we have a base
// expression.
// FIXME: This is just to keep the old behavior where `foo(base.<HERE>)`
// the argument is type checked to the type of the 'base'. Ideally, code
// completion expression should be defauled to 'UnresolvedType'
// regardless of the existence of the base expression. But the constraint
// system is simply not ready for that.
if (auto base = E->getBase()) {
// Defaults to the type of the base expression if we have a base
// expression.
// FIXME: This is just to keep the old behavior where `foo(base.<HERE>)`
// the argument is type checked to the type of the 'base'. Ideally, code
// completion expression should be defauled to 'UnresolvedType'
// regardless of the existence of the base expression. But the
// constraint system is simply not ready for that.
CS.addConstraint(ConstraintKind::Defaultable, ty, CS.getType(base),
locator);

// Apply a viable solution even if it's ambiguous.
// FIXME: Remove this. This is a hack for code completion which only
// see solution applied AST. In future, code completion collects all
// viable solutions so we need to apply any solution at all.
CS.Options |= ConstraintSystemFlags::ForceApplyViableSolution;
}

return ty;
}

Expand Down Expand Up @@ -2321,12 +2327,18 @@ namespace {

return setType(ParenType::get(CS.getASTContext(), underlyingType));
}
case PatternKind::Var:
case PatternKind::Var: {
auto *subPattern = cast<VarPattern>(pattern)->getSubPattern();
auto type = getTypeForPattern(subPattern, locator, externalPatternType,
bindPatternVarsOneWay);

if (!type)
return Type();

// Var doesn't affect the type.
return setType(
getTypeForPattern(
cast<VarPattern>(pattern)->getSubPattern(), locator,
externalPatternType, bindPatternVarsOneWay));
return setType(type);
}

case PatternKind::Any: {
return setType(
CS.createTypeVariable(CS.getConstraintLocator(locator),
Expand Down Expand Up @@ -4235,7 +4247,9 @@ static bool generateInitPatternConstraints(
pattern, locator, target.shouldBindPatternVarsOneWay(),
target.getInitializationPatternBindingDecl(),
target.getInitializationPatternBindingIndex());
assert(patternType && "All patterns have a type");

if (!patternType)
return true;

if (auto wrappedVar = target.getInitializationWrappedVar()) {
// Add an equal constraint between the pattern type and the
Expand Down
6 changes: 6 additions & 0 deletions lib/Sema/CSRanking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,12 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
return bestIdx;
}

// FIXME: Terrible hack for code completion. But applying a solution is better
// than just failing.
if (Options.contains(ConstraintSystemFlags::ForceApplyViableSolution)) {
return bestIdx;
}

// If there is not a single "better" than others
// solution, which probably means that solutions
// were incomparable, let's just keep the original
Expand Down
5 changes: 5 additions & 0 deletions lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,11 @@ enum class ConstraintSystemFlags {
/// If set, constraint system always reuses type of pre-typechecked
/// expression, and doesn't dig into its subexpressions.
ReusePrecheckedType = 0x08,

/// FIME: Temporary hack.
/// Force apply a viable solution even if they are ambiguous, so that the
/// client get a solution.
ForceApplyViableSolution = 0x10,
};

/// Options that affect the constraint system as a whole.
Expand Down
Loading