Skip to content

[pull] swiftwasm-release/5.3 from release/5.3 #1203

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
Jun 16, 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
d93778e
Remove stray backtick in doc comment.
amartini51 May 1, 2020
a9e97b3
Add all the ptrauth IR attributes that Clang does.
rjmccall May 22, 2020
2f10202
[semantic-arc-opts] Use all consuming uses instead of just destroying…
gottesmm Apr 20, 2020
b9ad518
[CodeCompletion] Wrap base expression with CodeCompletionExpr
rintaro Jun 4, 2020
0911d2d
[Property wrappers] Reject opaque result types when there is no initi…
DougGregor Jun 8, 2020
41fc033
[Property wrappers] Fix another opaque-result-types crasher.
DougGregor Jun 8, 2020
e52ec93
[Function builders] Infer function builder through @_dynamicReplaceme…
DougGregor Jun 8, 2020
3b626c9
[Function builders] Improve test case for inference behavior
DougGregor Jun 8, 2020
ad1bf22
Coarse-grained dependencies by default
Jun 9, 2020
c6d6f29
[CodeCompletion] Skip to '=' after completion in 'if'/'guard' pattern
rintaro May 28, 2020
5753754
[CodeCompletion] Add keypath apply subscript after open bracket
rintaro May 21, 2020
157c38d
[CodeCompletion] Suggest 'Self' inside struct, enum and classe
rintaro May 28, 2020
f34687c
Also disable type fingerprints by default.
Jun 10, 2020
3951ea5
Fix tests
Jun 10, 2020
4388134
[5.3] Fix c_globals test
aschwaighofer Jun 10, 2020
4ffaa5a
Merge pull request #32298 from aschwaighofer/fix_c_globals_test_5.3
shahmishal Jun 10, 2020
2e6bf1a
Merge pull request #32259 from DougGregor/infer-function-builder-dyna…
tkremenek Jun 10, 2020
8ba8d95
Merge pull request #32258 from DougGregor/property-wrapper-opaque-res…
tkremenek Jun 10, 2020
3e0b2b8
Merge pull request #31963 from rjmccall/ir-ptrauth-attributes-5.3
tkremenek Jun 10, 2020
3a23cac
[5.3] Mark non-foreign entry points of `@objc dynamic` methods in gen…
aschwaighofer Jun 3, 2020
fc20aee
Merge pull request #32286 from rintaro/5.3-ide-completion-rdar56802036
tkremenek Jun 10, 2020
1517ceb
Merge pull request #32288 from rintaro/5.3-ide-completion-sself-rdar6…
tkremenek Jun 10, 2020
38b2066
Merge pull request #32287 from rintaro/5.3-ide-completion-keypathsubs…
tkremenek Jun 10, 2020
24370b7
Merge pull request #32130 from gottesmm/release/5.3-rdar63188362
tkremenek Jun 10, 2020
b0340f0
Merge pull request #32280 from davidungar/coarse-by-default
Jun 10, 2020
8f1415c
[SourceKit] Disable labeled trailing closure support except code comp…
rintaro Jun 9, 2020
3d4a9cf
Merge pull request #32300 from aschwaighofer/dyn_repl_objc_method_gen…
aschwaighofer Jun 11, 2020
3718981
Merge pull request #32207 from rintaro/5.3-ide-completion-rdar63965160
tkremenek Jun 11, 2020
eaa3e34
[5.3][preset] Add missing libicu dependencies to package presets (#32…
edymtt Jun 11, 2020
b556c73
[Type checker] Experimental support for one-way parameter constraints.
DougGregor Jun 5, 2020
fd29659
[Function builders] Use one-way constraints for closure parameters.
DougGregor Jun 10, 2020
991cc3f
Merge pull request #32315 from rintaro/5.3-ide-conformingmethods-disa…
tkremenek Jun 11, 2020
3e13ca6
Merge pull request #32323 from DougGregor/function-builder-one-way-pa…
DougGregor Jun 12, 2020
edec4aa
[CS] Update splice logic in simplifyLocator to handle situations wher…
theblixguy Jun 13, 2020
0f1439c
[Runtime] Zero out the entire witness table during instantiation.
DougGregor Jun 14, 2020
6c1acb9
Merge pull request #31766 from amartini51/release/5.3
amartini51 Jun 15, 2020
5729d2f
Merge pull request #32361 from theblixguy/fix/SR-12990-5.3
DougGregor Jun 15, 2020
30491e6
Merge pull request #32370 from DougGregor/witness-table-instantiation…
DougGregor Jun 16, 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
32 changes: 32 additions & 0 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,7 @@ class ValueDecl : public Decl {
/// Is this declaration marked with 'dynamic'?
bool isDynamic() const;

private:
bool isObjCDynamic() const {
return isObjC() && isDynamic();
}
Expand All @@ -2719,6 +2720,37 @@ class ValueDecl : public Decl {
return !isObjC() && isDynamic();
}

bool isObjCDynamicInGenericClass() const;

public:
/// Should we use Objective-C method dispatch for this decl.
bool shouldUseObjCDispatch() const {
return isObjCDynamic();
}

/// Should we use native dynamic function replacement dispatch for this decl.
bool shouldUseNativeDynamicDispatch() const {
return isNativeDynamic();
}

/// Should we use Objective-C category based function replacement for this
/// decl.
/// This is all `@objc dynamic` methods except for such methods in native
/// generic classes. We can't use a category for generic classes so we use
/// native replacement instead (this behavior is only enabled with
/// -enable-implicit-dynamic).
bool shouldUseObjCMethodReplacement() const;

/// Should we use native dynamic function replacement mechanism for this decl.
/// This is all native dynamic methods except for `@objc dynamic` methods in
/// generic classes (see above).
bool shouldUseNativeMethodReplacement() const;

/// Is this a native dynamic function replacement based replacement.
/// This is all @_dynamicReplacement(for:) of native functions and @objc
/// dynamic methods on generic classes (see above).
bool isNativeMethodReplacement() const;

bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const {
return (std::min(getEffectiveAccess(), AccessLevel::Public) >
std::min(other->getEffectiveAccess(), AccessLevel::Public));
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -5054,8 +5054,8 @@ ERROR(function_builder_infer_ambig, none,
NOTE(function_builder_infer_add_return, none,
"add an explicit 'return' statement to not use a function builder", ())
NOTE(function_builder_infer_pick_specific, none,
"apply function builder %0 (inferred from protocol %1)",
(Type, DeclName))
"apply function builder %0 (inferred from %select{protocol|dynamic replacement of}1 %2)",
(Type, unsigned, DeclName))

//------------------------------------------------------------------------------
// MARK: Tuple Shuffle Diagnostics
Expand Down
18 changes: 14 additions & 4 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,23 @@ class ErrorExpr : public Expr {
/// CodeCompletionExpr - Represents the code completion token in the AST, this
/// can help us preserve the context of the code completion position.
class CodeCompletionExpr : public Expr {
SourceRange Range;
Expr *Base;
SourceLoc Loc;

public:
CodeCompletionExpr(SourceRange Range, Type Ty = Type())
: Expr(ExprKind::CodeCompletion, /*Implicit=*/true, Ty), Range(Range) {}
CodeCompletionExpr(Expr *Base, SourceLoc Loc)
: Expr(ExprKind::CodeCompletion, /*Implicit=*/true, Type()),
Base(Base), Loc(Loc) {}

SourceRange getSourceRange() const { return Range; }
CodeCompletionExpr(SourceLoc Loc)
: CodeCompletionExpr(/*Base=*/nullptr, Loc) {}

Expr *getBase() const { return Base; }
void setBase(Expr *E) { Base = E; }

SourceLoc getLoc() const { return Loc; }
SourceLoc getStartLoc() const { return Base ? Base->getStartLoc() : Loc; }
SourceLoc getEndLoc() const { return Loc; }

static bool classof(const Expr *E) {
return E->getKind() == ExprKind::CodeCompletion;
Expand Down
9 changes: 6 additions & 3 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ namespace swift {

/// Emit the newer, finer-grained swiftdeps file. Eventually will support
/// faster rebuilds.
bool EnableFineGrainedDependencies = true;
bool EnableFineGrainedDependencies = false;

/// Instead of hashing tokens inside of NominalType and ExtensionBodies into
/// the interface hash, hash them into per-iterable-decl-context
/// fingerprints. Fine-grained dependency types won't dirty every provides
/// in a file when the user adds a member to, e.g., a struct.
bool EnableTypeFingerprints = true;
bool EnableTypeFingerprints = false;

/// When using fine-grained dependencies, emit dot files for every swiftdeps
/// file.
Expand Down Expand Up @@ -540,7 +540,10 @@ namespace swift {
/// Enable constraint solver support for experimental
/// operator protocol designator feature.
bool SolverEnableOperatorDesignatedTypes = false;


/// Enable experimental support for one-way constraints for the
/// parameters of closures.
bool EnableOneWayClosureParameters = false;
};
} // end namespace swift

Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ def experimental_print_full_convention :
HelpText<"When emitting a module interface, emit additional @convention "
"arguments, regardless of whether they were written in the source">;

def experimental_one_way_closure_params :
Flag<["-"], "experimental-one-way-closure-params">,
HelpText<"Enable experimental support for one-way closure parameters">;

def prebuilt_module_cache_path :
Separate<["-"], "prebuilt-module-cache-path">,
HelpText<"Directory of prebuilt modules for loading module interfaces">;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Parse/CodeCompletionCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ class CodeCompletionCallbacks {

virtual void completeCallArg(CodeCompletionExpr *E, bool isFirst) {};

virtual bool canPerformCompleteLabeledTrailingClosure() const {
return false;
}

virtual void completeLabeledTrailingClosure(CodeCompletionExpr *E,
bool isAtStartOfLine) {};

Expand Down
5 changes: 5 additions & 0 deletions include/swift/Serialization/Validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ExtendedValidationInfo {
unsigned IsSIB : 1;
unsigned IsTestable : 1;
unsigned ResilienceStrategy : 2;
unsigned IsImplicitDynamicEnabled: 1;
} Bits;
public:
ExtendedValidationInfo() : Bits() {}
Expand All @@ -123,6 +124,10 @@ class ExtendedValidationInfo {
void setPrivateImportsEnabled(bool enabled) {
Bits.ArePrivateImportsEnabled = enabled;
}
bool isImplicitDynamicEnabled() { return Bits.IsImplicitDynamicEnabled; }
void setImplicitDynamicEnabled(bool val) {
Bits.IsImplicitDynamicEnabled = val;
}
bool isTestable() const { return Bits.IsTestable; }
void setIsTestable(bool val) {
Bits.IsTestable = val;
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3111,12 +3111,12 @@ class Verifier : public ASTWalker {
storageDecl->getWriteImpl() ==
WriteImplKind::StoredWithObservers ||
storageDecl->getWriteImpl() == WriteImplKind::MutableAddress) &&
storageDecl->isNativeDynamic()) &&
storageDecl->shouldUseNativeDynamicDispatch()) &&
// We allow a non dynamic getter if there is a dynamic read.
!(FD->isGetter() &&
(storageDecl->getReadImpl() == ReadImplKind::Read ||
storageDecl->getReadImpl() == ReadImplKind::Address) &&
storageDecl->isNativeDynamic())) {
storageDecl->shouldUseNativeDynamicDispatch())) {
Out << "Property and accessor do not match for 'dynamic'\n";
abort();
}
Expand Down
10 changes: 9 additions & 1 deletion lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,15 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
} while (false)

Expr *visitErrorExpr(ErrorExpr *E) { return E; }
Expr *visitCodeCompletionExpr(CodeCompletionExpr *E) { return E; }
Expr *visitCodeCompletionExpr(CodeCompletionExpr *E) {
if (Expr *baseExpr = E->getBase()) {
Expr *newBaseExpr = doIt(baseExpr);
if (!newBaseExpr)
return nullptr;
E->setBase(newBaseExpr);
}
return E;
}
Expr *visitLiteralExpr(LiteralExpr *E) { return E; }
Expr *visitDiscardAssignmentExpr(DiscardAssignmentExpr *E) { return E; }
Expr *visitTypeExpr(TypeExpr *E) {
Expand Down
61 changes: 57 additions & 4 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ SourceRange IfConfigDecl::getSourceRange() const {
}

static bool isPolymorphic(const AbstractStorageDecl *storage) {
if (storage->isObjCDynamic())
if (storage->shouldUseObjCDispatch())
return true;


Expand Down Expand Up @@ -2083,7 +2083,7 @@ getDirectReadWriteAccessStrategy(const AbstractStorageDecl *storage) {
return AccessStrategy::getStorage();
case ReadWriteImplKind::Stored: {
// If the storage isDynamic (and not @objc) use the accessors.
if (storage->isNativeDynamic())
if (storage->shouldUseNativeDynamicDispatch())
return AccessStrategy::getMaterializeToTemporary(
getOpaqueReadAccessStrategy(storage, false),
getOpaqueWriteAccessStrategy(storage, false));
Expand Down Expand Up @@ -2168,7 +2168,7 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
if (isPolymorphic(this))
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ true);

if (isNativeDynamic())
if (shouldUseNativeDynamicDispatch())
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ false);

// If the storage is resilient from the given module and resilience
Expand Down Expand Up @@ -2926,6 +2926,59 @@ bool ValueDecl::isDynamic() const {
getAttrs().hasAttribute<DynamicAttr>());
}

bool ValueDecl::isObjCDynamicInGenericClass() const {
if (!isObjCDynamic())
return false;

auto *DC = this->getDeclContext();
auto *classDecl = DC->getSelfClassDecl();
if (!classDecl)
return false;

return classDecl->isGenericContext() && !classDecl->usesObjCGenericsModel();
}

bool ValueDecl::shouldUseObjCMethodReplacement() const {
if (isNativeDynamic())
return false;

if (getModuleContext()->isImplicitDynamicEnabled() &&
isObjCDynamicInGenericClass())
return false;

return isObjCDynamic();
}

bool ValueDecl::shouldUseNativeMethodReplacement() const {
if (isNativeDynamic())
return true;

if (!isObjCDynamicInGenericClass())
return false;

auto *replacedDecl = getDynamicallyReplacedDecl();
if (replacedDecl)
return false;

return getModuleContext()->isImplicitDynamicEnabled();
}

bool ValueDecl::isNativeMethodReplacement() const {
// Is this a @_dynamicReplacement(for:) that use the native dynamic function
// replacement mechanism.
auto *replacedDecl = getDynamicallyReplacedDecl();
if (!replacedDecl)
return false;

if (isNativeDynamic())
return true;

if (isObjCDynamicInGenericClass())
return replacedDecl->getModuleContext()->isImplicitDynamicEnabled();

return false;
}

void ValueDecl::setIsDynamic(bool value) {
assert(!LazySemanticInfo.isDynamicComputed ||
LazySemanticInfo.isDynamic == value);
Expand Down Expand Up @@ -5143,7 +5196,7 @@ bool AbstractStorageDecl::hasDidSetOrWillSetDynamicReplacement() const {

bool AbstractStorageDecl::hasAnyNativeDynamicAccessors() const {
for (auto accessor : getAllAccessors()) {
if (accessor->isNativeDynamic())
if (accessor->shouldUseNativeDynamicDispatch())
return true;
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,

Opts.SolverEnableOperatorDesignatedTypes |=
Args.hasArg(OPT_solver_enable_operator_designated_types);
Opts.EnableOneWayClosureParameters |=
Args.hasArg(OPT_experimental_one_way_closure_params);

Opts.DebugConstraintSolver |= Args.hasArg(OPT_debug_constraints);
Opts.DebugGenericSignatures |= Args.hasArg(OPT_debug_generic_signatures);
Expand Down
Loading