Skip to content

Commit c9171c1

Browse files
Merge pull request #5450 from swiftwasm/main
[pull] swiftwasm from main
2 parents 0c6f630 + 580d501 commit c9171c1

File tree

120 files changed

+2922
-598
lines changed

Some content is hidden

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

120 files changed

+2922
-598
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
/lib/ClangImporter/DWARFImporter* @adrian-prantl
9797
/lib/DependencyScan @artemcm
9898
/lib/Driver @artemcm
99+
/lib/DriverTool/autolink_extract_main.cpp @MaxDesiatov @etcwilde
99100
/lib/DriverTool/swift_symbolgraph_extract_main.cpp @QuietMisdreavus
100101
/lib/Frontend/*ModuleInterface* @artemcm @tshortli
101102
# TODO: /lib/IRGen/
@@ -149,6 +150,7 @@
149150
/test/DebugInfo/ @adrian-prantl
150151
/test/Distributed/ @ktoso
151152
/test/Driver/ @artemcm
153+
/test/Driver/static* @MaxDesiatov @etcwilde
152154
/test/Generics/ @hborla @slavapestov
153155
# TODO: /test/IRGen/
154156
/test/IDE/ @ahoppen @bnbarham @rintaro

docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ Entities
399399
macro-discriminator-list ::= macro-discriminator-list? file-discriminator? macro-expansion-operator INDEX
400400

401401
macro-expansion-operator ::= decl-name identifier 'fMa' // attached accessor macro
402-
macro-expansion-operator ::= decl-name identifier 'fMA' // attached member-attribute macro
402+
macro-expansion-operator ::= decl-name identifier 'fMr' // attached member-attribute macro
403403
macro-expansion-operator ::= identifier 'fMf' // freestanding macro
404404
macro-expansion-operator ::= decl-name identifier 'fMm' // attached member macro
405405
macro-expansion-operator ::= decl-name identifier 'fMp' // attached peer macro

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,39 +1501,6 @@ class ASTContext final {
15011501
/// Get the plugin loader.
15021502
PluginLoader &getPluginLoader();
15031503

1504-
/// Lookup a library plugin that can handle \p moduleName and return the path
1505-
/// to it.
1506-
/// The path is valid within the VFS, use `FS.getRealPath()` for the
1507-
/// underlying path.
1508-
Optional<std::string> lookupLibraryPluginByModuleName(Identifier moduleName);
1509-
1510-
/// Load the specified dylib plugin path resolving the path with the
1511-
/// current VFS. If it fails to load the plugin, a diagnostic is emitted, and
1512-
/// returns a nullptr.
1513-
/// NOTE: This method is idempotent. If the plugin is already loaded, the same
1514-
/// instance is simply returned.
1515-
LoadedLibraryPlugin *loadLibraryPlugin(StringRef path);
1516-
1517-
/// Lookup an executable plugin that is declared to handle \p moduleName
1518-
/// module by '-load-plugin-executable'.
1519-
/// The path is valid within the VFS, use `FS.getRealPath()` for the
1520-
/// underlying path.
1521-
Optional<StringRef> lookupExecutablePluginByModuleName(Identifier moduleName);
1522-
1523-
/// Look for dynamic libraries in paths from `-external-plugin-path` and
1524-
/// return a pair of `(library path, plugin server executable)` if found.
1525-
/// These paths are valid within the VFS, use `FS.getRealPath()` for their
1526-
/// underlying path.
1527-
Optional<std::pair<std::string, std::string>>
1528-
lookupExternalLibraryPluginByModuleName(Identifier moduleName);
1529-
1530-
/// Launch the specified executable plugin path resolving the path with the
1531-
/// current VFS. If it fails to load the plugin, a diagnostic is emitted, and
1532-
/// returns a nullptr.
1533-
/// NOTE: This method is idempotent. If the plugin is already loaded, the same
1534-
/// instance is simply returned.
1535-
LoadedExecutablePlugin *loadExecutablePlugin(StringRef path);
1536-
15371504
/// Get the output backend. The output backend needs to be initialized via
15381505
/// constructor or `setOutputBackend`.
15391506
llvm::vfs::OutputBackend &getOutputBackend() const {

include/swift/AST/DiagnosticsParse.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,8 @@ ERROR(expected_expr_after_await, none,
13861386
"expected expression after 'await'", ())
13871387
ERROR(expected_expr_after_move, none,
13881388
"expected expression after 'consume'", ())
1389+
ERROR(expected_expr_after_copy, none,
1390+
"expected expression after 'copy'", ())
13891391
ERROR(expected_expr_after_borrow, none,
13901392
"expected expression after '_borrow'", ())
13911393

@@ -2057,6 +2059,8 @@ ERROR(macro_expansion_expr_expected_macro_identifier,PointsToFirstBadToken,
20572059
"expected a macro identifier for a pound literal expression", ())
20582060
ERROR(macro_expansion_decl_expected_macro_identifier,PointsToFirstBadToken,
20592061
"expected a macro identifier for a pound literal declaration", ())
2062+
ERROR(extra_whitespace_macro_expansion_identifier,PointsToFirstBadToken,
2063+
"extraneous whitespace between '#' and macro name is not permitted", ())
20602064

20612065
ERROR(macro_role_attr_expected_kind,PointsToFirstBadToken,
20622066
"expected %select{a freestanding|an attached}0 macro role such as "

include/swift/AST/DiagnosticsSema.def

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,27 @@ ERROR(need_hermetic_seal_to_import_module,none,
872872
"current compilation does not have -experimental-hermetic-seal-at-link",
873873
(Identifier))
874874

875+
ERROR(modularization_issue_decl_moved,Fatal,
876+
"reference to %select{top-level|type}0 %1 broken by a context change; "
877+
"%1 was expected to be in %2, but now a candidate is found only in %3",
878+
(bool, DeclName, Identifier, Identifier))
879+
ERROR(modularization_issue_decl_type_changed,Fatal,
880+
"reference to %select{top-level|type}0 %1 broken by a context change; "
881+
"the details of %1 %select{from %2|}5 changed since building '%3'"
882+
"%select{|, it was in %2 and is now found in %4}5",
883+
(bool, DeclName, Identifier, StringRef, Identifier, bool))
884+
ERROR(modularization_issue_decl_not_found,Fatal,
885+
"reference to %select{top-level|type}0 %1 broken by a context change; "
886+
"%1 is not found, it was expected to be in %2",
887+
(bool, DeclName, Identifier))
888+
889+
NOTE(modularization_issue_side_effect_extension_error,none,
890+
"could not deserialize extension",
891+
())
892+
NOTE(modularization_issue_side_effect_type_error,none,
893+
"could not deserialize type for %0",
894+
(DeclName))
895+
875896
ERROR(reserved_member_name,none,
876897
"type member must not be named %0, since it would conflict with the"
877898
" 'foo.%1' expression", (DeclName, StringRef))
@@ -6992,10 +7013,14 @@ ERROR(concurrency_task_to_thread_model_global_actor_annotation,none,
69927013

69937014
ERROR(moveOnly_not_allowed_here,none,
69947015
"'moveOnly' only applies to structs or enums", ())
6995-
ERROR(move_expression_not_passed_lvalue,none,
7016+
ERROR(consume_expression_not_passed_lvalue,none,
69967017
"'consume' can only be applied to lvalues", ())
69977018
ERROR(borrow_expression_not_passed_lvalue,none,
69987019
"'borrow' can only be applied to lvalues", ())
7020+
ERROR(copy_expression_not_passed_lvalue,none,
7021+
"'copy' can only be applied to lvalues", ())
7022+
ERROR(copy_expression_cannot_be_used_with_noncopyable_types,none,
7023+
"'copy' cannot be applied to noncopyable types", ())
69997024

70007025
ERROR(moveOnly_requires_lexical_lifetimes,none,
70017026
"noncopyable types require lexical borrow scopes "

include/swift/AST/Expr.h

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,31 +2050,61 @@ class AwaitExpr final : public IdentityExpr {
20502050
}
20512051
};
20522052

2053-
/// MoveExpr - A 'move' surrounding an lvalue expression marking the lvalue as
2054-
/// needing to be moved.
2055-
///
2056-
/// getSemanticsProvidingExpr() looks through this because it doesn't
2057-
/// provide the value and only very specific clients care where the
2058-
/// 'move' was written.
2059-
class MoveExpr final : public IdentityExpr {
2060-
SourceLoc MoveLoc;
2053+
/// ConsumeExpr - A 'consume' surrounding an lvalue expression marking the
2054+
/// lvalue as needing to be moved.
2055+
class ConsumeExpr final : public Expr {
2056+
Expr *SubExpr;
2057+
SourceLoc ConsumeLoc;
20612058

20622059
public:
2063-
MoveExpr(SourceLoc moveLoc, Expr *sub, Type type = Type(),
2060+
ConsumeExpr(SourceLoc consumeLoc, Expr *sub, Type type = Type(),
2061+
bool implicit = false)
2062+
: Expr(ExprKind::Consume, implicit, type), SubExpr(sub),
2063+
ConsumeLoc(consumeLoc) {}
2064+
2065+
static ConsumeExpr *createImplicit(ASTContext &ctx, SourceLoc moveLoc,
2066+
Expr *sub, Type type = Type()) {
2067+
return new (ctx) ConsumeExpr(moveLoc, sub, type, /*implicit=*/true);
2068+
}
2069+
2070+
SourceLoc getLoc() const { return ConsumeLoc; }
2071+
2072+
Expr *getSubExpr() const { return SubExpr; }
2073+
void setSubExpr(Expr *E) { SubExpr = E; }
2074+
2075+
SourceLoc getStartLoc() const { return getLoc(); }
2076+
SourceLoc getEndLoc() const { return getSubExpr()->getEndLoc(); }
2077+
2078+
static bool classof(const Expr *e) {
2079+
return e->getKind() == ExprKind::Consume;
2080+
}
2081+
};
2082+
2083+
/// CopyExpr - A 'copy' surrounding an lvalue expression marking the lvalue as
2084+
/// needing a semantic copy. Used to force a copy of a no implicit copy type.
2085+
class CopyExpr final : public Expr {
2086+
Expr *SubExpr;
2087+
SourceLoc CopyLoc;
2088+
2089+
public:
2090+
CopyExpr(SourceLoc copyLoc, Expr *sub, Type type = Type(),
20642091
bool implicit = false)
2065-
: IdentityExpr(ExprKind::Move, sub, type, implicit), MoveLoc(moveLoc) {}
2092+
: Expr(ExprKind::Copy, implicit, type), SubExpr(sub), CopyLoc(copyLoc) {}
20662093

2067-
static MoveExpr *createImplicit(ASTContext &ctx, SourceLoc moveLoc, Expr *sub,
2094+
static CopyExpr *createImplicit(ASTContext &ctx, SourceLoc copyLoc, Expr *sub,
20682095
Type type = Type()) {
2069-
return new (ctx) MoveExpr(moveLoc, sub, type, /*implicit=*/true);
2096+
return new (ctx) CopyExpr(copyLoc, sub, type, /*implicit=*/true);
20702097
}
20712098

2072-
SourceLoc getLoc() const { return MoveLoc; }
2099+
SourceLoc getLoc() const { return CopyLoc; }
2100+
2101+
Expr *getSubExpr() const { return SubExpr; }
2102+
void setSubExpr(Expr *E) { SubExpr = E; }
20732103

2074-
SourceLoc getStartLoc() const { return MoveLoc; }
2104+
SourceLoc getStartLoc() const { return CopyLoc; }
20752105
SourceLoc getEndLoc() const { return getSubExpr()->getEndLoc(); }
20762106

2077-
static bool classof(const Expr *e) { return e->getKind() == ExprKind::Move; }
2107+
static bool classof(const Expr *e) { return e->getKind() == ExprKind::Copy; }
20782108
};
20792109

20802110
/// BorrowExpr - A 'borrow' surrounding an lvalue/accessor expression at an

include/swift/AST/ExprNodes.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ ABSTRACT_EXPR(Identity, Expr)
107107
EXPR(Paren, IdentityExpr)
108108
EXPR(DotSelf, IdentityExpr)
109109
EXPR(Await, IdentityExpr)
110-
EXPR(Move, IdentityExpr)
111110
EXPR(Borrow, IdentityExpr)
112111
EXPR(UnresolvedMemberChainResult, IdentityExpr)
113112
EXPR_RANGE(Identity, Paren, UnresolvedMemberChainResult)
113+
EXPR(Copy, Expr)
114+
EXPR(Consume, Expr)
114115
ABSTRACT_EXPR(AnyTry, Expr)
115116
EXPR(Try, AnyTryExpr)
116117
EXPR(ForceTry, AnyTryExpr)

include/swift/AST/GenericSignature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
360360
/// Determine whether the given dependent type is required to be a class.
361361
bool requiresClass(Type type) const;
362362

363+
Type getUpperBound(Type type, bool wantDependentUpperBound = false) const;
364+
363365
/// Determine the superclass bound on the given dependent type.
364366
Type getSuperclassBound(Type type) const;
365367

include/swift/AST/PluginLoader.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ class PluginLoader {
5353
PluginRegistry *getRegistry();
5454

5555
/// Lookup a library plugin that can handle \p moduleName and return the path
56-
/// to it from `-plugin-path` or `-load-plugin-library`.
56+
/// to it from `-load-plugin-library`.
5757
/// The path returned can be loaded by 'loadLibraryPlugin' method.
5858
llvm::Optional<std::string>
59-
lookupLibraryPluginByModuleName(Identifier moduleName);
59+
lookupExplicitLibraryPluginByModuleName(Identifier moduleName);
60+
61+
/// Lookup a library plugin that can handle \p moduleName and return the path
62+
/// to it from `-plugin-path`.
63+
/// The path returned can be loaded by 'loadLibraryPlugin' method.
64+
llvm::Optional<std::string>
65+
lookupLibraryPluginInSearchPathByModuleName(Identifier moduleName);
6066

6167
/// Lookup an executable plugin that is declared to handle \p moduleName
6268
/// module by '-load-plugin-executable'.

include/swift/ClangImporter/ClangImporter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ class ClangImporter final : public ClangModuleLoader {
404404
/// if we need to persist a PCH for later reuse.
405405
bool canReadPCH(StringRef PCHFilename);
406406

407+
/// Reads the original source file name from PCH.
408+
std::string getOriginalSourceFile(StringRef PCHFilename);
409+
407410
/// Makes a temporary replica of the ClangImporter's CompilerInstance, reads a
408411
/// module map into the replica and emits a PCM file for one of the modules it
409412
/// declares. Delegates to clang for everything except construction of the

0 commit comments

Comments
 (0)