Skip to content

Commit ce28378

Browse files
authored
Merge pull request #4135 from swiftwasm/main
Merge upstream `main`
2 parents d3a4b2e + e197455 commit ce28378

File tree

156 files changed

+1660
-896
lines changed

Some content is hidden

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

156 files changed

+1660
-896
lines changed

include/swift/AST/DeclContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace swift {
7373
class PrefixOperatorDecl;
7474
class ProtocolConformance;
7575
class ValueDecl;
76+
class VarDecl;
7677
class Initializer;
7778
class ClassDecl;
7879
class SerializedAbstractClosureExpr;
@@ -355,6 +356,11 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
355356
LLVM_READONLY
356357
ProtocolDecl *getExtendedProtocolDecl() const;
357358

359+
/// If this DeclContext is the initializer expression of a global or instance
360+
/// property, return the VarDecl, otherwise return null.
361+
LLVM_READONLY
362+
VarDecl *getNonLocalVarDecl() const;
363+
358364
/// Retrieve the generic parameter 'Self' from a protocol or
359365
/// protocol extension.
360366
///

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ ERROR(error_mode_cannot_emit_reference_dependencies,none,
119119
"this mode does not support emitting reference dependency files", ())
120120
ERROR(error_mode_cannot_emit_header,none,
121121
"this mode does not support emitting Objective-C headers", ())
122+
ERROR(error_mode_cannot_emit_cxx_header,none,
123+
"this mode does not support emitting C++ headers", ())
122124
ERROR(error_mode_cannot_emit_loaded_module_trace,none,
123125
"this mode does not support emitting the loaded module trace", ())
124126
ERROR(error_mode_cannot_emit_module,none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,6 +4480,10 @@ ERROR(global_actor_from_nonactor_context,none,
44804480
"%0 %1 isolated to global actor %2 can not be %select{referenced|mutated|used 'inout'}4"
44814481
" from %select{this|a non-isolated}3%select{| synchronous}5 context",
44824482
(DescriptiveDeclKind, DeclName, Type, bool, unsigned, bool))
4483+
ERROR(global_actor_from_initializing_expr,none,
4484+
"expression requiring global actor %0 cannot appear in "
4485+
"default-value expression of %1 %2",
4486+
(Type, DescriptiveDeclKind, DeclName))
44834487
ERROR(actor_isolated_call,none,
44844488
"call to %0 function in a synchronous %1 context",
44854489
(ActorIsolation, ActorIsolation))

include/swift/AST/FileUnit.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "swift/AST/Module.h"
1717
#include "swift/AST/RawComment.h"
1818
#include "swift/Basic/BasicSourceInfo.h"
19+
#include "swift/Basic/Debug.h"
1920

2021
#include "llvm/ADT/PointerIntPair.h"
2122

@@ -188,6 +189,8 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
188189
virtual Identifier
189190
getDiscriminatorForPrivateValue(const ValueDecl *D) const = 0;
190191

192+
virtual bool shouldCollectDisplayDecls() const { return true; }
193+
191194
/// Finds all top-level decls in this file.
192195
///
193196
/// This does a simple local lookup, not recursively looking through imports.
@@ -308,6 +311,9 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
308311
return getParentModule()->getRealName().str();
309312
}
310313

314+
SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
315+
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());
316+
311317
/// Traverse the decls within this file.
312318
///
313319
/// \returns true if traversal was aborted, false if it completed

include/swift/AST/Module.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "swift/AST/Type.h"
2727
#include "swift/Basic/BasicSourceInfo.h"
2828
#include "swift/Basic/Compiler.h"
29+
#include "swift/Basic/Debug.h"
2930
#include "swift/Basic/OptionSet.h"
3031
#include "swift/Basic/STLExtras.h"
3132
#include "swift/Basic/SourceLoc.h"
@@ -759,6 +760,15 @@ class ModuleDecl
759760
/// The order of the results is not guaranteed to be meaningful.
760761
void getPrecedenceGroups(SmallVectorImpl<PrecedenceGroupDecl*> &Results) const;
761762

763+
/// Determines whether this module should be recursed into when calling
764+
/// \c getDisplayDecls.
765+
///
766+
/// Some modules should not call \c getDisplayDecls, due to assertions
767+
/// in their implementation. These are usually implicit imports that would be
768+
/// recursed into for parsed modules. This function provides a guard against
769+
/// recusing into modules that should not have decls collected.
770+
bool shouldCollectDisplayDecls() const;
771+
762772
/// Finds all top-level decls that should be displayed to a client of this
763773
/// module.
764774
///
@@ -856,6 +866,9 @@ class ModuleDecl
856866
/// transferred from module files to the dSYMs, remove this.
857867
bool isExternallyConsumed() const;
858868

869+
SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
870+
SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());
871+
859872
SourceRange getSourceRange() const { return SourceRange(); }
860873

861874
static bool classof(const DeclContext *DC) {

include/swift/AST/PrintOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ struct PrintOptions {
200200
/// Print fully qualified extended types if ambiguous.
201201
bool FullyQualifiedExtendedTypesIfAmbiguous = false;
202202

203+
/// Whether to protocol-qualify DependentMemberTypes.
204+
bool ProtocolQualifiedDependentMemberTypes = false;
205+
203206
/// If true, printed module names will use the "exported" name, which may be
204207
/// different from the regular name.
205208
///

include/swift/AST/SourceFile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ class SourceFile final : public FileUnit {
288288

289289
~SourceFile();
290290

291+
bool hasImports() const {
292+
return Imports.hasValue();
293+
}
294+
291295
/// Retrieve an immutable view of the source file's imports.
292296
ArrayRef<AttributedImport<ImportedModule>> getImports() const {
293297
return *Imports;

include/swift/AST/Types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,7 +5654,7 @@ class OpenedArchetypeType final : public ArchetypeType,
56545654
/// \param knownID When non-empty, the known ID of the archetype. When empty,
56555655
/// a fresh archetype with a unique ID will be opened.
56565656
static CanTypeWrapper<OpenedArchetypeType> get(
5657-
Type existential, Optional<UUID> knownID = None);
5657+
CanType existential, Optional<UUID> knownID = None);
56585658

56595659
/// Get or create an archetype that represents the opened type
56605660
/// of an existential value.
@@ -5665,20 +5665,20 @@ class OpenedArchetypeType final : public ArchetypeType,
56655665
/// \param knownID When non-empty, the known ID of the archetype. When empty,
56665666
/// a fresh archetype with a unique ID will be opened.
56675667
static CanTypeWrapper<OpenedArchetypeType> get(
5668-
Type existential, Type interfaceType, Optional<UUID> knownID = None);
5668+
CanType existential, Type interfaceType, Optional<UUID> knownID = None);
56695669

56705670
/// Create a new archetype that represents the opened type
56715671
/// of an existential value.
56725672
///
56735673
/// \param existential The existential type or existential metatype to open.
56745674
/// \param interfaceType The interface type represented by this archetype.
5675-
static CanType getAny(Type existential, Type interfaceType);
5675+
static CanType getAny(CanType existential, Type interfaceType);
56765676

56775677
/// Create a new archetype that represents the opened type
56785678
/// of an existential value.
56795679
///
56805680
/// \param existential The existential type or existential metatype to open.
5681-
static CanType getAny(Type existential);
5681+
static CanType getAny(CanType existential);
56825682

56835683
/// Retrieve the ID number of this opened existential.
56845684
UUID getOpenedExistentialID() const;

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ struct SupplementaryOutputPaths {
3131
/// \sa swift::printAsObjC
3232
std::string ObjCHeaderOutputPath;
3333

34+
/// The path to which we should emit a C++ header for the module.
35+
///
36+
/// Currently only makes sense when the compiler has whole module knowledge.
37+
/// The modes for which it makes sense include both WMO and the "merge
38+
/// modules" job that happens after the normal compilation jobs. That's where
39+
/// the header is emitted in single-file mode, since it needs whole-module
40+
/// information.
41+
///
42+
/// \sa swift::printAsCXX
43+
std::string CxxHeaderOutputPath;
44+
3445
/// The path to which we should emit a serialized module.
3546
/// It is valid whenever there are any inputs.
3647
///
@@ -160,7 +171,9 @@ struct SupplementaryOutputPaths {
160171
/// Apply a given function for each existing (non-empty string) supplementary output
161172
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {
162173
if (!ObjCHeaderOutputPath.empty())
163-
fn(ObjCHeaderOutputPath);
174+
fn(ObjCHeaderOutputPath);
175+
if (!CxxHeaderOutputPath.empty())
176+
fn(CxxHeaderOutputPath);
164177
if (!ModuleOutputPath.empty())
165178
fn(ModuleOutputPath);
166179
if (!ModuleSourceInfoOutputPath.empty())
@@ -196,14 +209,16 @@ struct SupplementaryOutputPaths {
196209
}
197210

198211
bool empty() const {
199-
return ObjCHeaderOutputPath.empty() && ModuleOutputPath.empty() &&
200-
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&
212+
return ObjCHeaderOutputPath.empty() && CxxHeaderOutputPath.empty() &&
213+
ModuleOutputPath.empty() && ModuleDocOutputPath.empty() &&
214+
DependenciesFilePath.empty() &&
201215
ReferenceDependenciesFilePath.empty() &&
202216
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
203217
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
204-
ModuleSourceInfoOutputPath.empty() && ABIDescriptorOutputPath.empty() &&
205-
ModuleSemanticInfoOutputPath.empty() &&
206-
YAMLOptRecordPath.empty() && BitstreamOptRecordPath.empty();
218+
ModuleSourceInfoOutputPath.empty() &&
219+
ABIDescriptorOutputPath.empty() &&
220+
ModuleSemanticInfoOutputPath.empty() && YAMLOptRecordPath.empty() &&
221+
BitstreamOptRecordPath.empty();
207222
}
208223
};
209224
} // namespace swift

include/swift/ClangImporter/ClangModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class ClangModuleUnit final : public LoadedFile {
8787
ObjCSelector selector,
8888
SmallVectorImpl<AbstractFunctionDecl *> &results) const override;
8989

90+
virtual bool shouldCollectDisplayDecls() const override;
91+
9092
virtual void getTopLevelDecls(SmallVectorImpl<Decl*> &results) const override;
9193

9294
virtual void getDisplayDecls(SmallVectorImpl<Decl*> &results) const override;

0 commit comments

Comments
 (0)