Skip to content

Commit 2f4ee5f

Browse files
Merge pull request #5391 from swiftwasm/main
[pull] swiftwasm from main
2 parents bde203a + 49e50a5 commit 2f4ee5f

File tree

136 files changed

+2335
-779
lines changed

Some content is hidden

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

136 files changed

+2335
-779
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
610610
"Enable build of the Swift concurrency module"
611611
FALSE)
612612

613+
option(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP
614+
"Enable experimental C++ interop modules"
615+
FALSE)
616+
613617
option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
614618
"Enable experimental distributed actors and functions"
615619
FALSE)

include/swift/AST/Decl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5742,6 +5742,16 @@ class VarDecl : public AbstractStorageDecl {
57425742
return false;
57435743
}
57445744

5745+
/// Return the initializer that will initializer this VarDecl at runtime.
5746+
/// This is equivalent to `getParentInitializer()`, but returns `null` if the
5747+
/// initializer itself was subsumed, e.g., by a macro or property wrapper.
5748+
Expr *getParentExecutableInitializer() const;
5749+
5750+
/// Whether this variable has an initializer that will be code-generated.
5751+
bool isParentExecutabledInitialized() const {
5752+
return getParentExecutableInitializer() != nullptr;
5753+
}
5754+
57455755
// Return whether this VarDecl has an initial value, either by checking
57465756
// if it has an initializer in its parent pattern binding or if it has
57475757
// the @_hasInitialValue attribute.

include/swift/AST/DiagnosticsCommon.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ ERROR(unknown_attribute,none,
223223
NOTE(in_macro_expansion,none,
224224
"in expansion of macro %0 here", (DeclName))
225225
ERROR(macro_experimental,none,
226-
"%0 macros are an experimental feature that is not enabled (%1)",
226+
"%0 macros are an experimental feature that is not enabled %select{|(%1)}1",
227227
(StringRef, StringRef))
228228
ERROR(ambiguous_macro_reference,none,
229229
"ambiguous reference to macro %0", (DeclName))

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ ERROR(operator_decl_no_fixity,none,
461461
"operator must be declared as 'prefix', 'postfix', or 'infix'", ())
462462
ERROR(operator_decl_expected_precedencegroup, none,
463463
"expected precedence group name after ':' in operator declaration", ())
464-
464+
ERROR(operator_decl_should_not_contain_other_attributes, none,
465+
"unexpected attribute %0 in operator declaration", (StringRef))
465466
WARNING(operator_decl_remove_designated_types,none,
466467
"designated types are no longer used by the compiler; please remove "
467468
"the designated type list from this operator declaration", ())

include/swift/AST/MacroDeclaration.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ enum class MacroRole: uint32_t {
5858
/// A freestanding macro that expands to expressions, statements and
5959
/// declarations in a code block.
6060
CodeItem = 0x80,
61+
62+
// NOTE: When adding a new macro role, also add it to `getAllMacroRoles`.
6163
};
6264

65+
/// Returns an enumeratable list of all macro roles.
66+
std::vector<MacroRole> getAllMacroRoles();
67+
6368
/// The contexts in which a particular macro declaration can be used.
6469
using MacroRoles = OptionSet<MacroRole>;
6570

@@ -83,6 +88,9 @@ bool isAttachedMacro(MacroRoles contexts);
8388

8489
MacroRoles getAttachedMacroRoles();
8590

91+
/// Checks if the macro is supported or guarded behind an experimental flag.
92+
bool isMacroSupported(MacroRole role, ASTContext &ctx);
93+
8694
enum class MacroIntroducedDeclNameKind {
8795
Named,
8896
Overloaded,

include/swift/AST/MacroDiscriminatorContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ struct MacroDiscriminatorContext
3131
static MacroDiscriminatorContext getParentOf(
3232
SourceLoc loc, DeclContext *origDC
3333
);
34+
35+
/// Return the innermost declaration context that is suitable for
36+
/// use in identifying a macro.
37+
static DeclContext *getInnermostMacroContext(DeclContext *dc);
3438
};
3539

3640
}

include/swift/AST/SourceFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class SourceFile final : public FileUnit {
496496
collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const override;
497497

498498
Identifier getDiscriminatorForPrivateDecl(const Decl *D) const override;
499-
Identifier getPrivateDiscriminator() const { return PrivateDiscriminator; }
499+
Identifier getPrivateDiscriminator(bool createIfMissing = false) const;
500500
Optional<ExternalSourceLocs::RawLocs>
501501
getExternalRawLocsForDecl(const Decl *D) const override;
502502

include/swift/AST/TypeCheckRequests.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,6 +3930,26 @@ class ExpandMacroExpansionDeclRequest
39303930
void noteCycleStep(DiagnosticEngine &diags) const;
39313931
};
39323932

3933+
/// Expand a 'MacroExpansionExpr',
3934+
class ExpandMacroExpansionExprRequest
3935+
: public SimpleRequest<ExpandMacroExpansionExprRequest,
3936+
Optional<unsigned>(MacroExpansionExpr *),
3937+
RequestFlags::Cached> {
3938+
public:
3939+
using SimpleRequest::SimpleRequest;
3940+
3941+
private:
3942+
friend SimpleRequest;
3943+
3944+
Optional<unsigned>
3945+
evaluate(Evaluator &evaluator, MacroExpansionExpr *mee) const;
3946+
3947+
public:
3948+
bool isCached() const { return true; }
3949+
void diagnoseCycle(DiagnosticEngine &diags) const;
3950+
void noteCycleStep(DiagnosticEngine &diags) const;
3951+
};
3952+
39333953
/// Expand all accessor macros attached to the given declaration.
39343954
///
39353955
/// Produces the set of macro expansion buffer IDs.

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ SWIFT_REQUEST(TypeChecker, ExternalMacroDefinitionRequest,
439439
SWIFT_REQUEST(TypeChecker, ExpandMacroExpansionDeclRequest,
440440
ArrayRef<Decl *>(MacroExpansionDecl *),
441441
Cached, NoLocationInfo)
442+
SWIFT_REQUEST(TypeChecker, ExpandMacroExpansionExprRequest,
443+
ArrayRef<Decl *>(MacroExpansionExpr *),
444+
Cached, NoLocationInfo)
442445
SWIFT_REQUEST(TypeChecker, ExpandMemberAttributeMacros,
443446
ArrayRef<unsigned>(Decl *),
444447
Cached, NoLocationInfo)

include/swift/Frontend/ModuleInterfaceSupport.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define SWIFT_COMPILER_VERSION_KEY "swift-compiler-version"
2222
#define SWIFT_MODULE_FLAGS_KEY "swift-module-flags"
2323
#define SWIFT_MODULE_FLAGS_IGNORABLE_KEY "swift-module-flags-ignorable"
24+
#define SWIFT_MODULE_FLAGS_IGNORABLE_PRIVATE_KEY "swift-module-flags-ignorable-private"
2425

2526
namespace swift {
2627

@@ -50,6 +51,10 @@ struct ModuleInterfaceOptions {
5051
/// ignored by the earlier version of the compiler.
5152
std::string IgnorableFlags;
5253

54+
/// Ignorable flags that should only be printed in .private.swiftinterface file;
55+
/// e.g. -package-name PACKAGE_ID
56+
std::string IgnorablePrivateFlags;
57+
5358
/// Print for a private swiftinterface file, SPI decls and attributes.
5459
bool PrintPrivateInterfaceContent = false;
5560

0 commit comments

Comments
 (0)