Skip to content

Commit dd991b7

Browse files
Merge pull request #5518 from swiftwasm/main
[pull] swiftwasm from main
2 parents 222c704 + 7143203 commit dd991b7

File tree

146 files changed

+4418
-995
lines changed

Some content is hidden

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

146 files changed

+4418
-995
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ function(add_swift_compiler_modules_library name)
8787
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
8888
endif()
8989

90+
if(NOT LLVM_ENABLE_ASSERTIONS)
91+
list(APPEND swift_compile_options "-Xcc" "-DNDEBUG")
92+
endif()
93+
9094
if(NOT SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
9195
list(APPEND swift_compile_options "-Xfrontend" "-disable-legacy-type-info")
9296
endif()

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
2626
/// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
2727
#define SWIFTSCAN_VERSION_MAJOR 0
28-
#define SWIFTSCAN_VERSION_MINOR 3
28+
#define SWIFTSCAN_VERSION_MINOR 4
2929

3030
SWIFTSCAN_BEGIN_DECLS
3131

@@ -139,6 +139,10 @@ SWIFTSCAN_PUBLIC swiftscan_string_set_t *
139139
swiftscan_swift_textual_detail_get_command_line(
140140
swiftscan_module_details_t details);
141141

142+
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
143+
swiftscan_swift_textual_detail_get_bridging_pch_command_line(
144+
swiftscan_module_details_t details);
145+
142146
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
143147
swiftscan_swift_textual_detail_get_extra_pcm_args(
144148
swiftscan_module_details_t details);
@@ -154,6 +158,14 @@ SWIFTSCAN_PUBLIC swiftscan_string_set_t *
154158
swiftscan_swift_textual_detail_get_swift_overlay_dependencies(
155159
swiftscan_module_details_t details);
156160

161+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
162+
swiftscan_swift_textual_detail_get_cas_fs_root_id(
163+
swiftscan_module_details_t details);
164+
165+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
166+
swiftscan_swift_textual_detail_get_module_cache_key(
167+
swiftscan_module_details_t details);
168+
157169
//=== Swift Binary Module Details query APIs ------------------------------===//
158170

159171
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
@@ -168,10 +180,18 @@ SWIFTSCAN_PUBLIC swiftscan_string_ref_t
168180
swiftscan_swift_binary_detail_get_module_source_info_path(
169181
swiftscan_module_details_t details);
170182

183+
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
184+
swiftscan_swift_binary_detail_get_header_dependencies(
185+
swiftscan_module_details_t details);
186+
171187
SWIFTSCAN_PUBLIC bool
172188
swiftscan_swift_binary_detail_get_is_framework(
173189
swiftscan_module_details_t details);
174190

191+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
192+
swiftscan_swift_binary_detail_get_module_cache_key(
193+
swiftscan_module_details_t details);
194+
175195
//=== Swift Placeholder Module Details query APIs -------------------------===//
176196

177197
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
@@ -200,6 +220,12 @@ swiftscan_clang_detail_get_command_line(swiftscan_module_details_t details);
200220
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
201221
swiftscan_clang_detail_get_captured_pcm_args(swiftscan_module_details_t details);
202222

223+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
224+
swiftscan_clang_detail_get_cas_fs_root_id(swiftscan_module_details_t details);
225+
226+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
227+
swiftscan_clang_detail_get_module_cache_key(swiftscan_module_details_t details);
228+
203229
//=== Batch Scan Input Functions ------------------------------------------===//
204230

205231
/// Create an \c swiftscan_batch_scan_input_t instance.
@@ -402,6 +428,40 @@ swiftscan_scanner_cache_reset(swiftscan_scanner_t scanner);
402428
/// An entry point to invoke the compiler via a library call.
403429
SWIFTSCAN_PUBLIC int invoke_swift_compiler(int argc, const char **argv);
404430

431+
//=== Scanner CAS Operations ----------------------------------------------===//
432+
433+
/// Opaque container for a CAS instance that includes both ObjectStore and
434+
/// ActionCache.
435+
typedef struct swiftscan_cas_s *swiftscan_cas_t;
436+
437+
/// Enum types for output types for cache key computation.
438+
/// TODO: complete the list.
439+
typedef enum {
440+
SWIFTSCAN_OUTPUT_TYPE_OBJECT = 0,
441+
SWIFTSCAN_OUTPUT_TYPE_SWIFTMODULE = 1,
442+
SWIFTSCAN_OUTPUT_TYPE_SWIFTINTERFACE = 2,
443+
SWIFTSCAN_OUTPUT_TYPE_SWIFTPRIAVEINTERFACE = 3,
444+
SWIFTSCAN_OUTPUT_TYPE_CLANG_MODULE = 4,
445+
SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5
446+
} swiftscan_output_kind_t;
447+
448+
/// Create a \c cas instance that points to path.
449+
SWIFTSCAN_PUBLIC swiftscan_cas_t swiftscan_cas_create(const char *path);
450+
451+
/// Dispose the \c cas instance.
452+
SWIFTSCAN_PUBLIC void swiftscan_cas_dispose(swiftscan_cas_t cas);
453+
454+
/// Store content into CAS. Return \c CASID as string.
455+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_cas_store(swiftscan_cas_t cas,
456+
uint8_t *data,
457+
unsigned size);
458+
459+
/// Compute \c CacheKey for output of \c kind from the compiler invocation \c
460+
/// argc and \c argv with \c input. Return \c CacheKey as string.
461+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
462+
swiftscan_compute_cache_key(swiftscan_cas_t cas, int argc, const char **argv,
463+
const char *input, swiftscan_output_kind_t kind);
464+
405465
//===----------------------------------------------------------------------===//
406466

407467
SWIFTSCAN_END_DECLS

include/swift/AST/ASTScope.h

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
218218
return nullptr;
219219
}
220220

221+
virtual NullablePtr<MacroExpansionDecl> getFreestandingMacro() const {
222+
return nullptr;
223+
}
224+
221225
#pragma mark - debugging and printing
222226

223227
public:
@@ -278,6 +282,10 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
278282
static std::pair<CaseStmt *, CaseStmt *>
279283
lookupFallthroughSourceAndDest(SourceFile *sourceFile, SourceLoc loc);
280284

285+
static void lookupEnclosingMacroScope(
286+
SourceFile *sourceFile, SourceLoc loc,
287+
llvm::function_ref<bool(ASTScope::PotentialMacro)> consume);
288+
281289
/// Scopes that cannot bind variables may set this to true to create more
282290
/// compact scope tree in the debug info.
283291
virtual bool ignoreInDebugInfo() const { return false; }
@@ -840,24 +848,20 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
840848
bool ignoreInDebugInfo() const override { return true; }
841849
};
842850

843-
/// Consider:
844-
/// @_propertyWrapper
845-
/// struct WrapperWithInitialValue {
846-
/// }
847-
/// struct HasWrapper {
848-
/// @WrapperWithInitialValue var y = 17
849-
/// }
850-
/// Lookup has to be able to find the use of WrapperWithInitialValue, that's
851-
/// what this scope is for. Because the source positions are screwy.
852-
853-
class AttachedPropertyWrapperScope final : public ASTScopeImpl {
851+
/// The scope for custom attributes and their arguments, such as for
852+
/// attached property wrappers and for attached macros.
853+
///
854+
/// Source locations for the attribute name and its arguments are in the
855+
/// custom attribute, so lookup is invoked from within the attribute
856+
/// itself.
857+
class CustomAttributeScope final : public ASTScopeImpl {
854858
public:
855859
CustomAttr *attr;
856-
VarDecl *decl;
860+
Decl *decl;
857861

858-
AttachedPropertyWrapperScope(CustomAttr *attr, VarDecl *decl)
862+
CustomAttributeScope(CustomAttr *attr,Decl *decl)
859863
: attr(attr), decl(decl) {}
860-
virtual ~AttachedPropertyWrapperScope() {}
864+
virtual ~CustomAttributeScope() {}
861865

862866
protected:
863867
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
@@ -871,7 +875,8 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
871875
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
872876
return attr;
873877
}
874-
bool ignoreInDebugInfo() const override { return true; }
878+
bool ignoreInDebugInfo() const override { return true; }
879+
875880
private:
876881
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
877882
};
@@ -1134,9 +1139,9 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
11341139
class DifferentiableAttributeScope final : public ASTScopeImpl {
11351140
public:
11361141
DifferentiableAttr *const differentiableAttr;
1137-
ValueDecl *const attributedDeclaration;
1142+
Decl *const attributedDeclaration;
11381143

1139-
DifferentiableAttributeScope(DifferentiableAttr *diffAttr, ValueDecl *decl)
1144+
DifferentiableAttributeScope(DifferentiableAttr *diffAttr, Decl *decl)
11401145
: differentiableAttr(diffAttr), attributedDeclaration(decl) {}
11411146
virtual ~DifferentiableAttributeScope() {}
11421147

@@ -1270,6 +1275,10 @@ class MacroExpansionDeclScope final : public ASTScopeImpl {
12701275
SourceRange
12711276
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
12721277

1278+
NullablePtr<MacroExpansionDecl> getFreestandingMacro() const override {
1279+
return decl;
1280+
}
1281+
12731282
protected:
12741283
void printSpecifics(llvm::raw_ostream &out) const override;
12751284

include/swift/AST/Decl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,7 +3902,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
39023902
/// protocols to which the nominal type conforms. Furthermore, the resulting
39033903
/// set of declarations has not been filtered for visibility, nor have
39043904
/// overridden declarations been removed.
3905-
TinyPtrVector<ValueDecl *> lookupDirect(DeclName name,
3905+
TinyPtrVector<ValueDecl *> lookupDirect(DeclName name, SourceLoc loc = SourceLoc(),
39063906
OptionSet<LookupDirectFlags> flags =
39073907
OptionSet<LookupDirectFlags>());
39083908

@@ -4457,7 +4457,8 @@ class ClassDecl final : public NominalTypeDecl {
44574457
// Force loading all the members, which will add this attribute if any of
44584458
// members are determined to be missing while loading.
44594459
auto mutableThis = const_cast<ClassDecl *>(this);
4460-
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor());
4460+
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor(),
4461+
getStartLoc());
44614462
}
44624463

44634464
if (Bits.ClassDecl.ComputedHasMissingDesignatedInitializers)

include/swift/AST/DeclContext.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
598598
/// lookup.
599599
///
600600
/// \returns true if anything was found.
601-
bool lookupQualified(Type type, DeclNameRef member, NLOptions options,
601+
bool lookupQualified(Type type, DeclNameRef member,
602+
SourceLoc loc, NLOptions options,
602603
SmallVectorImpl<ValueDecl *> &decls) const;
603604

604605
/// Look for the set of declarations with the given name within the
@@ -616,12 +617,12 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
616617
///
617618
/// \returns true if anything was found.
618619
bool lookupQualified(ArrayRef<NominalTypeDecl *> types, DeclNameRef member,
619-
NLOptions options,
620+
SourceLoc loc, NLOptions options,
620621
SmallVectorImpl<ValueDecl *> &decls) const;
621622

622623
/// Perform qualified lookup for the given member in the given module.
623624
bool lookupQualified(ModuleDecl *module, DeclNameRef member,
624-
NLOptions options,
625+
SourceLoc loc, NLOptions options,
625626
SmallVectorImpl<ValueDecl *> &decls) const;
626627

627628
/// Look up all Objective-C methods with the given selector visible

include/swift/AST/DiagnosticsSIL.def

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,10 @@ ERROR(sil_movechecking_borrowed_parameter_captured_by_closure, none,
766766
"parameter",
767767
(StringRef))
768768
ERROR(sil_movechecking_capture_consumed, none,
769-
"noncopyable '%0' cannot be consumed when captured by a closure", (StringRef))
770-
ERROR(sil_movechecking_inout_not_reinitialized_before_end_of_function, none,
771-
"missing reinitialization of inout parameter '%0' after consume", (StringRef))
769+
"noncopyable '%0' cannot be consumed when captured by an escaping closure", (StringRef))
770+
ERROR(sil_movechecking_not_reinitialized_before_end_of_function, none,
771+
"missing reinitialization of %select{inout parameter|closure capture}1 '%0' "
772+
"after consume", (StringRef, bool))
772773
ERROR(sil_movechecking_value_consumed_in_a_loop, none,
773774
"'%0' consumed in a loop", (StringRef))
774775
ERROR(sil_movechecking_use_after_partial_consume, none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7194,6 +7194,10 @@ ERROR(macro_accessor_missing_from_expansion,none,
71947194
ERROR(macro_init_accessor_not_documented,none,
71957195
"expansion of macro %0 produced an unexpected 'init' accessor",
71967196
(DeclName))
7197+
ERROR(global_arbitrary_name,none,
7198+
"'%0' macros are not allowed to introduce arbitrary names "
7199+
"at global scope",
7200+
(StringRef))
71977201

71987202
ERROR(macro_resolve_circular_reference, none,
71997203
"circular reference resolving %select{freestanding|attached}0 macro %1",

include/swift/AST/Evaluator.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,6 @@ class Evaluator {
208208
/// is treated as a stack and is used to detect cycles.
209209
llvm::SetVector<ActiveRequest> activeRequests;
210210

211-
/// How many `ResolveMacroRequest` requests are active.
212-
///
213-
/// This allows us to quickly determine whether there is any
214-
/// `ResolveMacroRequest` active in the active request stack.
215-
/// It saves us from a linear scan through `activeRequests` when
216-
/// we need to determine this information.
217-
///
218-
/// Why on earth would we need to determine this information?
219-
/// Please see the extended comment that goes with the constructor
220-
/// of `UnqualifiedLookupRequest`.
221-
unsigned numActiveResolveMacroRequests = 0;
222-
223211
/// A cache that stores the results of requests.
224212
evaluator::RequestCache cache;
225213

@@ -342,16 +330,6 @@ class Evaluator {
342330
return activeRequests.count(ActiveRequest(request));
343331
}
344332

345-
/// Determine whether there is any active "resolve macro" request
346-
/// on the request stack.
347-
///
348-
/// Why on earth would we need to determine this information?
349-
/// Please see the extended comment that goes with the constructor
350-
/// of `UnqualifiedLookupRequest`.
351-
bool hasActiveResolveMacroRequest() const {
352-
return numActiveResolveMacroRequests > 0;
353-
}
354-
355333
private:
356334
/// Diagnose a cycle detected in the evaluation of the given
357335
/// request.

0 commit comments

Comments
 (0)