Skip to content

Commit aaf2832

Browse files
committed
Merge branch 'main' into mchiu/freebsd
2 parents cf041b1 + 9a0a831 commit aaf2832

File tree

96 files changed

+1298
-563
lines changed

Some content is hidden

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

96 files changed

+1298
-563
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/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/DiagnosticsSema.def

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8319,11 +8319,14 @@ ERROR(lifetime_dependence_immortal_alone, none,
83198319
"cannot specify any other dependence source along with immortal", ())
83208320
ERROR(lifetime_dependence_invalid_inherit_escapable_type, none,
83218321
"cannot copy the lifetime of an Escapable type, use "
8322-
"'@_lifetime(%1%0)' instead",
8322+
"'@_lifetime(%0%1)' instead",
83238323
(StringRef, StringRef))
8324-
ERROR(lifetime_dependence_cannot_use_parsed_borrow_consuming, none,
8324+
ERROR(lifetime_dependence_parsed_borrow_with_ownership, none,
83258325
"invalid use of %0 dependence with %1 ownership",
83268326
(StringRef, StringRef))
8327+
NOTE(lifetime_dependence_parsed_borrow_with_ownership_fix, none,
8328+
"use '@_lifetime(%0%1)' instead",
8329+
(StringRef, StringRef))
83278330
ERROR(lifetime_dependence_cannot_use_default_escapable_consuming, none,
83288331
"invalid lifetime dependence on an Escapable value with %0 ownership",
83298332
(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: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,30 +156,35 @@ struct ScannerImportStatementInfo {
156156
uint32_t columnNumber;
157157
};
158158

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

163164
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
165+
AccessLevel accessLevel,
164166
ImportDiagnosticLocationInfo location)
165-
: importLocations({location}), importIdentifier(importIdentifier),
166-
isExported(isExported) {}
167+
: importIdentifier(importIdentifier), importLocations({location}),
168+
isExported(isExported), accessLevel(accessLevel) {}
167169

168170
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
171+
AccessLevel accessLevel,
169172
SmallVector<ImportDiagnosticLocationInfo, 4> locations)
170-
: importLocations(locations), importIdentifier(importIdentifier),
171-
isExported(isExported) {}
173+
: importIdentifier(importIdentifier), importLocations(locations),
174+
isExported(isExported), accessLevel(accessLevel) {}
172175

173176
void addImportLocation(ImportDiagnosticLocationInfo location) {
174177
importLocations.push_back(location);
175178
}
176179

177-
/// Buffer, line & column number of the import statement
178-
SmallVector<ImportDiagnosticLocationInfo, 4> importLocations;
179180
/// Imported module string. e.g. "Foo.Bar" in 'import Foo.Bar'
180181
std::string importIdentifier;
182+
/// Buffer, line & column number of the import statement
183+
SmallVector<ImportDiagnosticLocationInfo, 4> importLocations;
181184
/// Is this an @_exported import
182185
bool isExported;
186+
/// Access level of this dependency
187+
AccessLevel accessLevel;
183188
};
184189

185190
/// Base class for the variant storage of ModuleDependencyInfo.
@@ -942,6 +947,7 @@ class ModuleDependencyInfo {
942947
/// Add a dependency on the given module, if it was not already in the set.
943948
void
944949
addOptionalModuleImport(StringRef module, bool isExported,
950+
AccessLevel accessLevel,
945951
llvm::StringSet<> *alreadyAddedModules = nullptr);
946952

947953
/// Add all of the module imports in the given source
@@ -952,12 +958,14 @@ class ModuleDependencyInfo {
952958

953959
/// Add a dependency on the given module, if it was not already in the set.
954960
void addModuleImport(ImportPath::Module module, bool isExported,
961+
AccessLevel accessLevel,
955962
llvm::StringSet<> *alreadyAddedModules = nullptr,
956963
const SourceManager *sourceManager = nullptr,
957964
SourceLoc sourceLocation = SourceLoc());
958965

959966
/// Add a dependency on the given module, if it was not already in the set.
960967
void addModuleImport(StringRef module, bool isExported,
968+
AccessLevel accessLevel,
961969
llvm::StringSet<> *alreadyAddedModules = nullptr,
962970
const SourceManager *sourceManager = nullptr,
963971
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.

include/swift/AST/PluginRegistry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class LoadedExecutablePlugin : public CompilerPlugin {
152152
: process(process), input(input), output(output) {}
153153
~PluginProcess();
154154

155+
PluginProcess(const PluginProcess &) = delete;
156+
PluginProcess &operator=(const PluginProcess &) = delete;
157+
155158
ssize_t write(const void *buf, size_t nbyte) const;
156159
ssize_t read(void *buf, size_t nbyte) const;
157160
};

include/swift/AST/Types.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ class alignas(1 << TypeAlignInBits) TypeBase
720720
return getRecursiveProperties().hasTypeVariable();
721721
}
722722

723+
// Convenience for checking whether the given type either has a type
724+
// variable or placeholder.
725+
bool hasTypeVariableOrPlaceholder() const {
726+
return hasTypeVariable() || hasPlaceholder();
727+
}
728+
723729
/// Determine where this type is a type variable or a dependent
724730
/// member root in a type variable.
725731
bool isTypeVariableOrMember();
@@ -3583,13 +3589,13 @@ class AnyFunctionType : public TypeBase {
35833589
Bits.AnyFunctionType.NumParams = NumParams;
35843590
assert(Bits.AnyFunctionType.NumParams == NumParams && "Params dropped!");
35853591

3586-
if (Info) {
3592+
if (Info && CONDITIONAL_ASSERT_enabled()) {
35873593
unsigned maxLifetimeTarget = NumParams + 1;
35883594
if (auto outputFn = Output->getAs<AnyFunctionType>()) {
35893595
maxLifetimeTarget += outputFn->getNumParams();
35903596
}
35913597
for (auto &dep : Info->getLifetimeDependencies()) {
3592-
assert(dep.getTargetIndex() < maxLifetimeTarget);
3598+
ASSERT(dep.getTargetIndex() < maxLifetimeTarget);
35933599
}
35943600
}
35953601
}

0 commit comments

Comments
 (0)