Skip to content

Commit 1ea746e

Browse files
authored
Merge branch 'main' into wip-deprecate-extractisolation
2 parents c009461 + 9a0a831 commit 1ea746e

File tree

176 files changed

+2913
-950
lines changed

Some content is hidden

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

176 files changed

+2913
-950
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ extension LifetimeDependentApply {
145145
case .inherit:
146146
continue
147147
case .scope:
148+
// FIXME: For yields with a scoped lifetime dependence, dependence on parameter operands is redundant,
149+
// since we introduce dependence on the begin_apply's token as well.
150+
// This can lead to duplicate lifetime dependence diagnostics in some cases.
151+
// However this is neccessary for safety when begin_apply gets inlined which will delete the dependence on the token.
148152
for yieldedValue in beginApply.yieldedValues {
149153
let targetKind = yieldedValue.type.isAddress ? TargetKind.yieldAddress : TargetKind.yield
150-
info.sources.push(LifetimeSource(targetKind: targetKind, convention: .inherit, value: operand.value))
154+
info.sources.push(LifetimeSource(targetKind: targetKind, convention: dep, value: operand.value))
151155
}
152156
}
153157
}

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 39 additions & 2 deletions
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 2
28-
#define SWIFTSCAN_VERSION_MINOR 1
28+
#define SWIFTSCAN_VERSION_MINOR 2
2929

3030
SWIFTSCAN_BEGIN_DECLS
3131

@@ -49,6 +49,9 @@ typedef struct swiftscan_dependency_info_s *swiftscan_dependency_info_t;
4949
/// Opaque container to a link library info.
5050
typedef struct swiftscan_link_library_info_s *swiftscan_link_library_info_t;
5151

52+
/// Opaque container to an import info.
53+
typedef struct swiftscan_import_info_s *swiftscan_import_info_t;
54+
5255
/// Opaque container to a macro dependency.
5356
typedef struct swiftscan_macro_dependency_s *swiftscan_macro_dependency_t;
5457

@@ -76,6 +79,18 @@ typedef struct {
7679
size_t count;
7780
} swiftscan_link_library_set_t;
7881

82+
/// Set of details about source imports
83+
typedef struct {
84+
swiftscan_import_info_t *imports;
85+
size_t count;
86+
} swiftscan_import_info_set_t;
87+
88+
/// Set of source location infos
89+
typedef struct {
90+
swiftscan_source_location_t *source_locations;
91+
size_t count;
92+
} swiftscan_source_location_set_t;
93+
7994
/// Set of macro dependency
8095
typedef struct {
8196
swiftscan_macro_dependency_t *macro_dependencies;
@@ -89,6 +104,15 @@ typedef enum {
89104
SWIFTSCAN_DIAGNOSTIC_SEVERITY_REMARK = 3
90105
} swiftscan_diagnostic_severity_t;
91106

107+
// Must maintain consistency with swift::AccessLevel
108+
typedef enum {
109+
SWIFTSCAN_ACCESS_LEVEL_PRIVATE = 0,
110+
SWIFTSCAN_ACCESS_LEVEL_FILEPRIVATE = 1,
111+
SWIFTSCAN_ACCESS_LEVEL_INTERNAL = 2,
112+
SWIFTSCAN_ACCESS_LEVEL_PACKAGE = 3,
113+
SWIFTSCAN_ACCESS_LEVEL_PUBLIC = 4
114+
} swiftscan_access_level_t;
115+
92116
typedef struct {
93117
swiftscan_diagnostic_info_t *diagnostics;
94118
size_t count;
@@ -148,10 +172,23 @@ swiftscan_module_info_get_direct_dependencies(swiftscan_dependency_info_t info);
148172
SWIFTSCAN_PUBLIC swiftscan_link_library_set_t *
149173
swiftscan_module_info_get_link_libraries(swiftscan_dependency_info_t info);
150174

175+
SWIFTSCAN_PUBLIC swiftscan_import_info_set_t *
176+
swiftscan_module_info_get_imports(swiftscan_dependency_info_t info);
177+
151178
SWIFTSCAN_PUBLIC swiftscan_module_details_t
152179
swiftscan_module_info_get_details(swiftscan_dependency_info_t info);
153180

154-
//=== Link Library Info Functions ------------------------------------===//
181+
//=== Import Details Functions -------------------------------------------===//
182+
SWIFTSCAN_PUBLIC swiftscan_source_location_set_t *
183+
swiftscan_import_info_get_source_locations(swiftscan_import_info_t info);
184+
185+
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
186+
swiftscan_import_info_get_identifier(swiftscan_import_info_t info);
187+
188+
SWIFTSCAN_PUBLIC swiftscan_access_level_t
189+
swiftscan_import_info_get_access_level(swiftscan_import_info_t info);
190+
191+
//=== Link Library Info Functions ----------------------------------------===//
155192
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
156193
swiftscan_link_library_info_get_link_name(
157194
swiftscan_link_library_info_t info);

include/swift/AST/AvailabilityDomain.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ class AvailabilityDomain final {
209209
/// version ranges.
210210
bool isVersioned() const;
211211

212+
/// Returns true if the given version is a valid version number for this
213+
/// domain. It is an error to call this on an un-versioned domain.
214+
bool isVersionValid(const llvm::VersionTuple &version) const;
215+
212216
/// Returns true if availability of the domain can be refined using
213217
/// `@available` attributes and `if #available` queries. If not, then the
214218
/// domain's availability is fixed by compilation settings. For example,

include/swift/AST/Builtins.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,15 @@ BUILTIN_MISC_OPERATION(InsertElement, "insertelement", "n", Special)
680680
/// T must be trivial.
681681
BUILTIN_MISC_OPERATION(Select, "select", "n", Special)
682682

683-
// Shufflevector has type (VecN<T>, VecN<T>, VecM<Int32>) -> VecM<T>
683+
/// Shufflevector has type (VecN<T>, VecN<T>, VecM<Int32>) -> VecM<T>
684684
BUILTIN_MISC_OPERATION(ShuffleVector, "shufflevector", "n", Special)
685685

686+
/// Interleave has type (VecN<T>, VecN<T>) -> (VecN<T>, VecN<T>)
687+
BUILTIN_MISC_OPERATION(Interleave, "interleave", "n", Special)
688+
689+
/// Deinterleave has type (VecN<T>, VecN<T>) -> (VecN<T>, VecN<T>)
690+
BUILTIN_MISC_OPERATION(Deinterleave, "deinterleave", "n", Special)
691+
686692
/// StaticReport has type (Builtin.Int1, Builtin.Int1, Builtin.RawPointer) -> ()
687693
BUILTIN_MISC_OPERATION(StaticReport, "staticReport", "", Special)
688694

include/swift/AST/Decl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,8 @@ class ExtensionDecl final : public GenericContext, public Decl,
20612061
NominalTypeDecl *getExtendedNominal() const;
20622062

20632063
/// Compute the nominal type declaration that is being extended.
2064-
NominalTypeDecl *computeExtendedNominal() const;
2064+
NominalTypeDecl *computeExtendedNominal(
2065+
bool excludeMacroExpansions=false) const;
20652066

20662067
/// \c hasBeenBound means nothing if this extension can never been bound
20672068
/// because it is not at the top level.

include/swift/AST/DiagnosticGroups.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ GROUP(ExistentialMemberAccess, "existential-member-access-limitations")
5252
GROUP(ImplementationOnlyDeprecated, "implementation-only-deprecated")
5353
GROUP(IsolatedConformances, "isolated-conformances")
5454
GROUP(MemberImportVisibility, "member-import-visibility")
55+
GROUP(MissingModuleOnKnownPaths, "missing-module-on-known-paths")
5556
GROUP(MultipleInheritance, "multiple-inheritance")
5657
GROUP(MutableGlobalVariable, "mutable-global-variable")
5758
GROUP(NominalTypes, "nominal-types")

include/swift/AST/DiagnosticsSema.def

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,14 @@ ERROR(serialization_failed,none,
891891
WARNING(can_import_invalid_swiftmodule,none,
892892
"canImport() evaluated to false due to invalid swiftmodule: %0", (StringRef))
893893

894+
ERROR(map_os_version_from_textual_interface_failed,none,
895+
"failed to map OS version from %0 to %1 in %2",
896+
(StringRef, StringRef, StringRef))
897+
898+
ERROR(target_os_version_from_textual_interface_invalid,none,
899+
"invalid target triple %0 in %1",
900+
(StringRef, StringRef))
901+
894902
ERROR(serialization_load_failed,Fatal,
895903
"failed to load module '%0'", (StringRef))
896904
ERROR(module_interface_build_failed,Fatal,
@@ -2374,12 +2382,18 @@ ERROR(alignment_not_power_of_two,none,
23742382

23752383
// Dependency Scanning
23762384
ERROR(dependency_scan_module_not_found, none, "Unable to find module dependency: '%0'", (StringRef))
2385+
GROUPED_ERROR(dependency_scan_module_not_found_on_specified_search_paths, MissingModuleOnKnownPaths, none,
2386+
"Compilation search paths unable to resolve module dependency: '%0'", (StringRef))
23772387
NOTE(unresolved_import_location,none,
23782388
"also imported here", ())
23792389
NOTE(dependency_as_imported_by_main_module,none,
23802390
"a dependency of main module '%0'", (StringRef))
23812391
NOTE(dependency_as_imported_by, none,
23822392
"a dependency of %select{Swift|Clang}2 module '%0': '%1'", (StringRef, StringRef, bool))
2393+
NOTE(inherited_search_path_resolves_module,none,
2394+
"'%0' can be found using a search path that was specified when building module '%1' ('%2'). "
2395+
"This search path was not explicitly specified on the current compilation.", (StringRef, StringRef, StringRef))
2396+
23832397
ERROR(clang_dependency_scan_error, none, "Clang dependency scanner failure: %0", (StringRef))
23842398
ERROR(clang_header_dependency_scan_error, none, "Bridging header dependency scan failure: %0", (StringRef))
23852399

@@ -6929,6 +6943,9 @@ GROUPED_ERROR(availability_suggest_platform_name,
69296943
(Identifier, StringRef))
69306944
WARNING(availability_unsupported_version_number, none,
69316945
"'%0' is not a supported version number", (llvm::VersionTuple))
6946+
WARNING(availability_invalid_version_number_for_domain, none,
6947+
"'%0' is not a valid version number for %1",
6948+
(llvm::VersionTuple, AvailabilityDomain))
69326949

69336950
WARNING(attr_availability_expected_deprecated_version, none,
69346951
"expected version number with 'deprecated' in '%0' attribute for %1",
@@ -8302,11 +8319,14 @@ ERROR(lifetime_dependence_immortal_alone, none,
83028319
"cannot specify any other dependence source along with immortal", ())
83038320
ERROR(lifetime_dependence_invalid_inherit_escapable_type, none,
83048321
"cannot copy the lifetime of an Escapable type, use "
8305-
"'@_lifetime(%1%0)' instead",
8322+
"'@_lifetime(%0%1)' instead",
83068323
(StringRef, StringRef))
8307-
ERROR(lifetime_dependence_cannot_use_parsed_borrow_consuming, none,
8324+
ERROR(lifetime_dependence_parsed_borrow_with_ownership, none,
83088325
"invalid use of %0 dependence with %1 ownership",
83098326
(StringRef, StringRef))
8327+
NOTE(lifetime_dependence_parsed_borrow_with_ownership_fix, none,
8328+
"use '@_lifetime(%0%1)' instead",
8329+
(StringRef, StringRef))
83108330
ERROR(lifetime_dependence_cannot_use_default_escapable_consuming, none,
83118331
"invalid lifetime dependence on an Escapable value with %0 ownership",
83128332
(StringRef))

include/swift/AST/LifetimeDependence.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ class LifetimeDependenceInfo {
236236
paramIndicesLength = inheritLifetimeParamIndices->getCapacity();
237237
}
238238
if (scopeLifetimeParamIndices) {
239-
assert(paramIndicesLength == 0 ||
239+
ASSERT(paramIndicesLength == 0 ||
240240
paramIndicesLength == scopeLifetimeParamIndices->getCapacity());
241241
paramIndicesLength = scopeLifetimeParamIndices->getCapacity();
242242
}
243243
if (addressableParamIndices) {
244-
assert(paramIndicesLength == 0 ||
244+
ASSERT(paramIndicesLength == 0 ||
245245
paramIndicesLength == addressableParamIndices->getCapacity());
246246
paramIndicesLength = addressableParamIndices->getCapacity();
247247
}

include/swift/AST/ModuleDependencies.h

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/LinkLibrary.h"
2323
#include "swift/Basic/CXXStdlibKind.h"
2424
#include "swift/Basic/LLVM.h"
25+
#include "swift/Serialization/Validation.h"
2526
#include "clang/CAS/CASOptions.h"
2627
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
2728
#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
@@ -155,30 +156,35 @@ struct ScannerImportStatementInfo {
155156
uint32_t columnNumber;
156157
};
157158

158-
ScannerImportStatementInfo(std::string importIdentifier, bool isExported)
159-
: importLocations(), importIdentifier(importIdentifier),
160-
isExported(isExported) {}
159+
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
160+
AccessLevel accessLevel)
161+
: importIdentifier(importIdentifier), importLocations(),
162+
isExported(isExported), accessLevel(accessLevel) {}
161163

162164
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
165+
AccessLevel accessLevel,
163166
ImportDiagnosticLocationInfo location)
164-
: importLocations({location}), importIdentifier(importIdentifier),
165-
isExported(isExported) {}
167+
: importIdentifier(importIdentifier), importLocations({location}),
168+
isExported(isExported), accessLevel(accessLevel) {}
166169

167170
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
171+
AccessLevel accessLevel,
168172
SmallVector<ImportDiagnosticLocationInfo, 4> locations)
169-
: importLocations(locations), importIdentifier(importIdentifier),
170-
isExported(isExported) {}
173+
: importIdentifier(importIdentifier), importLocations(locations),
174+
isExported(isExported), accessLevel(accessLevel) {}
171175

172176
void addImportLocation(ImportDiagnosticLocationInfo location) {
173177
importLocations.push_back(location);
174178
}
175179

176-
/// Buffer, line & column number of the import statement
177-
SmallVector<ImportDiagnosticLocationInfo, 4> importLocations;
178180
/// Imported module string. e.g. "Foo.Bar" in 'import Foo.Bar'
179181
std::string importIdentifier;
182+
/// Buffer, line & column number of the import statement
183+
SmallVector<ImportDiagnosticLocationInfo, 4> importLocations;
180184
/// Is this an @_exported import
181185
bool isExported;
186+
/// Access level of this dependency
187+
AccessLevel accessLevel;
182188
};
183189

184190
/// Base class for the variant storage of ModuleDependencyInfo.
@@ -406,15 +412,18 @@ class SwiftBinaryModuleDependencyStorage
406412
StringRef sourceInfoPath,
407413
ArrayRef<ScannerImportStatementInfo> moduleImports,
408414
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
409-
ArrayRef<LinkLibrary> linkLibraries, StringRef headerImport,
410-
StringRef definingModuleInterface, bool isFramework, bool isStatic,
411-
StringRef moduleCacheKey, StringRef userModuleVersion)
415+
ArrayRef<LinkLibrary> linkLibraries,
416+
ArrayRef<serialization::SearchPath> serializedSearchPaths,
417+
StringRef headerImport, StringRef definingModuleInterface,
418+
bool isFramework, bool isStatic, StringRef moduleCacheKey,
419+
StringRef userModuleVersion)
412420
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftBinary,
413421
moduleImports, optionalModuleImports,
414422
linkLibraries, moduleCacheKey),
415423
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
416424
sourceInfoPath(sourceInfoPath), headerImport(headerImport),
417425
definingModuleInterfacePath(definingModuleInterface),
426+
serializedSearchPaths(serializedSearchPaths),
418427
isFramework(isFramework), isStatic(isStatic),
419428
userModuleVersion(userModuleVersion) {}
420429

@@ -441,6 +450,9 @@ class SwiftBinaryModuleDependencyStorage
441450
/// Source files on which the header inputs depend.
442451
std::vector<std::string> headerSourceFiles;
443452

453+
/// Search paths this module was built with which got serialized
454+
std::vector<serialization::SearchPath> serializedSearchPaths;
455+
444456
/// (Clang) modules on which the header inputs depend.
445457
std::vector<ModuleDependencyID> headerModuleDependencies;
446458

@@ -613,15 +625,17 @@ class ModuleDependencyInfo {
613625
StringRef sourceInfoPath,
614626
ArrayRef<ScannerImportStatementInfo> moduleImports,
615627
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
616-
ArrayRef<LinkLibrary> linkLibraries, StringRef headerImport,
617-
StringRef definingModuleInterface, bool isFramework,
618-
bool isStatic, StringRef moduleCacheKey, StringRef userModuleVer) {
628+
ArrayRef<LinkLibrary> linkLibraries,
629+
ArrayRef<serialization::SearchPath> serializedSearchPaths,
630+
StringRef headerImport, StringRef definingModuleInterface,
631+
bool isFramework, bool isStatic, StringRef moduleCacheKey,
632+
StringRef userModuleVer) {
619633
return ModuleDependencyInfo(
620634
std::make_unique<SwiftBinaryModuleDependencyStorage>(
621635
compiledModulePath, moduleDocPath, sourceInfoPath, moduleImports,
622-
optionalModuleImports, linkLibraries, headerImport,
623-
definingModuleInterface,isFramework, isStatic, moduleCacheKey,
624-
userModuleVer));
636+
optionalModuleImports, linkLibraries, serializedSearchPaths,
637+
headerImport, definingModuleInterface,isFramework, isStatic,
638+
moduleCacheKey, userModuleVer));
625639
}
626640

627641
/// Describe the main Swift module.
@@ -933,6 +947,7 @@ class ModuleDependencyInfo {
933947
/// Add a dependency on the given module, if it was not already in the set.
934948
void
935949
addOptionalModuleImport(StringRef module, bool isExported,
950+
AccessLevel accessLevel,
936951
llvm::StringSet<> *alreadyAddedModules = nullptr);
937952

938953
/// Add all of the module imports in the given source
@@ -943,12 +958,14 @@ class ModuleDependencyInfo {
943958

944959
/// Add a dependency on the given module, if it was not already in the set.
945960
void addModuleImport(ImportPath::Module module, bool isExported,
961+
AccessLevel accessLevel,
946962
llvm::StringSet<> *alreadyAddedModules = nullptr,
947963
const SourceManager *sourceManager = nullptr,
948964
SourceLoc sourceLocation = SourceLoc());
949965

950966
/// Add a dependency on the given module, if it was not already in the set.
951967
void addModuleImport(StringRef module, bool isExported,
968+
AccessLevel accessLevel,
952969
llvm::StringSet<> *alreadyAddedModules = nullptr,
953970
const SourceManager *sourceManager = nullptr,
954971
SourceLoc sourceLocation = SourceLoc());

include/swift/AST/NameLookupRequests.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class HasMissingDesignatedInitializersRequest :
267267
/// Request the nominal declaration extended by a given extension declaration.
268268
class ExtendedNominalRequest
269269
: public SimpleRequest<
270-
ExtendedNominalRequest, NominalTypeDecl *(ExtensionDecl *),
270+
ExtendedNominalRequest, NominalTypeDecl *(ExtensionDecl *, bool),
271271
RequestFlags::SeparatelyCached | RequestFlags::DependencySink> {
272272
public:
273273
using SimpleRequest::SimpleRequest;
@@ -276,8 +276,8 @@ class ExtendedNominalRequest
276276
friend SimpleRequest;
277277

278278
// Evaluation.
279-
NominalTypeDecl *
280-
evaluate(Evaluator &evaluator, ExtensionDecl *ext) const;
279+
NominalTypeDecl * evaluate(Evaluator &evaluator, ExtensionDecl *ext,
280+
bool excludeMacroExpansions) const;
281281

282282
public:
283283
// Separate caching.

0 commit comments

Comments
 (0)