Skip to content

[master-rebranch] Merge in master resolving conflicts #33717

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
362a25a
[AST] Support SILFunctionType/SILBlockStorageType in ClangTypeConverter.
varungandhi-apple Jan 16, 2020
d287963
[sil-mode] Change viewcfg integration to specify dot as a renderer.
gottesmm Aug 27, 2020
80560da
CSGen: Infer generic arguments in explicit closure result types
AnthonyLatsis Aug 27, 2020
61d86d5
[NFC] CSGen: Clean up some flow in inferClosureType
AnthonyLatsis Aug 27, 2020
84c5065
[SR-13461] Relax An Assert
CodaFi Aug 27, 2020
c890cdd
[AST] Add functionality for computing Clang types for SIL functions.
varungandhi-apple Jul 28, 2020
1807412
[Serialization] Allow different Clang types in deserialization.
varungandhi-apple Aug 18, 2020
eaac23f
[NFC] Remove ASTExtInfo::assertIsFunctionType in favor of checkInvari…
varungandhi-apple Aug 18, 2020
8da4d53
[NFC] Use ClangTypeInfo's implicit null state instead of an extra Opt…
varungandhi-apple Aug 18, 2020
eead4ae
[NFC] Remove unused function parameter.
varungandhi-apple Aug 18, 2020
eeec16f
[NFC] Remove redundant ExtInfo parameter for getBridgedFunctionType.
varungandhi-apple Aug 20, 2020
fdbcd12
[NFC] Bridge based on SILFunctionLanguage instead of Representation.
varungandhi-apple Aug 21, 2020
f86aad9
[NFC] Extract computation of SILExtInfoBuilder bits into new method.
varungandhi-apple Aug 21, 2020
c4ad840
[NFC] Reuse SILExtInfoBuilder's main constructor in default constructor.
varungandhi-apple Aug 21, 2020
4c7ccf5
[NFC] Clean Up FrontendTool
CodaFi Aug 25, 2020
fe7444f
Add doesActionRequireSwiftStandardLibrary
CodaFi Aug 27, 2020
4c56c95
Define doesActionRequireInputs
CodaFi Aug 27, 2020
16876fb
[Clang importer] Drop unused parameter from getParamOptionality().
DougGregor Aug 24, 2020
1e5d30f
[Concurrency] Import Objective-C methods with completion handlers as …
DougGregor Aug 26, 2020
1132cda
[ownership] Move SemanticARCOpts into a separate folder in preparatio…
gottesmm Aug 28, 2020
fd6922f
Add error reporting when looking up types by demangled name.
mikeash Aug 19, 2020
6ad2757
[Concurrency] Use completion/completionHandler parameter names for as…
DougGregor Aug 28, 2020
7c8041a
Merge pull request #33672 from CodaFi/ceci-nest-pas-une-pipeline
CodaFi Aug 28, 2020
592d427
Merge pull request #33668 from CodaFi/field-day
CodaFi Aug 28, 2020
8df8315
Merge pull request #33541 from varungandhi-apple/vg-clang-types-in-si…
varungandhi-apple Aug 28, 2020
50ea66d
Merge pull request #33585 from mikeash/type-lookup-error-reporting
mikeash Aug 28, 2020
c4f0505
[Parse] Don't drop throws containing a code completion expression.
Aug 14, 2020
00994f1
[Parse] Stop early exiting when parsing catch statements and ObjCSele…
Aug 27, 2020
3e0500d
[Parse][IDE] Don't drop default argument init exprs containing code c…
Aug 24, 2020
8980356
[Parse] Perform the single expression function body transform for del…
Aug 26, 2020
c03d762
[ConstraintSystem] NFC: Clarify why upward propagation of literal con…
xedin Aug 29, 2020
ebc03a1
[CSBindings] NFC: Remove dead condition leftover from Swift version 3…
xedin Aug 29, 2020
5525a78
Merge pull request #33663 from AnthonyLatsis/unbound-closure-retty
AnthonyLatsis Aug 29, 2020
172c4be
[Sema] Diagnose use of ambiguous property wrappers (#33688)
theblixguy Aug 29, 2020
8c1be69
Merge pull request #33677 from gottesmm/pr-0c62e0beda3a13e79c75b24764…
gottesmm Aug 29, 2020
11eac12
Merge pull request #33659 from gottesmm/pr-84ac4140f366657db17f220c96…
swift-ci Aug 29, 2020
10fa19b
Merge pull request #33674 from DougGregor/concurrency-objc-import-async
DougGregor Aug 29, 2020
7a6f84d
When building standalone stdlib, explicitly use C/C++ compilers from …
kubamracek Aug 29, 2020
73f4273
Mark Reflection_jit.swift as UNSUPPORTED for standalone stdlib builds…
kubamracek Aug 29, 2020
dbd16d2
swift_build_sdk_interfaces.py: adjust output directory path to an SDK…
nkcsgexi Aug 29, 2020
3e8278a
Merge pull request #33676 from nathawes/parser-completion-fixes
Aug 29, 2020
8573c99
Merge pull request #33690 from xedin/csbindings-protocol-propagation
xedin Aug 29, 2020
db0a6f7
Merge pull request #33691 from nkcsgexi/fix-67951012
nkcsgexi Aug 29, 2020
1986870
[IDE] Fix typo to address unused warning (NFC)
Aug 29, 2020
c34212a
Turn on Verbose Output For Test
CodaFi Aug 29, 2020
a412e48
Revert "Add A Reproducer For rdar://48443680"
CodaFi Aug 29, 2020
a0cdeb5
Merge pull request #33693 from CodaFi/testify
CodaFi Aug 29, 2020
0869b51
Revert "Fallback to building Cmake from source on all platforms, not …
CodaFi Aug 30, 2020
161fa16
Revert "Turn on Verbose Output For Test"
CodaFi Aug 30, 2020
1e09ad0
Merge pull request #33699 from CodaFi/cmake-and-model
swift-ci Aug 30, 2020
fcf398a
Don't crash on a bad -j input
Aug 30, 2020
364b7c7
[ownership] Refactor OwnershipLiveRange and OwnershipPhiOperand into …
gottesmm Aug 28, 2020
76d0648
[AutoDiff] [Sema] Include certain 'let' properties in 'Differentiable…
rxwei Aug 30, 2020
6f9df09
Merge pull request #33701 from davidungar/handle-bad-j
Aug 30, 2020
76a81ef
ASTDemangler: Fix reconstruction of opaque result type defined in a c…
slavapestov Aug 30, 2020
adba0f0
Merge pull request #33702 from gottesmm/pr-03d4e156c1dfdff0133077eb67…
swift-ci Aug 30, 2020
96feb2d
[ownership] Extract out the main visitor SemanticARCOptVisitor from S…
gottesmm Aug 28, 2020
421bce3
Disable lldb tests in macOS nightly toolchain package (67923799)
shahmishal Aug 30, 2020
f8d0fe2
Merge pull request #33703 from slavapestov/fix-opaque-type-decl-in-co…
slavapestov Aug 30, 2020
f326927
CSGen: Infer generic arguments in typed placeholders
AnthonyLatsis Aug 28, 2020
6b1b837
[NFC] CSGen: Tighten up resolveTypeReferenceInExpression
AnthonyLatsis Aug 28, 2020
43574f7
Merge pull request #33705 from gottesmm/pr-beeb1dacb18240fd260f0740c2…
gottesmm Aug 30, 2020
850745a
Merge pull request #33680 from AnthonyLatsis/unbound-placeholder
AnthonyLatsis Aug 30, 2020
88e26c0
[NFC] Correcting minor typo on a CSDiagnostics comment
LucianoPAlmeida Aug 31, 2020
8bbffac
Merge pull request #33708 from LucianoPAlmeida/minor-typo
LucianoPAlmeida Aug 31, 2020
294bde9
Documentation fix: remainder matches sign of lhs, not rhs.
stephentyrone Aug 31, 2020
f89dbd3
Merge pull request #33711 from stephentyrone/remainder-sign
swift-ci Aug 31, 2020
816b555
Merge pull request #33695 from nathawes/fix-typo
Aug 31, 2020
9da1d89
Manually merge remote-tracking branch 'upstream/master' into HEAD
Aug 31, 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
13 changes: 13 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace swift {
class BoundGenericType;
class ClangModuleLoader;
class ClangNode;
class ClangTypeConverter;
class ConcreteDeclRef;
class ConstructorDecl;
class Decl;
Expand Down Expand Up @@ -586,6 +587,10 @@ class ASTContext final {
Type getBridgedToObjC(const DeclContext *dc, Type type,
Type *bridgedValueType = nullptr) const;

private:
ClangTypeConverter &getClangTypeConverter();

public:
/// Get the Clang type corresponding to a Swift function type.
///
/// \param params The function parameters.
Expand All @@ -595,6 +600,14 @@ class ASTContext final {
getClangFunctionType(ArrayRef<AnyFunctionType::Param> params, Type resultTy,
FunctionTypeRepresentation trueRep);

/// Get the canonical Clang type corresponding to a SIL function type.
///
/// SIL analog of \c ASTContext::getClangFunctionType .
const clang::Type *
getCanonicalClangFunctionType(
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
SILFunctionType::Representation trueRep);

/// Get the Swift declaration that a Clang declaration was exported from,
/// if applicable.
const Decl *getSwiftDeclForExportedClangDecl(const clang::Decl *decl);
Expand Down
14 changes: 12 additions & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace swift {
class Type;
class Expr;
class DeclRefExpr;
class ForeignAsyncConvention;
class ForeignErrorConvention;
class LiteralExpr;
class BraceStmt;
Expand Down Expand Up @@ -6148,7 +6149,15 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// being dropped altogether. `None` is returned for a normal function
/// or method.
Optional<int> getForeignFunctionAsMethodSelfParameterIndex() const;


/// Set information about the foreign async convention used by this
/// declaration.
void setForeignAsyncConvention(const ForeignAsyncConvention &convention);

/// Get information about the foreign async convention used by this
/// declaration, given that it is @objc and 'async'.
Optional<ForeignAsyncConvention> getForeignAsyncConvention() const;

static bool classof(const Decl *D) {
return D->getKind() >= DeclKind::First_AbstractFunctionDecl &&
D->getKind() <= DeclKind::Last_AbstractFunctionDecl;
Expand Down Expand Up @@ -6277,7 +6286,8 @@ class FuncDecl : public AbstractFunctionDecl {
DeclContext *Parent);

static FuncDecl *createImported(ASTContext &Context, SourceLoc FuncLoc,
DeclName Name, SourceLoc NameLoc, bool Throws,
DeclName Name, SourceLoc NameLoc,
bool Async, bool Throws,
ParameterList *BodyParams, Type FnRetType,
DeclContext *Parent, ClangNode ClangN);

Expand Down
14 changes: 14 additions & 0 deletions include/swift/AST/DiagnosticsCommon.def
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,19 @@ ERROR(scanner_find_cycle, none,
ERROR(scanner_arguments_invalid, none,
"dependencies scanner cannot be configured with arguments: '%0'", (StringRef))

//------------------------------------------------------------------------------
// MARK: custom attribute diagnostics
//------------------------------------------------------------------------------

ERROR(ambiguous_custom_attribute_ref,none,
"ambiguous use of attribute %0", (Identifier))
NOTE(ambiguous_custom_attribute_ref_fix,none,
"use '%0.' to reference the attribute %1 in module %2",
(StringRef, Identifier, Identifier))
NOTE(found_attribute_candidate,none,
"found this attribute", ())
ERROR(unknown_attribute,none,
"unknown attribute '%0'", (StringRef))

#define UNDEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,6 @@ ERROR(replace_equal_with_colon_for_value,none,
"'=' has been replaced with ':' in attribute arguments", ())
ERROR(expected_attribute_name,none,
"expected an attribute name", ())
ERROR(unknown_attribute,none,
"unknown attribute '%0'", (StringRef))
ERROR(unexpected_lparen_in_attribute,none,
"unexpected '(' in attribute '%0'", (StringRef))
ERROR(duplicate_attribute,none,
Expand Down
7 changes: 4 additions & 3 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2823,15 +2823,16 @@ WARNING(differentiable_nondiff_type_implicit_noderivative_fixit,none,
/*nominalCanDeriveAdditiveArithmetic*/ bool))
WARNING(differentiable_immutable_wrapper_implicit_noderivative_fixit,none,
"synthesis of the 'Differentiable.move(along:)' requirement for %1 "
"requires 'wrappedValue' in property wrapper %0 to be mutable; "
"add an explicit '@noDerivative' attribute"
"requires 'wrappedValue' in property wrapper %0 to be mutable or have a "
"non-mutating 'move(along:)'; add an explicit '@noDerivative' attribute"
"%select{|, or conform %1 to 'AdditiveArithmetic'}2",
(/*wrapperType*/ Identifier, /*nominalName*/ Identifier,
/*nominalCanDeriveAdditiveArithmetic*/ bool))
WARNING(differentiable_let_property_implicit_noderivative_fixit,none,
"synthesis of the 'Differentiable.move(along:)' requirement for %0 "
"requires all stored properties not marked with `@noDerivative` to be "
"mutable; use 'var' instead, or add an explicit '@noDerivative' attribute"
"mutable or have a non-mutating 'move(along:)'; use 'var' instead, or "
"add an explicit '@noDerivative' attribute "
"%select{|, or conform %0 to 'AdditiveArithmetic'}1",
(/*nominalName*/ Identifier, /*nominalCanDeriveAdditiveArithmetic*/ bool))

Expand Down
55 changes: 25 additions & 30 deletions include/swift/AST/ExtInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,8 @@ class ASTExtInfoBuilder {

using Representation = FunctionTypeRepresentation;

static void assertIsFunctionType(const clang::Type *);

ASTExtInfoBuilder(unsigned bits, ClangTypeInfo clangTypeInfo)
: bits(bits), clangTypeInfo(clangTypeInfo) {
// TODO: [clang-function-type-serialization] Once we start serializing
// the Clang type, we should also assert that the pointer is non-null.
auto Rep = Representation(bits & RepresentationMask);
if ((Rep == Representation::CFunctionPointer) && clangTypeInfo.type)
assertIsFunctionType(clangTypeInfo.type);
}
: bits(bits), clangTypeInfo(clangTypeInfo) {}

public:
// Constructor with all defaults.
Expand Down Expand Up @@ -255,10 +247,7 @@ class ASTExtInfoBuilder {
DifferentiabilityKind::NonDifferentiable;
}

/// Get the underlying ClangTypeInfo value if it is not the default value.
Optional<ClangTypeInfo> getClangTypeInfo() const {
return clangTypeInfo.empty() ? Optional<ClangTypeInfo>() : clangTypeInfo;
}
ClangTypeInfo getClangTypeInfo() const { return clangTypeInfo; }

constexpr SILFunctionTypeRepresentation getSILRepresentation() const {
unsigned rawRep = bits & RepresentationMask;
Expand Down Expand Up @@ -405,9 +394,7 @@ class ASTExtInfo {

constexpr bool isDifferentiable() const { return builder.isDifferentiable(); }

Optional<ClangTypeInfo> getClangTypeInfo() const {
return builder.getClangTypeInfo();
}
ClangTypeInfo getClangTypeInfo() const { return builder.getClangTypeInfo(); }

constexpr bool hasSelfParam() const { return builder.hasSelfParam(); }

Expand Down Expand Up @@ -519,20 +506,32 @@ class SILExtInfoBuilder {
SILExtInfoBuilder(unsigned bits, ClangTypeInfo clangTypeInfo)
: bits(bits), clangTypeInfo(clangTypeInfo) {}

static constexpr unsigned makeBits(Representation rep, bool isPseudogeneric,
bool isNoEscape, bool isAsync,
DifferentiabilityKind diffKind) {
return ((unsigned)rep) | (isPseudogeneric ? PseudogenericMask : 0) |
(isNoEscape ? NoEscapeMask : 0) | (isAsync ? AsyncMask : 0) |
(((unsigned)diffKind << DifferentiabilityMaskOffset) &
DifferentiabilityMask);
}

public:
// Constructor with all defaults.
SILExtInfoBuilder() : bits(0), clangTypeInfo(ClangTypeInfo(nullptr)) {}
SILExtInfoBuilder() : SILExtInfoBuilder(0, ClangTypeInfo(nullptr)) {}

// Constructor for polymorphic type.
SILExtInfoBuilder(Representation rep, bool isPseudogeneric, bool isNoEscape,
bool isAsync, DifferentiabilityKind diffKind,
const clang::Type *type)
: SILExtInfoBuilder(
((unsigned)rep) | (isPseudogeneric ? PseudogenericMask : 0) |
(isNoEscape ? NoEscapeMask : 0) | (isAsync ? AsyncMask : 0) |
(((unsigned)diffKind << DifferentiabilityMaskOffset) &
DifferentiabilityMask),
ClangTypeInfo(type)) {}
: SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape, isAsync,
diffKind),
ClangTypeInfo(type)) {}

SILExtInfoBuilder(ASTExtInfoBuilder info, bool isPseudogeneric)
: SILExtInfoBuilder(makeBits(info.getSILRepresentation(), isPseudogeneric,
info.isNoEscape(), info.isAsync(),
info.getDifferentiabilityKind()),
info.getClangTypeInfo()) {}

void checkInvariants() const;

Expand Down Expand Up @@ -567,10 +566,8 @@ class SILExtInfoBuilder {
DifferentiabilityKind::NonDifferentiable;
}

/// Get the underlying ClangTypeInfo value if it is not the default value.
Optional<ClangTypeInfo> getClangTypeInfo() const {
return clangTypeInfo.empty() ? Optional<ClangTypeInfo>() : clangTypeInfo;
}
/// Get the underlying ClangTypeInfo value.
ClangTypeInfo getClangTypeInfo() const { return clangTypeInfo; }

constexpr bool hasSelfParam() const {
switch (getRepresentation()) {
Expand Down Expand Up @@ -698,9 +695,7 @@ class SILExtInfo {

constexpr bool isDifferentiable() const { return builder.isDifferentiable(); }

Optional<ClangTypeInfo> getClangTypeInfo() const {
return builder.getClangTypeInfo();
}
ClangTypeInfo getClangTypeInfo() const { return builder.getClangTypeInfo(); }

constexpr bool hasSelfParam() const { return builder.hasSelfParam(); }

Expand Down
81 changes: 81 additions & 0 deletions include/swift/AST/ForeignAsyncConvention.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//===--- ForeignAsyncConvention.h - Async conventions -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the ForeignAsyncConvention structure, which
// describes the rules for how to detect that a foreign API is asynchronous.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_FOREIGN_ASYNC_CONVENTION_H
#define SWIFT_FOREIGN_ASYNC_CONVENTION_H

#include "swift/AST/Type.h"

namespace swift {

/// A small structure describing the async convention of a foreign declaration.
class ForeignAsyncConvention {
/// The index of the completion handler parameters.
unsigned CompletionHandlerParamIndex;

/// When non-zero, indicates which parameter to the completion handler is the
/// Error? parameter (minus one) that makes this async function also throwing.
unsigned CompletionHandlerErrorParamIndex;
public:
ForeignAsyncConvention()
: CompletionHandlerParamIndex(0), CompletionHandlerErrorParamIndex(0) { }

ForeignAsyncConvention(unsigned completionHandlerParamIndex,
Optional<unsigned> completionHandlerErrorParamIndex)
: CompletionHandlerParamIndex(completionHandlerParamIndex),
CompletionHandlerErrorParamIndex(
completionHandlerErrorParamIndex
? *completionHandlerErrorParamIndex + 1
: 0) {}

/// Retrieve the index of the completion handler parameter, which will be
/// erased from the Swift signature of the imported async function.
unsigned completionHandlerParamIndex() const {
return CompletionHandlerParamIndex;
}

/// Retrieve the index of the \c Error? parameter in the completion handler's
/// parameter list. When argument passed to this parameter is non-null, the
/// provided error will be thrown by the async function.
Optional<unsigned> completionHandlerErrorParamIndex() const {
if (CompletionHandlerErrorParamIndex == 0)
return None;

return CompletionHandlerErrorParamIndex - 1;
}

/// Whether the async function is throwing due to the completion handler
/// having an \c Error? parameter.
///
/// Equivalent to \c static_cast<bool>(completionHandlerErrorParamIndex()).
bool isThrowing() const {
return CompletionHandlerErrorParamIndex != 0;
}

bool operator==(ForeignAsyncConvention other) const {
return CompletionHandlerParamIndex == other.CompletionHandlerParamIndex
&& CompletionHandlerErrorParamIndex ==
other.CompletionHandlerErrorParamIndex;
}
bool operator!=(ForeignAsyncConvention other) const {
return !(*this == other);
}
};

}

#endif
23 changes: 20 additions & 3 deletions include/swift/AST/ForeignErrorConvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class ForeignErrorConvention {
}

Info() = default;

Kind getKind() const {
return static_cast<Kind>(TheKind);
}
};

private:
Expand Down Expand Up @@ -178,11 +182,24 @@ class ForeignErrorConvention {
/// Returns the physical result type of the function, for functions
/// that completely erase this information.
CanType getResultType() const {
assert(getKind() == ZeroResult ||
getKind() == NonZeroResult);
assert(resultTypeErasedToVoid(getKind()));
return ResultType;
}


/// Whether this kind of error import erases the result type to 'Void'.
static bool resultTypeErasedToVoid(Kind kind) {
switch (kind) {
case ZeroResult:
case NonZeroResult:
return true;

case ZeroPreservedResult:
case NilResult:
case NonNilError:
return false;
}
}

bool operator==(ForeignErrorConvention other) const {
return info.TheKind == other.info.TheKind
&& info.ErrorIsOwned == other.info.ErrorIsOwned
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ class AnyFunctionType : public TypeBase {
unsigned NumParams, ExtInfo Info)
: TypeBase(Kind, CanTypeContext, properties), Output(Output) {
Bits.AnyFunctionType.ExtInfoBits = Info.getBits();
Bits.AnyFunctionType.HasClangTypeInfo = Info.getClangTypeInfo().hasValue();
Bits.AnyFunctionType.HasClangTypeInfo = !Info.getClangTypeInfo().empty();
Bits.AnyFunctionType.NumParams = NumParams;
assert(Bits.AnyFunctionType.NumParams == NumParams && "Params dropped!");
// The use of both assert() and static_assert() is intentional.
Expand Down
Loading