Skip to content

Resolve master conflicts #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
41ef65c
[build-script] Add the installation prefix to the toolchain path
finagolfin Mar 22, 2020
6ad83a0
[stdlib] StaticString: extension per conformance
benrimmington Mar 28, 2020
96e6e50
Fix @available(macCatalyst N, iOS N+M) bug
beccadax Apr 14, 2020
f32a6e2
[stdlib] Buildfix differentiation for OpenBSD.
3405691582 Apr 15, 2020
05736d1
Handle multiple @available attributes correctly
beccadax Apr 17, 2020
4ed3665
[Diagnostics] Provide anchors on demand instead of storing in `Failur…
xedin Apr 15, 2020
f5714bf
[Diagnostics] Switch `get{Raw}Anchor` to return `TypedNode`
xedin Apr 15, 2020
71ab19b
[Diagnostics] Switch `getConstraintLocator` variants to accept `Typed…
xedin Apr 16, 2020
66a07ba
[Diagnostics] Switch `getContextualType*` to use `TypedNode`
xedin Apr 16, 2020
08e09fc
[Diagnostics] Switch `getType` to use `TypedNode`
xedin Apr 16, 2020
6335a4f
[Diagnostics] Resolve const-ness problems introduced by `TypedNode`
xedin Apr 16, 2020
c3b0232
Add compiler option to *disable* warnings-as-errors
artemcm Apr 17, 2020
4ea7f3b
[Diagnostics] Add helper functions to work with anchors - `{castTo, g…
xedin Apr 17, 2020
967b3a3
[Diagnostics] Adjust `getCallInfo` to accept `TypedNode` instead of e…
xedin Apr 17, 2020
5fb9d73
Avoid unnecessary performTypeChecking() in REPL
rintaro Nov 13, 2019
a2d38f6
[SIL Diagnostics] Improve diagnostics for capture of inout values
ravikandhadai Apr 19, 2020
446c6e6
[NFC] Refactor validateTBDIfNeeded
CodaFi Apr 19, 2020
fbbf61f
Revert "[Darwin] Further restrict inference of the simulator environm…
compnerd Apr 19, 2020
f0df467
Merge pull request #31144 from apple/revert-30771-stop-inferring-simu…
shahmishal Apr 20, 2020
423713b
Merge pull request #31135 from CodaFi/replete-with-errors
CodaFi Apr 20, 2020
db3e9fc
Merge pull request #31142 from CodaFi/TBD-TBD
CodaFi Apr 20, 2020
7fb81ea
[Gardening] Const-qualify CompilerInstance::getInvocation()
CodaFi Apr 20, 2020
37f016b
[NFC] Formalize isModuleExternallyConsumed
CodaFi Apr 20, 2020
ad967dd
Merge pull request #31145 from CodaFi/all-bran
CodaFi Apr 20, 2020
00b09c7
More StringRef -> std::string conversion fixes.
MForster Apr 20, 2020
87d3b4d
Merge pull request #31148 from MForster/m/string-fixes
swift-ci Apr 20, 2020
131aede
Devirtualizer: fix a miscompile due to handling of cast instructions.
eeckstein Apr 20, 2020
5a2b42d
[NFC] Fix typo in SerializedModuleLoader.cpp
MaxDesiatov Apr 20, 2020
4f4ed60
Merge pull request #31151 from eeckstein/fix-devirtualizer
eeckstein Apr 20, 2020
82cdf91
Merge pull request #31033 from 3405691582/OpenBSD_Port_BuildfixDiffer…
compnerd Apr 20, 2020
f1885df
Merge pull request #31152 from MaxDesiatov/patch-1
swift-ci Apr 20, 2020
c11f013
Merge pull request #31099 from artemcm/NoWarningsAsErrorsOption
artemcm Apr 20, 2020
1c2bc06
Merge pull request #31139 from ravikandhadai/autoclosure-capture-diag…
ravikandhadai Apr 20, 2020
177bd24
Merge pull request #30702 from benrimmington/static-string-extensions
CodaFi Apr 20, 2020
682b375
Merge pull request #30565 from buttaface/prefix
shahmishal Apr 20, 2020
0a037e7
Merge pull request #31104 from xedin/compute-diag-anchors-on-demand
xedin Apr 20, 2020
2996e93
Merge pull request #31025 from brentdax/dangerous-intersection
beccadax Apr 20, 2020
a6f6120
Merge branch 'master' of github.com:swiftwasm/swift into maxd/master-…
MaxDesiatov Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ERROR(capture_before_declaration_defer,none,
NOTE(captured_value_declared_here,none,
"captured value declared here", ())

#define SELECT_ESCAPING_CLOSURE_KIND "escaping %select{local function|closure}0"
#define SELECT_ESCAPING_CLOSURE_KIND "escaping %select{local function|closure|autoclosure}0"

// Invalid escaping capture diagnostics.
ERROR(escaping_inout_capture,none,
Expand All @@ -133,6 +133,10 @@ ERROR(escaping_noescape_var_capture,none,

NOTE(value_captured_here,none,"captured here", ())

NOTE(copy_inout_captured_by_autoclosure,none, "pass a copy of %0", (Identifier))

NOTE(copy_self_captured_by_autoclosure,none, "pass a copy of 'self'", ())

#undef SELECT_ESCAPING_CLOSURE_KIND

NOTE(value_captured_transitively,none,
Expand Down
7 changes: 6 additions & 1 deletion include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3759,7 +3759,12 @@ class ClosureExpr : public AbstractClosureExpr {
assert(hasExplicitResultType() && "No explicit result type");
return ExplicitResultType;
}


TypeRepr *getExplicitResultTypeRepr() const {
assert(hasExplicitResultType() && "No explicit result type");
return ExplicitResultType.getTypeRepr();
}

void setExplicitResultType(SourceLoc arrowLoc, TypeLoc resultType) {
ArrowLoc = arrowLoc;
ExplicitResultType = resultType;
Expand Down
42 changes: 28 additions & 14 deletions lib/AST/Availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,29 @@ void AvailabilityInference::applyInferredAvailableAttrs(
}
}

/// Returns true if the introduced version in \p newAttr should be used instead
/// of the introduced version in \p prevAttr when both are attached to the same
/// declaration and refer to the active platform.
static bool isBetterThan(const AvailableAttr *newAttr,
const AvailableAttr *prevAttr) {
assert(newAttr);

// If there is no prevAttr, newAttr of course wins.
if (!prevAttr)
return true;

// If they belong to the same platform, the one that introduces later wins.
if (prevAttr->Platform == newAttr->Platform)
return prevAttr->Introduced.getValue() < newAttr->Introduced.getValue();

// If the new attribute's platform inherits from the old one, it wins.
return inheritsAvailabilityFromPlatform(newAttr->Platform,
prevAttr->Platform);
}

Optional<AvailabilityContext>
AvailabilityInference::annotatedAvailableRange(const Decl *D, ASTContext &Ctx) {
Optional<AvailabilityContext> AnnotatedRange;
const AvailableAttr *bestAvailAttr = nullptr;

for (auto Attr : D->getAttrs()) {
auto *AvailAttr = dyn_cast<AvailableAttr>(Attr);
Expand All @@ -145,21 +165,15 @@ AvailabilityInference::annotatedAvailableRange(const Decl *D, ASTContext &Ctx) {
continue;
}

AvailabilityContext AttrRange{
VersionRange::allGTE(AvailAttr->Introduced.getValue())};

// If we have multiple introduction versions, we will conservatively
// assume the worst case scenario. We may want to be more precise here
// in the future or emit a diagnostic.

if (AnnotatedRange.hasValue()) {
AnnotatedRange.getValue().intersectWith(AttrRange);
} else {
AnnotatedRange = AttrRange;
}
if (isBetterThan(AvailAttr, bestAvailAttr))
bestAvailAttr = AvailAttr;
}

return AnnotatedRange;
if (!bestAvailAttr)
return None;

return AvailabilityContext{
VersionRange::allGTE(bestAvailAttr->Introduced.getValue())};
}

AvailabilityContext AvailabilityInference::availableRange(const Decl *D,
Expand Down
23 changes: 19 additions & 4 deletions lib/SILOptimizer/Mandatory/DiagnoseInvalidEscapingCaptures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "swift/AST/ASTContext.h"
#include "swift/AST/DiagnosticsSIL.h"
#include "swift/AST/Expr.h"
#include "swift/AST/Types.h"
#include "swift/SIL/ApplySite.h"
#include "swift/SIL/InstructionUtils.h"
Expand Down Expand Up @@ -332,17 +333,22 @@ static void checkPartialApply(ASTContext &Context, DeclContext *DC,
// Should match SELECT_ESCAPING_CLOSURE_KIND in DiagnosticsSIL.def.
enum {
EscapingLocalFunction,
EscapingClosure
EscapingClosure,
EscapingAutoClosure,
} functionKind = EscapingClosure;

if (auto *F = PAI->getReferencedFunctionOrNull()) {
if (auto loc = F->getLocation()) {
if (loc.isASTNode<FuncDecl>())
if (loc.isASTNode<FuncDecl>()) {
functionKind = EscapingLocalFunction;
} else if (loc.isASTNode<AutoClosureExpr>()) {
functionKind = EscapingAutoClosure;
}
}
}
// First, diagnose the inout captures, if any.
for (auto inoutCapture : inoutCaptures) {
Optional<Identifier> paramName = None;
if (isUseOfSelfInInitializer(inoutCapture)) {
diagnose(Context, PAI->getLoc(), diag::escaping_mutable_self_capture,
functionKind);
Expand All @@ -352,14 +358,23 @@ static void checkPartialApply(ASTContext &Context, DeclContext *DC,
diagnose(Context, PAI->getLoc(), diag::escaping_mutable_self_capture,
functionKind);
else {
paramName = param->getName();
diagnose(Context, PAI->getLoc(), diag::escaping_inout_capture,
functionKind, param->getName());
diagnose(Context, param->getLoc(), diag::inout_param_defined_here,
param->getName());
}
}

diagnoseCaptureLoc(Context, DC, PAI, inoutCapture);
if (functionKind != EscapingAutoClosure) {
diagnoseCaptureLoc(Context, DC, PAI, inoutCapture);
continue;
}
// For an autoclosure capture, present a way to fix the problem.
if (paramName)
diagnose(Context, PAI->getLoc(), diag::copy_inout_captured_by_autoclosure,
paramName.getValue());
else
diagnose(Context, PAI->getLoc(), diag::copy_self_captured_by_autoclosure);
}

// Finally, diagnose captures of values with noescape type.
Expand Down
11 changes: 9 additions & 2 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,17 @@ ConstraintLocator *Solution::getCalleeLocator(ConstraintLocator *locator,
}

ConstraintLocator *
Solution::getConstraintLocator(Expr *anchor,
Solution::getConstraintLocator(const Expr *anchor,
ArrayRef<LocatorPathElt> path) const {
auto &cs = getConstraintSystem();
return cs.getConstraintLocator(anchor, path);
return cs.getConstraintLocator(const_cast<Expr *>(anchor), path);
}

ConstraintLocator *
Solution::getConstraintLocator(ConstraintLocator *base,
ArrayRef<LocatorPathElt> path) const {
auto &cs = getConstraintSystem();
return cs.getConstraintLocator(base, path);
}

/// Return the implicit access kind for a MemberRefExpr with the
Expand Down
Loading