Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] swiftwasm from main #5518

Merged
merged 54 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
be3015b
[Test] Remove five second delay in swift-reflection-test startup.
mikeash Jun 8, 2023
0996342
[CodeCompletion] Fix an issue that causes an iterator to be invalidat…
ahoppen Jun 9, 2023
abcdc6c
[ASTScope] Rename and generalize AttachedPropertyWrapperScope to Cust…
hborla Jun 8, 2023
2c0c596
[ASTScope] Add attribute scopes for nominal type and extension scopes.
hborla Jun 10, 2023
cd79cf9
[ASTScope] Add APIs for determining whether a given source location i…
hborla Jun 10, 2023
2943064
[Macros] Always exclude macro expansions in TypeChecker::lookupMacros.
hborla Jun 10, 2023
cd752cc
[NameLookup] Plumb source location arguments through all name lookup …
hborla Jun 10, 2023
61c99cc
[NameLookup] Use source locations to determine whether to exclude macro
hborla Jun 10, 2023
db23cf5
[PreCheckExpr] Don't perform typo correction inside macro arguments.
hborla Jun 10, 2023
f9f63e3
[Macros] Add a test that invokes macro expansion through the conformance
hborla Jun 10, 2023
9824954
[Macros] Ban freestanding and peer macro expansions that can produce …
hborla Jun 10, 2023
0b91f63
[ASTScope] Don't consider freestanding macro expansions as being part…
hborla Jun 10, 2023
706411d
[CodeCompletion] Plumb source locations through code completion name …
hborla Jun 11, 2023
51e1a39
[Parser] Reset ASTScopes before performing the IDEInspection second p…
hborla Jun 11, 2023
393b4ce
[NameLookup] Move macro-related name lookup operations into the namel…
hborla Jun 12, 2023
2cc1204
[Evaluator] Remove hasActiveResolveMacroRequest().
hborla Jun 12, 2023
cca5a6e
[SILGen] Emit block after unreachable when emitting if/switch express…
hamishknight Jun 12, 2023
490c528
Windows: add some defines from `WinUser.h`
compnerd Jun 12, 2023
1616e16
[CS] Walk into patterns when looking for closure referenced vars
hamishknight Jun 12, 2023
f18293b
[CS] Walk ExprPattern conjunction elements when finding type variables
hamishknight Jun 12, 2023
7e632c0
[Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
al45tair Jun 12, 2023
b1f99b8
[CAS] swift dependency scanning using CAS for compiler caching (#66366)
cachemeifyoucan Jun 12, 2023
fc24471
Merge pull request #66532 from hborla/suppress-expansion-in-macro-arg…
hborla Jun 12, 2023
ae2287d
Merge pull request #66551 from hamishknight/never-say-never
hamishknight Jun 12, 2023
90a1bb8
[Dependency Scanning] Do not treat modules as their own dependencies
artemcm Jun 9, 2023
1141e59
[Test] Update expected macro error
bnbarham Jun 12, 2023
02c3678
Merge pull request #66570 from apple/fix-test-failure
tshortli Jun 12, 2023
b974d97
[Dependency Scanning] Record header dependencies of Binary Swift modu…
artemcm Jun 9, 2023
9f51c06
Merge pull request #66517 from ahoppen/ahoppen/iterator-invalidation
ahoppen Jun 12, 2023
92d9e61
[Dependency Scanning] Emit header dependencies of binary Swift module…
artemcm Jun 12, 2023
775b4a4
AST: Inherit access level of opaque type decls from naming decl.
tshortli Jun 9, 2023
b459fb5
[cxx-interop] Avoid linker errors when calling a defaulted constructor
egorzhdan Jun 12, 2023
cfbbb28
[ConstraintSystem] Allow generic parameters to bind to holes only in …
xedin Jun 12, 2023
9220ec1
Merge pull request #66557 from apple/egorzhdan/irgen-defaulted-constr…
egorzhdan Jun 13, 2023
e715947
be specific that only escaping closures prevent consumption
kavon Jun 13, 2023
3e8985b
[CanOSSALifetime] Gardening: Tweaked comments.
nate-chandler Jun 7, 2023
9bb035f
Merge pull request #66515 from tshortli/usable-from-inline-opaque-typ…
tshortli Jun 13, 2023
219f94f
tailor reinit-after-consume message for closure captures
kavon Jun 13, 2023
8feefce
Merge pull request #66583 from nate-chandler/nfc/20230612/1/canonical…
swift-ci Jun 13, 2023
d6fe625
[GenericEnvironment] Don't apply outer context substitutions before
hborla Jun 13, 2023
f79938c
Merge pull request #66587 from kavon/improve-noncopyable-closure-diags
swift-ci Jun 13, 2023
4ec8276
[Runtime] Extract some layout string functionality into separate func…
drexin Jun 13, 2023
762cd4d
Merge pull request #66565 from hamishknight/connect-two
hamishknight Jun 13, 2023
fa2ac84
cmake: correctly set NDEBUG for imported headers in SwiftCompilerSources
eeckstein Jun 13, 2023
954d20b
Merge pull request #66591 from eeckstein/build-config
swift-ci Jun 13, 2023
185820a
Fix sign of fractional units in Duration initializers from Double. (#…
stephentyrone Jun 13, 2023
18798b6
Merge pull request #66556 from artemcm/TransitivePCHDepsOfBinaryModules
artemcm Jun 13, 2023
dd7e177
[cxx-interop] Add `std::set` initializer that takes a Swift Sequence
egorzhdan Jun 8, 2023
76ee456
Merge pull request #66589 from hborla/generic-env-context-substitutions
hborla Jun 13, 2023
15e6c6f
Merge pull request #66555 from compnerd/queued-status
compnerd Jun 13, 2023
7145ff0
Merge pull request #66567 from al45tair/eng/PR-110653167
al45tair Jun 13, 2023
74192c0
Merge pull request #65087 from apple/egorzhdan/cxx-set-init
egorzhdan Jun 13, 2023
5125ede
Merge pull request #66451 from mikeash/no-reflection-test-sleep
mikeash Jun 13, 2023
7143203
Merge pull request #66579 from xedin/allow-holes-in-diagnostic-mode-only
xedin Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions SwiftCompilerSources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ function(add_swift_compiler_modules_library name)
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
endif()

if(NOT LLVM_ENABLE_ASSERTIONS)
list(APPEND swift_compile_options "-Xcc" "-DNDEBUG")
endif()

if(NOT SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
list(APPEND swift_compile_options "-Xfrontend" "-disable-legacy-type-info")
endif()
Expand Down
62 changes: 61 additions & 1 deletion include/swift-c/DependencyScan/DependencyScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
/// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
#define SWIFTSCAN_VERSION_MAJOR 0
#define SWIFTSCAN_VERSION_MINOR 3
#define SWIFTSCAN_VERSION_MINOR 4

SWIFTSCAN_BEGIN_DECLS

Expand Down Expand Up @@ -139,6 +139,10 @@ SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_command_line(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_bridging_pch_command_line(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_extra_pcm_args(
swiftscan_module_details_t details);
Expand All @@ -154,6 +158,14 @@ SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_swift_overlay_dependencies(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_swift_textual_detail_get_cas_fs_root_id(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_swift_textual_detail_get_module_cache_key(
swiftscan_module_details_t details);

//=== Swift Binary Module Details query APIs ------------------------------===//

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
Expand All @@ -168,10 +180,18 @@ SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_swift_binary_detail_get_module_source_info_path(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_binary_detail_get_header_dependencies(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC bool
swiftscan_swift_binary_detail_get_is_framework(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_swift_binary_detail_get_module_cache_key(
swiftscan_module_details_t details);

//=== Swift Placeholder Module Details query APIs -------------------------===//

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
Expand Down Expand Up @@ -200,6 +220,12 @@ swiftscan_clang_detail_get_command_line(swiftscan_module_details_t details);
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_clang_detail_get_captured_pcm_args(swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_clang_detail_get_cas_fs_root_id(swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_clang_detail_get_module_cache_key(swiftscan_module_details_t details);

//=== Batch Scan Input Functions ------------------------------------------===//

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

//=== Scanner CAS Operations ----------------------------------------------===//

/// Opaque container for a CAS instance that includes both ObjectStore and
/// ActionCache.
typedef struct swiftscan_cas_s *swiftscan_cas_t;

/// Enum types for output types for cache key computation.
/// TODO: complete the list.
typedef enum {
SWIFTSCAN_OUTPUT_TYPE_OBJECT = 0,
SWIFTSCAN_OUTPUT_TYPE_SWIFTMODULE = 1,
SWIFTSCAN_OUTPUT_TYPE_SWIFTINTERFACE = 2,
SWIFTSCAN_OUTPUT_TYPE_SWIFTPRIAVEINTERFACE = 3,
SWIFTSCAN_OUTPUT_TYPE_CLANG_MODULE = 4,
SWIFTSCAN_OUTPUT_TYPE_CLANG_PCH = 5
} swiftscan_output_kind_t;

/// Create a \c cas instance that points to path.
SWIFTSCAN_PUBLIC swiftscan_cas_t swiftscan_cas_create(const char *path);

/// Dispose the \c cas instance.
SWIFTSCAN_PUBLIC void swiftscan_cas_dispose(swiftscan_cas_t cas);

/// Store content into CAS. Return \c CASID as string.
SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_cas_store(swiftscan_cas_t cas,
uint8_t *data,
unsigned size);

/// Compute \c CacheKey for output of \c kind from the compiler invocation \c
/// argc and \c argv with \c input. Return \c CacheKey as string.
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_compute_cache_key(swiftscan_cas_t cas, int argc, const char **argv,
const char *input, swiftscan_output_kind_t kind);

//===----------------------------------------------------------------------===//

SWIFTSCAN_END_DECLS
Expand Down
43 changes: 26 additions & 17 deletions include/swift/AST/ASTScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
return nullptr;
}

virtual NullablePtr<MacroExpansionDecl> getFreestandingMacro() const {
return nullptr;
}

#pragma mark - debugging and printing

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

static void lookupEnclosingMacroScope(
SourceFile *sourceFile, SourceLoc loc,
llvm::function_ref<bool(ASTScope::PotentialMacro)> consume);

/// Scopes that cannot bind variables may set this to true to create more
/// compact scope tree in the debug info.
virtual bool ignoreInDebugInfo() const { return false; }
Expand Down Expand Up @@ -840,24 +848,20 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
bool ignoreInDebugInfo() const override { return true; }
};

/// Consider:
/// @_propertyWrapper
/// struct WrapperWithInitialValue {
/// }
/// struct HasWrapper {
/// @WrapperWithInitialValue var y = 17
/// }
/// Lookup has to be able to find the use of WrapperWithInitialValue, that's
/// what this scope is for. Because the source positions are screwy.

class AttachedPropertyWrapperScope final : public ASTScopeImpl {
/// The scope for custom attributes and their arguments, such as for
/// attached property wrappers and for attached macros.
///
/// Source locations for the attribute name and its arguments are in the
/// custom attribute, so lookup is invoked from within the attribute
/// itself.
class CustomAttributeScope final : public ASTScopeImpl {
public:
CustomAttr *attr;
VarDecl *decl;
Decl *decl;

AttachedPropertyWrapperScope(CustomAttr *attr, VarDecl *decl)
CustomAttributeScope(CustomAttr *attr,Decl *decl)
: attr(attr), decl(decl) {}
virtual ~AttachedPropertyWrapperScope() {}
virtual ~CustomAttributeScope() {}

protected:
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
Expand All @@ -871,7 +875,8 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
return attr;
}
bool ignoreInDebugInfo() const override { return true; }
bool ignoreInDebugInfo() const override { return true; }

private:
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
};
Expand Down Expand Up @@ -1134,9 +1139,9 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
class DifferentiableAttributeScope final : public ASTScopeImpl {
public:
DifferentiableAttr *const differentiableAttr;
ValueDecl *const attributedDeclaration;
Decl *const attributedDeclaration;

DifferentiableAttributeScope(DifferentiableAttr *diffAttr, ValueDecl *decl)
DifferentiableAttributeScope(DifferentiableAttr *diffAttr, Decl *decl)
: differentiableAttr(diffAttr), attributedDeclaration(decl) {}
virtual ~DifferentiableAttributeScope() {}

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

NullablePtr<MacroExpansionDecl> getFreestandingMacro() const override {
return decl;
}

protected:
void printSpecifics(llvm::raw_ostream &out) const override;

Expand Down
5 changes: 3 additions & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3902,7 +3902,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
/// protocols to which the nominal type conforms. Furthermore, the resulting
/// set of declarations has not been filtered for visibility, nor have
/// overridden declarations been removed.
TinyPtrVector<ValueDecl *> lookupDirect(DeclName name,
TinyPtrVector<ValueDecl *> lookupDirect(DeclName name, SourceLoc loc = SourceLoc(),
OptionSet<LookupDirectFlags> flags =
OptionSet<LookupDirectFlags>());

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

if (Bits.ClassDecl.ComputedHasMissingDesignatedInitializers)
Expand Down
7 changes: 4 additions & 3 deletions include/swift/AST/DeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
/// lookup.
///
/// \returns true if anything was found.
bool lookupQualified(Type type, DeclNameRef member, NLOptions options,
bool lookupQualified(Type type, DeclNameRef member,
SourceLoc loc, NLOptions options,
SmallVectorImpl<ValueDecl *> &decls) const;

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

/// Perform qualified lookup for the given member in the given module.
bool lookupQualified(ModuleDecl *module, DeclNameRef member,
NLOptions options,
SourceLoc loc, NLOptions options,
SmallVectorImpl<ValueDecl *> &decls) const;

/// Look up all Objective-C methods with the given selector visible
Expand Down
7 changes: 4 additions & 3 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,10 @@ ERROR(sil_movechecking_borrowed_parameter_captured_by_closure, none,
"parameter",
(StringRef))
ERROR(sil_movechecking_capture_consumed, none,
"noncopyable '%0' cannot be consumed when captured by a closure", (StringRef))
ERROR(sil_movechecking_inout_not_reinitialized_before_end_of_function, none,
"missing reinitialization of inout parameter '%0' after consume", (StringRef))
"noncopyable '%0' cannot be consumed when captured by an escaping closure", (StringRef))
ERROR(sil_movechecking_not_reinitialized_before_end_of_function, none,
"missing reinitialization of %select{inout parameter|closure capture}1 '%0' "
"after consume", (StringRef, bool))
ERROR(sil_movechecking_value_consumed_in_a_loop, none,
"'%0' consumed in a loop", (StringRef))
ERROR(sil_movechecking_use_after_partial_consume, none,
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -7194,6 +7194,10 @@ ERROR(macro_accessor_missing_from_expansion,none,
ERROR(macro_init_accessor_not_documented,none,
"expansion of macro %0 produced an unexpected 'init' accessor",
(DeclName))
ERROR(global_arbitrary_name,none,
"'%0' macros are not allowed to introduce arbitrary names "
"at global scope",
(StringRef))

ERROR(macro_resolve_circular_reference, none,
"circular reference resolving %select{freestanding|attached}0 macro %1",
Expand Down
22 changes: 0 additions & 22 deletions include/swift/AST/Evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,6 @@ class Evaluator {
/// is treated as a stack and is used to detect cycles.
llvm::SetVector<ActiveRequest> activeRequests;

/// How many `ResolveMacroRequest` requests are active.
///
/// This allows us to quickly determine whether there is any
/// `ResolveMacroRequest` active in the active request stack.
/// It saves us from a linear scan through `activeRequests` when
/// we need to determine this information.
///
/// Why on earth would we need to determine this information?
/// Please see the extended comment that goes with the constructor
/// of `UnqualifiedLookupRequest`.
unsigned numActiveResolveMacroRequests = 0;

/// A cache that stores the results of requests.
evaluator::RequestCache cache;

Expand Down Expand Up @@ -342,16 +330,6 @@ class Evaluator {
return activeRequests.count(ActiveRequest(request));
}

/// Determine whether there is any active "resolve macro" request
/// on the request stack.
///
/// Why on earth would we need to determine this information?
/// Please see the extended comment that goes with the constructor
/// of `UnqualifiedLookupRequest`.
bool hasActiveResolveMacroRequest() const {
return numActiveResolveMacroRequests > 0;
}

private:
/// Diagnose a cycle detected in the evaluation of the given
/// request.
Expand Down