Skip to content

Commit 4fdc97a

Browse files
authored
Merge pull request #2166 from swiftwasm/main
[pull] swiftwasm from main
2 parents 9561605 + 1f71144 commit 4fdc97a

30 files changed

+716
-120
lines changed

docs/ContinuousIntegration.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
- [Linting](#linting)
1212
- [Source Compatibility Testing](#source-compatibility-testing)
1313
- [Sourcekit Stress Testing](#sourcekit-stress-testing)
14-
- [Specific Preset Testing](#specific-preset-testing)
15-
- [Running Non-Executable Device Tests](#running-non-executable-device-tests)
1614
- [Build Swift Toolchain](#build-swift-toolchain)
15+
- [Build and Test Stdlib against Snapshot Toolchain](#build-and-test-stdlib-against-snapshot-toolchain)
16+
- [Specific Preset Testing](#specific-preset-testing)
17+
- [Specific Preset Testing against a Snapshot Toolchain](#specific-preset-testing-against-a-snapshot-toolchain)
18+
- [Running Non-Executable Device Tests using Specific Preset Testing](#running-non-executable-device-tests-using-specific-preset-testing)
19+
- [Build and Test the Minimal Freestanding Stdlib using Toolchain Specific Preset Testing](#build-and-test-the-minimal-freestanding-stdlib-using-toolchain-specific-preset-testing)
1720
- [Testing Compiler Performance](#testing-compiler-performance)
1821
- [Swift Community Hosted CI Pull Request Testing](#swift-community-hosted-ci-pull-request-testing)
1922
- [Cross Repository Testing](#cross-repository-testing)
@@ -154,6 +157,21 @@ Platform | Comment | Check Status
154157
------------ | ------- | ------------
155158
macOS platform | @swift-ci Please Sourcekit Stress test | Swift Sourcekit Stress Tester on macOS Platform
156159

160+
### Build Swift Toolchain
161+
162+
Platform | Comment | Check Status
163+
------------ | ------- | ------------
164+
macOS platform | @swift-ci Please Build Toolchain macOS Platform| Swift Build Toolchain macOS Platform
165+
Linux platform | @swift-ci Please Build Toolchain Linux Platform| Swift Build Toolchain Linux Platform
166+
167+
### Build and Test Stdlib against Snapshot Toolchain
168+
169+
To test/build the stdlib for a branch that changes only the stdlib using a last known good snapshot toolchain:
170+
171+
Platform | Comment | Check Status
172+
------------ | ------- | ------------
173+
macOS platform | @swift-ci Please test stdlib with toolchain| Swift Test stdlib with toolchain macOS Platform
174+
157175
### Specific Preset Testing
158176

159177
Platform | Comment | Check Status
@@ -169,7 +187,23 @@ preset=buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx,single-thread
169187
@swift-ci Please test with preset macOS
170188
```
171189

172-
### Running Non-Executable Device Tests
190+
191+
### Specific Preset Testing against a Snapshot Toolchain
192+
193+
One can also run an arbitrary preset against a snapshot toolchain
194+
195+
Platform | Comment | Check Status
196+
------------ | ------- | ------------
197+
macOS platform | preset=<preset> <br> @swift-ci Please test with toolchain and preset| Swift Test stdlib with toolchain macOS Platform (Preset)
198+
199+
For example:
200+
201+
```
202+
preset=$PRESET_NAME
203+
@swift-ci Please test with toolchain and preset
204+
```
205+
206+
### Running Non-Executable Device Tests using Specific Preset Testing
173207

174208
Using the specific preset testing, one can run non-executable device tests by
175209
telling swift-ci:
@@ -179,12 +213,14 @@ preset=buildbot,tools=RA,stdlib=RD,test=non_executable
179213
@swift-ci Please test with preset macOS
180214
```
181215

182-
### Build Swift Toolchain
216+
### Build and Test the Minimal Freestanding Stdlib using Toolchain Specific Preset Testing
183217

184-
Platform | Comment | Check Status
185-
------------ | ------- | ------------
186-
macOS platform | @swift-ci Please Build Toolchain macOS Platform| Swift Build Toolchain macOS Platform
187-
Linux platform | @swift-ci Please Build Toolchain Linux Platform| Swift Build Toolchain Linux Platform
218+
To test the minimal freestanding stdlib on macho, you can use the support for running a miscellanous preset against a snapshot toolchain.
219+
220+
```
221+
preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
222+
@swift-ci please test with toolchain and preset
223+
```
188224

189225
### Testing Compiler Performance
190226

include/swift/AST/Availability.h

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -182,46 +182,19 @@ class VersionRange {
182182

183183
/// Records the reason a declaration is potentially unavailable.
184184
class UnavailabilityReason {
185-
public:
186-
enum class Kind {
187-
/// The declaration is potentially unavailable because it requires an OS
188-
/// version range that is not guaranteed by the minimum deployment
189-
/// target.
190-
RequiresOSVersionRange,
191-
192-
/// The declaration is potentially unavailable because it is explicitly
193-
/// weakly linked.
194-
ExplicitlyWeakLinked
195-
};
196-
197185
private:
198-
// A value of None indicates the declaration is potentially unavailable
199-
// because it is explicitly weak linked.
200-
Optional<VersionRange> RequiredDeploymentRange;
186+
VersionRange RequiredDeploymentRange;
201187

202-
UnavailabilityReason(const Optional<VersionRange> &RequiredDeploymentRange)
188+
explicit UnavailabilityReason(const VersionRange RequiredDeploymentRange)
203189
: RequiredDeploymentRange(RequiredDeploymentRange) {}
204190

205191
public:
206-
static UnavailabilityReason explicitlyWeaklyLinked() {
207-
return UnavailabilityReason(None);
208-
}
209-
210192
static UnavailabilityReason requiresVersionRange(const VersionRange Range) {
211193
return UnavailabilityReason(Range);
212194
}
213195

214-
Kind getReasonKind() const {
215-
if (RequiredDeploymentRange.hasValue()) {
216-
return Kind::RequiresOSVersionRange;
217-
} else {
218-
return Kind::ExplicitlyWeakLinked;
219-
}
220-
}
221-
222196
const VersionRange &getRequiredOSVersionRange() const {
223-
assert(getReasonKind() == Kind::RequiresOSVersionRange);
224-
return RequiredDeploymentRange.getValue();
197+
return RequiredDeploymentRange;
225198
}
226199
};
227200

include/swift/AST/DiagnosticsSema.def

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,6 +5040,39 @@ ERROR(availabilty_string_subscript_migration, none,
50405040
"subscripts returning String were obsoleted in Swift 4; explicitly "
50415041
"construct a String from subscripted result", ())
50425042

5043+
// Conformance availability checking diagnostics
5044+
5045+
ERROR(conformance_availability_unavailable, none,
5046+
"conformance of %0 to %1 is unavailable"
5047+
"%select{ in %3|}2%select{|: %4}4",
5048+
(Type, Type, bool, StringRef, StringRef))
5049+
5050+
NOTE(conformance_availability_marked_unavailable, none,
5051+
"conformance of %0 to %1 has been explicitly marked "
5052+
"unavailable here", (Type, Type))
5053+
5054+
NOTE(conformance_availability_introduced_in_version, none,
5055+
"conformance of %0 to %1 was introduced in %2 %3",
5056+
(Type, Type, StringRef, llvm::VersionTuple))
5057+
5058+
NOTE(conformance_availability_obsoleted, none,
5059+
"conformance of %0 to %1 was obsoleted in %2 %3",
5060+
(Type, Type, StringRef, llvm::VersionTuple))
5061+
5062+
WARNING(conformance_availability_deprecated, none,
5063+
"conformance of %0 to %1 %select{is|%select{is|was}4}2 "
5064+
"deprecated%select{| in %3%select{| %5}4}2%select{|: %6}6",
5065+
(Type, Type, bool, StringRef, bool, llvm::VersionTuple,
5066+
StringRef))
5067+
5068+
ERROR(conformance_availability_only_version_newer, none,
5069+
"conformance of %0 to %1 is only available in %2 %3 or newer",
5070+
(Type, Type, StringRef, llvm::VersionTuple))
5071+
5072+
WARNING(conformance_availability_only_version_newer_warn, none,
5073+
"conformance of %0 to %1 is only available in %2 %3 or newer",
5074+
(Type, Type, StringRef, llvm::VersionTuple))
5075+
50435076
//------------------------------------------------------------------------------
50445077
// MARK: @discardableResult
50455078
//------------------------------------------------------------------------------

include/swift/Basic/LangOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ namespace swift {
9595
/// Disable API availability checking.
9696
bool DisableAvailabilityChecking = false;
9797

98+
/// Should conformance availability violations be diagnosed as errors?
99+
bool EnableConformanceAvailabilityErrors = false;
100+
98101
/// Maximum number of typo corrections we are allowed to perform.
99102
/// This is disabled by default until we can get typo-correction working within acceptable performance bounds.
100103
unsigned TypoCorrectionLimit = 0;
@@ -242,6 +245,9 @@ namespace swift {
242245
/// Enable experimental concurrency model.
243246
bool EnableExperimentalConcurrency = false;
244247

248+
/// Disable the implicit import of the _Concurrency module.
249+
bool DisableImplicitConcurrencyModuleImport = false;
250+
245251
/// Should we check the target OSs of serialized modules to see that they're
246252
/// new enough?
247253
bool EnableTargetOSChecking = true;

include/swift/Option/FrontendOptions.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ def disable_clangimporter_source_import : Flag<["-"],
286286
"disable-clangimporter-source-import">,
287287
HelpText<"Disable ClangImporter and forward all requests straight the DWARF importer.">;
288288

289+
def disable_implicit_concurrency_module_import : Flag<["-"],
290+
"disable-implicit-concurrency-module-import">,
291+
HelpText<"Disable the implicit import of the _Concurrency module.">;
292+
289293
def disable_arc_opts : Flag<["-"], "disable-arc-opts">,
290294
HelpText<"Don't run SIL ARC optimization passes.">;
291295
def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">,
@@ -405,6 +409,14 @@ def disable_availability_checking : Flag<["-"],
405409
"disable-availability-checking">,
406410
HelpText<"Disable checking for potentially unavailable APIs">;
407411

412+
def enable_conformance_availability_errors : Flag<["-"],
413+
"enable-conformance-availability-errors">,
414+
HelpText<"Diagnose conformance availability violations as errors">;
415+
416+
def disable_conformance_availability_errors : Flag<["-"],
417+
"disable-conformance-availability-errors">,
418+
HelpText<"Diagnose conformance availability violations as warnings">;
419+
408420
def report_errors_to_debugger : Flag<["-"], "report-errors-to-debugger">,
409421
HelpText<"Deprecated, will be removed in future versions.">;
410422

include/swift/SIL/SILValue.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,8 @@ class Operand {
692692
/// potentially have to the UseLifetimeConstraint associated with that
693693
/// ownership kind
694694
///
695-
/// NOTE: This is implemented in OperandOwnershipKindMapClassifier.cpp.
696-
///
697-
/// NOTE: The default argument isSubValue is a temporary staging flag that
698-
/// will be removed once borrow scoping is checked by the normal verifier.
699-
OperandOwnershipKindMap
700-
getOwnershipKindMap(bool isForwardingSubValue = false) const;
695+
/// NOTE: This is implemented in OperandOwnership.cpp.
696+
OperandOwnershipKindMap getOwnershipKindMap() const;
701697

702698
/// Returns true if this operand acts as a use that consumes its associated
703699
/// value.

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3693,7 +3693,7 @@ void ClangImporter::Implementation::lookupValue(
36933693
if (name.isOperator()) {
36943694
for (auto entry : table.lookupMemberOperators(name.getBaseName())) {
36953695
if (isVisibleClangEntry(entry)) {
3696-
if (auto decl = dyn_cast<ValueDecl>(
3696+
if (auto decl = dyn_cast_or_null<ValueDecl>(
36973697
importDeclReal(entry->getMostRecentDecl(), CurrentVersion)))
36983698
consumer.foundDecl(decl, DeclVisibilityKind::VisibleAtTopLevel);
36993699
}

lib/ClangImporter/ImportType.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,8 +1814,20 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
18141814
// Import the parameter type into Swift.
18151815
Type swiftParamTy;
18161816
bool isParamTypeImplicitlyUnwrapped = false;
1817-
if (auto *templateParamType =
1818-
dyn_cast<clang::TemplateTypeParmType>(paramTy)) {
1817+
1818+
auto referenceType = dyn_cast<clang::ReferenceType>(paramTy);
1819+
if (referenceType &&
1820+
isa<clang::TemplateTypeParmType>(referenceType->getPointeeType())) {
1821+
auto pointeeType = referenceType->getPointeeType();
1822+
auto templateParamType = cast<clang::TemplateTypeParmType>(pointeeType);
1823+
PointerTypeKind pointerKind = pointeeType.getQualifiers().hasConst()
1824+
? PTK_UnsafePointer
1825+
: PTK_UnsafeMutablePointer;
1826+
auto genericType =
1827+
findGenericTypeInGenericDecls(templateParamType, genericParams);
1828+
swiftParamTy = genericType->wrapInPointer(pointerKind);
1829+
} else if (auto *templateParamType =
1830+
dyn_cast<clang::TemplateTypeParmType>(paramTy)) {
18191831
swiftParamTy =
18201832
findGenericTypeInGenericDecls(templateParamType, genericParams);
18211833
} else {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
376376
Opts.EnableExperimentalConcurrency |=
377377
Args.hasArg(OPT_enable_experimental_concurrency);
378378

379+
Opts.DisableImplicitConcurrencyModuleImport |=
380+
Args.hasArg(OPT_disable_implicit_concurrency_module_import);
381+
379382
Opts.EnableSubstSILFunctionTypesForFunctionValues |=
380383
Args.hasArg(OPT_enable_subst_sil_function_types_for_function_values);
381384

@@ -391,6 +394,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
391394
Opts.DisableAvailabilityChecking |=
392395
Args.hasArg(OPT_disable_availability_checking);
393396

397+
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
398+
OPT_disable_conformance_availability_errors)) {
399+
Opts.EnableConformanceAvailabilityErrors
400+
= A->getOption().matches(OPT_enable_conformance_availability_errors);
401+
}
402+
394403
if (auto A = Args.getLastArg(OPT_enable_access_control,
395404
OPT_disable_access_control)) {
396405
Opts.EnableAccessControl

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ CompilerInstance::openModuleDoc(const InputFile &input) {
708708
}
709709

710710
bool CompilerInvocation::shouldImportSwiftConcurrency() const {
711-
return getLangOptions().EnableExperimentalConcurrency;
711+
return getLangOptions().EnableExperimentalConcurrency
712+
&& !getLangOptions().DisableImplicitConcurrencyModuleImport;
712713
}
713714

714715
/// Implicitly import the SwiftOnoneSupport module in non-optimized

0 commit comments

Comments
 (0)