Skip to content

Commit d814844

Browse files
Merge pull request #5531 from swiftwasm/main
[pull] swiftwasm from main
2 parents 1d4395b + d312589 commit d814844

File tree

175 files changed

+4137
-1089
lines changed

Some content is hidden

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

175 files changed

+4137
-1089
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ class ConditionalClauseInitializerScope final : public ASTScopeImpl {
990990
SourceRange
991991
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
992992
std::string getClassName() const override;
993-
bool ignoreInDebugInfo() const override { return true; }
994993

995994
private:
996995
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);

include/swift/AST/Decl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,6 +5317,16 @@ class AbstractStorageDecl : public ValueDecl {
53175317
/// it.
53185318
bool hasStorage() const;
53195319

5320+
/// Return true if this is a VarDecl that has init accessor associated
5321+
/// with it.
5322+
bool hasInitAccessor() const;
5323+
5324+
/// Return true if this is a property that either has storage
5325+
/// or init accessor associated with it.
5326+
bool supportsInitialization() const {
5327+
return hasStorage() || hasInitAccessor();
5328+
}
5329+
53205330
/// Return true if this storage has the basic accessors/capability
53215331
/// to be mutated. This is generally constant after the accessors are
53225332
/// installed by the parser/importer/whatever.

include/swift/AST/DiagnosticEngine.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,22 @@ namespace swift {
14581458
}
14591459
};
14601460

1461+
/// A RAII object that adds and removes a diagnostic consumer from an engine.
1462+
class DiagnosticConsumerRAII final {
1463+
DiagnosticEngine &Diags;
1464+
DiagnosticConsumer &Consumer;
1465+
1466+
public:
1467+
DiagnosticConsumerRAII(DiagnosticEngine &diags,
1468+
DiagnosticConsumer &consumer)
1469+
: Diags(diags), Consumer(consumer) {
1470+
Diags.addConsumer(Consumer);
1471+
}
1472+
~DiagnosticConsumerRAII() {
1473+
Diags.removeConsumer(Consumer);
1474+
}
1475+
};
1476+
14611477
inline void
14621478
DiagnosticEngine::diagnoseWithNotes(InFlightDiagnostic parentDiag,
14631479
llvm::function_ref<void(void)> builder) {

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4672,7 +4672,7 @@ ERROR(unknown_case_multiple_patterns,none,
46724672
ERROR(unknown_case_must_be_last,none,
46734673
"'@unknown' can only be applied to the last case in a switch", ())
46744674

4675-
WARNING(move_only_pattern_match_not_consumed,none,
4675+
ERROR(move_only_pattern_match_not_consumed,none,
46764676
"noncopyable binding being pattern-matched must have the 'consume' operator applied", ())
46774677

46784678
WARNING(where_on_one_item, none,

include/swift/AST/SearchPathOptions.h

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#define SWIFT_AST_SEARCHPATHOPTIONS_H
1515

1616
#include "swift/Basic/ArrayRefView.h"
17+
#include "swift/Basic/ExternalUnion.h"
1718
#include "swift/Basic/PathRemapper.h"
18-
#include "swift/Basic/TaggedUnion.h"
1919
#include "llvm/ADT/Hashing.h"
2020
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2121
#include "llvm/ADT/StringMap.h"
@@ -187,25 +187,81 @@ struct ExternalPluginSearchPathAndServerPath {
187187
std::string ServerPath;
188188
};
189189

190-
namespace PluginSearchOption {
191-
struct LoadPluginLibrary {
192-
std::string LibraryPath;
193-
};
194-
struct LoadPluginExecutable {
195-
std::string ExecutablePath;
196-
std::vector<std::string> ModuleNames;
197-
};
198-
struct PluginPath {
199-
std::string SearchPath;
200-
};
201-
struct ExternalPluginPath {
202-
std::string SearchPath;
203-
std::string ServerPath;
204-
};
190+
class PluginSearchOption {
191+
public:
192+
struct LoadPluginLibrary {
193+
std::string LibraryPath;
194+
};
195+
struct LoadPluginExecutable {
196+
std::string ExecutablePath;
197+
std::vector<std::string> ModuleNames;
198+
};
199+
struct PluginPath {
200+
std::string SearchPath;
201+
};
202+
struct ExternalPluginPath {
203+
std::string SearchPath;
204+
std::string ServerPath;
205+
};
206+
207+
enum class Kind : uint8_t {
208+
LoadPluginLibrary,
209+
LoadPluginExecutable,
210+
PluginPath,
211+
ExternalPluginPath,
212+
};
205213

206-
using Value = TaggedUnion<LoadPluginLibrary, LoadPluginExecutable, PluginPath,
207-
ExternalPluginPath>;
208-
} // namespace PluginSearchOption
214+
private:
215+
using Members = ExternalUnionMembers<LoadPluginLibrary, LoadPluginExecutable,
216+
PluginPath, ExternalPluginPath>;
217+
static Members::Index getIndexForKind(Kind kind) {
218+
switch (kind) {
219+
case Kind::LoadPluginLibrary:
220+
return Members::indexOf<LoadPluginLibrary>();
221+
case Kind::LoadPluginExecutable:
222+
return Members::indexOf<LoadPluginExecutable>();
223+
case Kind::PluginPath:
224+
return Members::indexOf<PluginPath>();
225+
case Kind::ExternalPluginPath:
226+
return Members::indexOf<ExternalPluginPath>();
227+
}
228+
};
229+
using Storage = ExternalUnion<Kind, Members, getIndexForKind>;
230+
231+
Kind kind;
232+
Storage storage;
233+
234+
public:
235+
PluginSearchOption(const LoadPluginLibrary &v)
236+
: kind(Kind::LoadPluginLibrary) {
237+
storage.emplace<LoadPluginLibrary>(kind, v);
238+
}
239+
PluginSearchOption(const LoadPluginExecutable &v)
240+
: kind(Kind::LoadPluginExecutable) {
241+
storage.emplace<LoadPluginExecutable>(kind, v);
242+
}
243+
PluginSearchOption(const PluginPath &v) : kind(Kind::PluginPath) {
244+
storage.emplace<PluginPath>(kind, v);
245+
}
246+
PluginSearchOption(const ExternalPluginPath &v)
247+
: kind(Kind::ExternalPluginPath) {
248+
storage.emplace<ExternalPluginPath>(kind, v);
249+
}
250+
251+
Kind getKind() const { return kind; }
252+
253+
template <typename T>
254+
const T *dyn_cast() const {
255+
if (Members::indexOf<T>() != getIndexForKind(kind))
256+
return nullptr;
257+
return &storage.get<T>(kind);
258+
}
259+
260+
template <typename T>
261+
const T &get() const {
262+
return storage.get<T>(kind);
263+
}
264+
};
209265

210266
/// Options for controlling search path behavior.
211267
class SearchPathOptions {
@@ -383,7 +439,7 @@ class SearchPathOptions {
383439
std::vector<std::string> RuntimeLibraryPaths;
384440

385441
/// Plugin search path options.
386-
std::vector<PluginSearchOption::Value> PluginSearchOpts;
442+
std::vector<PluginSearchOption> PluginSearchOpts;
387443

388444
/// Don't look in for compiler-provided modules.
389445
bool SkipRuntimeLibraryImportPaths = false;

include/swift/AST/TypeCheckRequests.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,6 +4312,22 @@ class IsNonUserModuleRequest
43124312
bool isCached() const { return true; }
43134313
};
43144314

4315+
class HasInitAccessorRequest
4316+
: public SimpleRequest<HasInitAccessorRequest, bool(AbstractStorageDecl *),
4317+
RequestFlags::Cached> {
4318+
public:
4319+
using SimpleRequest::SimpleRequest;
4320+
4321+
private:
4322+
friend SimpleRequest;
4323+
4324+
// Evaluation.
4325+
bool evaluate(Evaluator &evaluator, AbstractStorageDecl *decl) const;
4326+
4327+
public:
4328+
bool isCached() const { return true; }
4329+
};
4330+
43154331
class InitAccessorReferencedVariablesRequest
43164332
: public SimpleRequest<InitAccessorReferencedVariablesRequest,
43174333
ArrayRef<VarDecl *>(DeclAttribute *, AccessorDecl *,

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ SWIFT_REQUEST(TypeChecker, IsNonUserModuleRequest,
487487
SWIFT_REQUEST(TypeChecker, TypeCheckObjCImplementationRequest,
488488
unsigned(ExtensionDecl *),
489489
Cached, NoLocationInfo)
490+
SWIFT_REQUEST(TypeChecker, HasInitAccessorRequest,
491+
bool(AbstractStorageDecl *), Cached,
492+
NoLocationInfo)
490493
SWIFT_REQUEST(TypeChecker, InitAccessorReferencedVariablesRequest,
491494
ArrayRef<VarDecl *>(DeclAttribute *, AccessorDecl *,
492495
ArrayRef<Identifier>),

include/swift/Basic/FrozenMultiMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class FrozenMultiMap {
7171
// Since our array is sorted, we need to first find the first pair with our
7272
// inst as the first element.
7373
auto start = std::lower_bound(
74-
storage.begin(), storage.end(), std::make_pair(key, Value()),
74+
storage.begin(), storage.end(), std::make_pair(key, llvm::None),
7575
[&](const std::pair<Key, Optional<Value>> &p1,
7676
const std::pair<Key, Optional<Value>> &p2) {
7777
return p1.first < p2.first;

include/swift/Driver/ToolChain.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ class ToolChain {
143143
const llvm::opt::ArgList &inputArgs,
144144
llvm::opt::ArgStringList &arguments) const;
145145

146+
virtual void addPlatformSpecificPluginFrontendArgs(
147+
const OutputInfo &OI,
148+
const CommandOutput &output,
149+
const llvm::opt::ArgList &inputArgs,
150+
llvm::opt::ArgStringList &arguments) const;
146151
virtual InvocationInfo constructInvocation(const CompileJobAction &job,
147152
const JobContext &context) const;
148153
virtual InvocationInfo constructInvocation(const InterpretJobAction &job,

0 commit comments

Comments
 (0)