Skip to content

Commit e0663cc

Browse files
Merge pull request #5200 from swiftwasm/main
[pull] swiftwasm from main
2 parents 3b8360d + 4eefefa commit e0663cc

Some content is hidden

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

46 files changed

+616
-416
lines changed

include/swift/AST/Attr.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,55 +2613,6 @@ class DeclAttributes {
26132613
SourceLoc getStartLoc(bool forModifiers = false) const;
26142614
};
26152615

2616-
/// Semantic attributes that are applied to a declaration.
2617-
///
2618-
/// This attribute list can include attributes that are not written in
2619-
/// source on a declaration, such as attributes that are applied during
2620-
/// macro expansion or inferred from the declaration context.
2621-
class SemanticDeclAttributes {
2622-
llvm::SmallVector<DeclAttribute *, 4> attrList;
2623-
2624-
public:
2625-
SemanticDeclAttributes() {}
2626-
2627-
/// Add a constructed DeclAttribute to this list.
2628-
void add(DeclAttribute *attr) {
2629-
attrList.push_back(attr);
2630-
}
2631-
2632-
using SemanticAttrList = llvm::SmallVectorImpl<DeclAttribute *>;
2633-
2634-
template <typename AttrType, bool AllowInvalid>
2635-
using AttributeKindRange =
2636-
OptionalTransformRange<iterator_range<SemanticAttrList::const_iterator>,
2637-
ToAttributeKind<AttrType, AllowInvalid>,
2638-
SemanticAttrList::const_iterator>;
2639-
2640-
template <typename AttrType, bool AllowInvalid = false>
2641-
AttributeKindRange<AttrType, AllowInvalid> getAttributes() const {
2642-
return AttributeKindRange<AttrType, AllowInvalid>(
2643-
make_range(attrList.begin(), attrList.end()),
2644-
ToAttributeKind<AttrType, AllowInvalid>());
2645-
}
2646-
2647-
/// Retrieve the first attribute of the given attribute class.
2648-
template <typename AttrType>
2649-
const AttrType *getAttribute(bool allowInvalid = false) const {
2650-
for (auto attr : attrList)
2651-
if (auto *specificAttr = dyn_cast<AttrType>(attr))
2652-
if (specificAttr->isValid() || allowInvalid)
2653-
return specificAttr;
2654-
2655-
return nullptr;
2656-
}
2657-
2658-
/// Determine whether there is an attribute with the given attribute class.
2659-
template <typename AttrType>
2660-
bool hasAttribute(bool allowInvalid = false) const {
2661-
return getAttribute<AttrType>(allowInvalid) != nullptr;
2662-
}
2663-
};
2664-
26652616
/// TypeAttributes - These are attributes that may be applied to types.
26662617
class TypeAttributes {
26672618
// Get a SourceLoc for every possible attribute that can be parsed in source.

include/swift/AST/Decl.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
850850
return Attrs;
851851
}
852852

853-
/// Returns the semantic attributes attached to this declaration.
854-
///
855-
/// \c getSemanticAttrs is intended to be a requestified replacement
856-
/// for \c getAttrs
857-
SemanticDeclAttributes getSemanticAttrs() const;
853+
/// Returns the semantic attributes attached to this declaration,
854+
/// including attributes that are generated as the result of member
855+
/// attribute macro expansion.
856+
DeclAttributes getSemanticAttrs() const;
858857

859858
/// Returns the innermost enclosing decl with an availability annotation.
860859
const Decl *getInnermostDeclWithAvailability() const;

include/swift/AST/DiagnosticsSema.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3886,6 +3886,9 @@ ERROR(unresolved_member_no_inference,none,
38863886
(DeclNameRef))
38873887
ERROR(cannot_infer_base_of_unresolved_member,none,
38883888
"cannot infer contextual base in reference to member %0", (DeclNameRef))
3889+
ERROR(cannot_infer_concrete_for_opaque_result,none,
3890+
"cannot infer concrete type for opaque result %0 from return expression",
3891+
(Type))
38893892
ERROR(unresolved_nil_literal,none,
38903893
"'nil' requires a contextual type", ())
38913894
ERROR(cannot_force_unwrap_nil_literal,none,
@@ -5334,6 +5337,12 @@ ERROR(differentiable_function_type_invalid_result,none,
53345337
"%select{| and satisfy '%0 == %0.TangentVector'}1, but the enclosing "
53355338
"function type is '@differentiable%select{|(_linear)}1'",
53365339
(StringRef, bool))
5340+
ERROR(differentiable_function_type_void_result,
5341+
none,
5342+
"'@differentiable' function returning Void must have at least one "
5343+
"differentiable inout parameter, i.e. a non-'@noDerivative' parameter "
5344+
"whose type conforms to 'Differentiable'",
5345+
())
53375346
ERROR(differentiable_function_type_no_differentiability_parameters,
53385347
none,
53395348
"'@differentiable' function type requires at least one differentiability "

include/swift/AST/SourceFile.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ class SourceFile final : public FileUnit {
500500
/// the \c SourceFileKind is \c MacroExpansion.
501501
ASTNode getMacroExpansion() const;
502502

503+
/// For source files created to hold the source code created by expanding
504+
/// an attached macro, this is the custom attribute that describes the macro
505+
/// expansion.
506+
///
507+
/// The source location of this attribute is the place in the source that
508+
/// triggered the creation of the macro expansion whose resulting source
509+
/// code is in this source file. This will only produce a non-null value when
510+
/// the \c SourceFileKind is \c MacroExpansion , and the macro is an attached
511+
/// macro.
512+
CustomAttr *getAttachedMacroAttribute() const;
513+
503514
/// When this source file is enclosed within another source file, for example
504515
/// because it describes a macro expansion, return the source file it was
505516
/// enclosed in.

include/swift/AST/TypeCheckRequests.h

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -742,26 +742,6 @@ class AttachedPropertyWrappersRequest :
742742
bool isCached() const { return true; }
743743
};
744744

745-
/// Request the semantic attributes attached to the given declaration.
746-
class AttachedSemanticAttrsRequest :
747-
public SimpleRequest<AttachedSemanticAttrsRequest,
748-
SemanticDeclAttributes(Decl *),
749-
RequestFlags::Cached> {
750-
public:
751-
using SimpleRequest::SimpleRequest;
752-
753-
private:
754-
friend SimpleRequest;
755-
756-
// Evaluation.
757-
SemanticDeclAttributes
758-
evaluate(Evaluator &evaluator, Decl *decl) const;
759-
760-
public:
761-
// Caching
762-
bool isCached() const { return true; }
763-
};
764-
765745
/// Request the raw (possibly unbound generic) type of the property wrapper
766746
/// that is attached to the given variable.
767747
class AttachedPropertyWrapperTypeRequest :
@@ -3840,6 +3820,24 @@ class ExpandMacroExpansionDeclRequest
38403820
bool isCached() const { return true; }
38413821
};
38423822

3823+
/// Expand all member attribute macros attached to the given
3824+
/// declaration.
3825+
class ExpandMemberAttributeMacros
3826+
: public SimpleRequest<ExpandMemberAttributeMacros,
3827+
bool(Decl *),
3828+
RequestFlags::Cached> {
3829+
public:
3830+
using SimpleRequest::SimpleRequest;
3831+
3832+
private:
3833+
friend SimpleRequest;
3834+
3835+
bool evaluate(Evaluator &evaluator, Decl *decl) const;
3836+
3837+
public:
3838+
bool isCached() const { return true; }
3839+
};
3840+
38433841
/// Resolve an external macro given its module and type name.
38443842
class ExternalMacroDefinitionRequest
38453843
: public SimpleRequest<ExternalMacroDefinitionRequest,

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ SWIFT_REQUEST(TypeChecker, AttachedPropertyWrapperTypeRequest,
2929
SWIFT_REQUEST(TypeChecker, AttachedPropertyWrappersRequest,
3030
llvm::TinyPtrVector<CustomAttr *>(VarDecl *), Cached,
3131
NoLocationInfo)
32-
SWIFT_REQUEST(TypeChecker, AttachedSemanticAttrsRequest,
33-
SemanticDeclAttributes(Decl *), Cached,
34-
NoLocationInfo)
3532
SWIFT_REQUEST(TypeChecker, CallerSideDefaultArgExprRequest,
3633
Expr *(DefaultArgumentExpr *), SeparatelyCached, NoLocationInfo)
3734
SWIFT_REQUEST(TypeChecker, CheckInconsistentImplementationOnlyImportsRequest,
@@ -455,6 +452,9 @@ SWIFT_REQUEST(TypeChecker, ExternalMacroDefinitionRequest,
455452
SWIFT_REQUEST(TypeChecker, ExpandMacroExpansionDeclRequest,
456453
ArrayRef<Decl *>(MacroExpansionDecl *),
457454
Cached, NoLocationInfo)
455+
SWIFT_REQUEST(TypeChecker, ExpandMemberAttributeMacros,
456+
bool(Decl *),
457+
Cached, NoLocationInfo)
458458
SWIFT_REQUEST(TypeChecker, SynthesizeRuntimeMetadataAttrGenerator,
459459
Expr *(CustomAttr *, ValueDecl *),
460460
Cached, NoLocationInfo)

include/swift/Frontend/Frontend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ class CompilerInstance {
559559
/// i.e. if it can be found.
560560
bool canImportSwiftConcurrency() const;
561561

562+
/// Whether the Swift Concurrency Shims support Clang library can be imported
563+
/// i.e. if it can be found.
564+
bool canImportSwiftConcurrencyShims() const;
565+
562566
/// Verify that if an implicit import of the `StringProcessing` module if
563567
/// expected, it can actually be imported. Emit a warning, otherwise.
564568
void verifyImplicitStringProcessingImport();

include/swift/Strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ constexpr static const StringLiteral STDLIB_NAME = "Swift";
2424
constexpr static const StringLiteral SWIFT_ONONE_SUPPORT = "SwiftOnoneSupport";
2525
/// The name of the Concurrency module, which supports that extension.
2626
constexpr static const StringLiteral SWIFT_CONCURRENCY_NAME = "_Concurrency";
27+
/// The name of the Concurrency Shims Clang module
28+
constexpr static const StringLiteral SWIFT_CONCURRENCY_SHIMS_NAME = "_SwiftConcurrencyShims";
2729
/// The name of the Distributed module, which supports that extension.
2830
constexpr static const StringLiteral SWIFT_DISTRIBUTED_NAME = "Distributed";
2931
/// The name of the StringProcessing module, which supports that extension.

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5464,7 +5464,10 @@ Type ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
54645464
*bridgedValueType = type;
54655465

54665466
// Find the Objective-C class type we bridge to.
5467-
return conformance.getTypeWitnessByName(type, Id_ObjectiveCType);
5467+
Type witnessTy = conformance.getTypeWitnessByName(type, Id_ObjectiveCType);
5468+
// If Objective-C import is broken, witness type would be a dependent member
5469+
// with `<<error type>>` base.
5470+
return (witnessTy && !witnessTy->hasError()) ? witnessTy : Type();
54685471
}
54695472

54705473
// Do we conform to Error?

lib/AST/Decl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,13 @@ StringRef Decl::getDescriptiveKindName(DescriptiveDeclKind K) {
365365
llvm_unreachable("bad DescriptiveDeclKind");
366366
}
367367

368-
SemanticDeclAttributes Decl::getSemanticAttrs() const {
368+
DeclAttributes Decl::getSemanticAttrs() const {
369369
auto mutableThis = const_cast<Decl *>(this);
370-
return evaluateOrDefault(getASTContext().evaluator,
371-
AttachedSemanticAttrsRequest{mutableThis},
372-
SemanticDeclAttributes());
370+
evaluateOrDefault(getASTContext().evaluator,
371+
ExpandMemberAttributeMacros{mutableThis},
372+
false);
373+
374+
return getAttrs();
373375
}
374376

375377
const Decl *Decl::getInnermostDeclWithAvailability() const {

0 commit comments

Comments
 (0)