Skip to content

Commit 04f92bf

Browse files
authored
---
yaml --- r: 340795 b: refs/heads/rxwei-patch-1 c: 1ab0008 h: refs/heads/master i: 340793: 0ab5daf 340791: 4d8283d
1 parent 0785398 commit 04f92bf

File tree

91 files changed

+1718
-469
lines changed

Some content is hidden

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

91 files changed

+1718
-469
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 0a27c88163d17b55b17a5e4766c198eca48f6d1d
1018+
refs/heads/rxwei-patch-1: 1ab0008d23eea468a6a343875e2a34c54b79aa28
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ function(_add_swift_library_single target name)
13831383
# NOTE(compnerd) use the C linker language to invoke `clang` rather than
13841384
# `clang++` as we explicitly link against the C++ runtime. We were previously
13851385
# actually passing `-nostdlib++` to avoid the C++ runtime linkage.
1386-
if(SWIFTLIB_SINGLE_SDK STREQUAL ANDROID)
1386+
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "ANDROID")
13871387
set_property(TARGET "${target}" PROPERTY
13881388
LINKER_LANGUAGE "C")
13891389
else()

branches/rxwei-patch-1/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ function(_compile_swift_files
269269
# into the new runtime.
270270
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
271271
list(APPEND swift_flags "-runtime-compatibility-version" "none")
272+
list(APPEND swift_flags "-disable-autolinking-runtime-compatibility-dynamic-replacements")
272273
endif()
273274

274275
if (SWIFTFILE_IS_STDLIB_CORE OR SWIFTFILE_IS_SDK_OVERLAY)

branches/rxwei-patch-1/include/swift/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ class ASTContext final {
590590
/// Get the runtime availability of the opaque types language feature for the target platform.
591591
AvailabilityContext getOpaqueTypeAvailability();
592592

593+
/// Get the runtime availability of features introduced in the Swift 5.1
594+
/// compiler for the target platform.
595+
AvailabilityContext getSwift51Availability();
596+
593597
//===--------------------------------------------------------------------===//
594598
// Diagnostics Helper functions
595599
//===--------------------------------------------------------------------===//

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class alignas(1 << DeclAlignInBits) Decl {
605605
HasAnyUnavailableValues : 1
606606
);
607607

608-
SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1+1+1,
608+
SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1+1+1+1,
609609
/// If the module was or is being compiled with `-enable-testing`.
610610
TestingEnabled : 1,
611611

@@ -620,14 +620,18 @@ class alignas(1 << DeclAlignInBits) Decl {
620620
/// Whether all imports have been resolved. Used to detect circular imports.
621621
HasResolvedImports : 1,
622622

623-
// If the module was or is being compiled with `-enable-private-imports`.
623+
/// If the module was or is being compiled with `-enable-private-imports`.
624624
PrivateImportsEnabled : 1,
625625

626-
// If the module is compiled with `-enable-implicit-dynamic`.
626+
/// If the module is compiled with `-enable-implicit-dynamic`.
627627
ImplicitDynamicEnabled : 1,
628628

629-
// Whether the module is a system module.
630-
IsSystemModule : 1
629+
/// Whether the module is a system module.
630+
IsSystemModule : 1,
631+
632+
/// Whether the module was imported from Clang (or, someday, maybe another
633+
/// language).
634+
IsNonSwiftModule : 1
631635
);
632636

633637
SWIFT_INLINE_BITFIELD(PrecedenceGroupDecl, Decl, 1+2,
@@ -2696,7 +2700,11 @@ class ValueDecl : public Decl {
26962700
/// True if this is a C function that was imported as a member of a type in
26972701
/// Swift.
26982702
bool isImportAsMember() const;
2699-
2703+
2704+
/// Returns true if the declaration's interface type is a function type with a
2705+
/// curried self parameter.
2706+
bool hasCurriedSelf() const;
2707+
27002708
/// Get the decl for this value's opaque result type, if it has one.
27012709
OpaqueTypeDecl *getOpaqueResultTypeDecl() const;
27022710

@@ -7185,6 +7193,14 @@ inline bool ValueDecl::isImportAsMember() const {
71857193
return false;
71867194
}
71877195

7196+
inline bool ValueDecl::hasCurriedSelf() const {
7197+
if (auto *afd = dyn_cast<AbstractFunctionDecl>(this))
7198+
return afd->hasImplicitSelfDecl();
7199+
if (isa<EnumElementDecl>(this))
7200+
return true;
7201+
return false;
7202+
}
7203+
71887204
inline bool Decl::isPotentiallyOverridable() const {
71897205
if (isa<VarDecl>(this) ||
71907206
isa<SubscriptDecl>(this) ||

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,11 @@ ERROR(module_not_compiled_for_private_import,none,
792792
ERROR(import_implementation_cannot_be_exported,none,
793793
"module %0 cannot be both exported and implementation-only", (Identifier))
794794

795+
WARNING(module_not_compiled_with_library_evolution,none,
796+
"module %0 was not compiled with library evolution support; "
797+
"using it means binary compatibility for %1 can't be guaranteed",
798+
(Identifier, Identifier))
799+
795800

796801
// Operator decls
797802
ERROR(ambiguous_operator_decls,none,
@@ -4152,6 +4157,9 @@ ERROR(availability_protocol_requires_version,
41524157
NOTE(availability_protocol_requirement_here, none,
41534158
"protocol requirement here", ())
41544159

4160+
WARNING(public_decl_needs_availability, none,
4161+
"public declarations should have an availability attribute with -require-explicit-availability", ())
4162+
41554163
// This doesn't display as an availability diagnostic, but it's
41564164
// implemented there and fires when these subscripts are marked
41574165
// unavailable, so it seems appropriate to put it here.

branches/rxwei-patch-1/include/swift/AST/Expr.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,8 +2126,6 @@ class CollectionExpr : public Expr {
21262126
SourceLoc RBracketLoc;
21272127
ConcreteDeclRef Initializer;
21282128

2129-
Expr *SemanticExpr = nullptr;
2130-
21312129
/// Retrieve the intrusive pointer storage from the subtype
21322130
Expr *const *getTrailingObjectsPointer() const;
21332131
Expr **getTrailingObjectsPointer() {
@@ -2192,9 +2190,6 @@ class CollectionExpr : public Expr {
21922190
SourceRange getSourceRange() const {
21932191
return SourceRange(LBracketLoc, RBracketLoc);
21942192
}
2195-
2196-
Expr *getSemanticExpr() const { return SemanticExpr; }
2197-
void setSemanticExpr(Expr *e) { SemanticExpr = e; }
21982193

21992194
static bool classof(const Expr *e) {
22002195
return e->getKind() >= ExprKind::First_CollectionExpr &&
@@ -2272,6 +2267,8 @@ class DictionaryExpr final : public CollectionExpr,
22722267
static bool classof(const Expr *e) {
22732268
return e->getKind() == ExprKind::Dictionary;
22742269
}
2270+
2271+
Type getElementType();
22752272
};
22762273

22772274
/// Subscripting expressions like a[i] that refer to an element within a

branches/rxwei-patch-1/include/swift/AST/IRGenOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class IRGenOptions {
228228

229229
/// Pull in runtime compatibility shim libraries by autolinking.
230230
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;
231+
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
231232

232233
IRGenOptions()
233234
: DWARFVersion(2), OutputKind(IRGenOutputKind::LLVMAssembly),

branches/rxwei-patch-1/include/swift/AST/Module.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ class ModuleDecl : public DeclContext, public TypeDecl {
337337
Bits.ModuleDecl.IsSystemModule = flag;
338338
}
339339

340+
/// Returns true if this module is a non-Swift module that was imported into
341+
/// Swift.
342+
///
343+
/// Right now that's just Clang modules.
344+
bool isNonSwiftModule() const {
345+
return Bits.ModuleDecl.IsNonSwiftModule;
346+
}
347+
/// \see #isNonSwiftModule
348+
void setIsNonSwiftModule(bool flag = true) {
349+
Bits.ModuleDecl.IsNonSwiftModule = flag;
350+
}
351+
340352
bool isResilient() const {
341353
return getResilienceStrategy() != ResilienceStrategy::Default;
342354
}

branches/rxwei-patch-1/include/swift/Basic/LangOptions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ namespace swift {
9696
/// Enable 'availability' restrictions for App Extensions.
9797
bool EnableAppExtensionRestrictions = false;
9898

99+
/// Require public declarations to declare an introduction OS version.
100+
bool RequireExplicitAvailability = false;
101+
102+
/// Introduction platform and version to suggest as fix-it
103+
/// when using RequireExplicitAvailability.
104+
std::string RequireExplicitAvailabilityTarget;
105+
99106
///
100107
/// Support for alternate usage modes
101108
///

branches/rxwei-patch-1/include/swift/Option/Options.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ def enable_library_evolution : Flag<["-"], "enable-library-evolution">,
312312
Flags<[FrontendOption, ModuleInterfaceOption]>,
313313
HelpText<"Build the module to allow binary-compatible library evolution">;
314314

315+
def require_explicit_availability : Flag<["-"], "require-explicit-availability">,
316+
Flags<[FrontendOption, NoInteractiveOption]>,
317+
HelpText<"Require explicit availability on public declarations">;
318+
def require_explicit_availability_target : Separate<["-"], "require-explicit-availability-target">,
319+
Flags<[FrontendOption, NoInteractiveOption]>,
320+
HelpText<"Suggest fix-its adding @available(<target>, *) to public declarations without availability">,
321+
MetaVarName<"<target>">;
322+
315323
def module_name : Separate<["-"], "module-name">,
316324
Flags<[FrontendOption, ModuleInterfaceOption]>,
317325
HelpText<"Name of the module to build">;
@@ -904,4 +912,10 @@ def disable_autolinking_runtime_compatibility : Flag<["-"], "disable-autolinking
904912
Flags<[FrontendOption]>,
905913
HelpText<"Do not use autolinking for runtime compatibility libraries">;
906914

915+
def disable_autolinking_runtime_compatibility_dynamic_replacements
916+
: Flag<[ "-" ], "disable-autolinking-runtime-compatibility-dynamic-replacements">,
917+
Flags<[ FrontendOption ]>,
918+
HelpText<"Do not use autolinking for the dynamic replacement runtime "
919+
"compatibility library">;
920+
907921
include "FrontendOptions.td"

branches/rxwei-patch-1/include/swift/Runtime/Exclusivity.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ void swift_beginAccess(void *pointer, ValueBuffer *buffer,
4444
/// replacement function if it should be called.
4545
/// Returns null if the original function (which is passed in \p CurrFn) should
4646
/// be called.
47+
#ifdef __APPLE__
48+
__attribute__((weak_import))
49+
#endif
4750
SWIFT_RUNTIME_EXPORT
4851
char *swift_getFunctionReplacement(char **ReplFnPtr, char *CurrFn);
4952

5053
/// Returns the original function of a replaced function, which is loaded from
5154
/// \p OrigFnPtr.
5255
/// This function is called from a replacement function to call the original
5356
/// function.
57+
#ifdef __APPLE__
58+
__attribute__((weak_import))
59+
#endif
5460
SWIFT_RUNTIME_EXPORT
5561
char *swift_getOrigOfReplaceable(char **OrigFnPtr);
5662

branches/rxwei-patch-1/include/swift/Runtime/RuntimeFnWrappersGen.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
namespace swift {
2323

2424
class AvailabilityContext;
25+
class ASTContext;
26+
27+
enum class RuntimeAvailability {
28+
AlwaysAvailable,
29+
AvailableByCompatibilityLibrary,
30+
ConditionallyAvailable
31+
};
2532

2633
/// Generate an llvm declaration for a runtime entry with a
2734
/// given name, return types, argument types, attributes and
@@ -30,7 +37,8 @@ llvm::Constant *getRuntimeFn(llvm::Module &Module,
3037
llvm::Constant *&cache,
3138
char const *name,
3239
llvm::CallingConv::ID cc,
33-
bool isWeakLinked,
40+
RuntimeAvailability availability,
41+
ASTContext *context,
3442
llvm::ArrayRef<llvm::Type*> retTypes,
3543
llvm::ArrayRef<llvm::Type*> argTypes,
3644
llvm::ArrayRef<llvm::Attribute::AttrKind> attrs);

branches/rxwei-patch-1/include/swift/Runtime/RuntimeFunctions.def

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ FUNCTION(GetGenericMetadata, swift_getGenericMetadata,
638638
// const OpaqueTypeDescriptor *descriptor,
639639
// uintptr_t index);
640640
FUNCTION(GetOpaqueTypeMetadata, swift_getOpaqueTypeMetadata,
641-
SwiftCC, OpaqueTypeAvailability,
641+
SwiftCC, ConditionallyAvailable,
642642
RETURNS(TypeMetadataResponseTy),
643643
ARGS(SizeTy, Int8PtrTy, OpaqueTypeDescriptorPtrTy, SizeTy),
644644
ATTRS(NoUnwind, ReadOnly))
@@ -647,7 +647,7 @@ FUNCTION(GetOpaqueTypeMetadata, swift_getOpaqueTypeMetadata,
647647
// const OpaqueTypeDescriptor *descriptor,
648648
// uintptr_t index);
649649
FUNCTION(GetOpaqueTypeConformance, swift_getOpaqueTypeConformance,
650-
SwiftCC, OpaqueTypeAvailability,
650+
SwiftCC, ConditionallyAvailable,
651651
RETURNS(WitnessTablePtrTy),
652652
ARGS(Int8PtrTy, OpaqueTypeDescriptorPtrTy, SizeTy),
653653
ATTRS(NoUnwind, ReadOnly))
@@ -1225,12 +1225,14 @@ FUNCTION(EndAccess, swift_endAccess, C_CC, AlwaysAvailable,
12251225
ARGS(getFixedBufferTy()->getPointerTo()),
12261226
ATTRS(NoUnwind))
12271227

1228-
FUNCTION(GetOrigOfReplaceable, swift_getOrigOfReplaceable, C_CC, AlwaysAvailable,
1228+
FUNCTION(GetOrigOfReplaceable, swift_getOrigOfReplaceable, C_CC,
1229+
AvailableByCompatibilityLibrary,
12291230
RETURNS(FunctionPtrTy),
12301231
ARGS(FunctionPtrTy->getPointerTo()),
12311232
ATTRS(NoUnwind))
12321233

1233-
FUNCTION(GetReplacement, swift_getFunctionReplacement, C_CC, AlwaysAvailable,
1234+
FUNCTION(GetReplacement, swift_getFunctionReplacement, C_CC,
1235+
AvailableByCompatibilityLibrary,
12341236
RETURNS(FunctionPtrTy),
12351237
ARGS(FunctionPtrTy->getPointerTo(), FunctionPtrTy),
12361238
ATTRS(NoUnwind))

branches/rxwei-patch-1/lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,16 +2127,16 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
21272127
OS << '\n';
21282128
printRec(elt);
21292129
}
2130-
printSemanticExpr(E->getSemanticExpr());
21312130
PrintWithColorRAII(OS, ParenthesisColor) << ')';
21322131
}
21332132
void visitDictionaryExpr(DictionaryExpr *E) {
21342133
printCommon(E, "dictionary_expr");
2134+
PrintWithColorRAII(OS, LiteralValueColor) << " initializer=";
2135+
E->getInitializer().dump(PrintWithColorRAII(OS, LiteralValueColor).getOS());
21352136
for (auto elt : E->getElements()) {
21362137
OS << '\n';
21372138
printRec(elt);
21382139
}
2139-
printSemanticExpr(E->getSemanticExpr());
21402140
PrintWithColorRAII(OS, ParenthesisColor) << ')';
21412141
}
21422142
void visitSubscriptExpr(SubscriptExpr *E) {

branches/rxwei-patch-1/lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
525525
}
526526

527527
Expr *visitCollectionExpr(CollectionExpr *E) {
528-
HANDLE_SEMANTIC_EXPR(E);
529-
530528
for (auto &elt : E->getElements())
531529
if (Expr *Sub = doIt(elt))
532530
elt = Sub;

branches/rxwei-patch-1/lib/AST/Availability.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ AvailabilityContext AvailabilityInference::inferForType(Type t) {
218218
}
219219

220220
AvailabilityContext ASTContext::getOpaqueTypeAvailability() {
221+
return getSwift51Availability();
222+
}
223+
224+
AvailabilityContext ASTContext::getSwift51Availability() {
221225
auto target = LangOpts.Target;
222226

223227
if (target.isMacOSX()) {

branches/rxwei-patch-1/lib/AST/Expr.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,19 @@ Type ArrayExpr::getElementType() {
14851485
.subst(init.getSubstitutions());
14861486
}
14871487

1488+
Type DictionaryExpr::getElementType() {
1489+
auto init = getInitializer();
1490+
if (!init)
1491+
return Type();
1492+
1493+
auto *decl = cast<ConstructorDecl>(init.getDecl());
1494+
return decl->getMethodInterfaceType()
1495+
->getAs<AnyFunctionType>()
1496+
->getParams()[0]
1497+
.getPlainType()
1498+
.subst(init.getSubstitutions());
1499+
}
1500+
14881501
DictionaryExpr *DictionaryExpr::create(ASTContext &C, SourceLoc LBracketLoc,
14891502
ArrayRef<Expr*> Elements,
14901503
ArrayRef<SourceLoc> CommaLocs,

branches/rxwei-patch-1/lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,8 +1672,7 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
16721672
Identifier name = SwiftContext.getIdentifier((*clangModule).Name);
16731673
result = ModuleDecl::create(name, SwiftContext);
16741674
result->setIsSystemModule(clangModule->IsSystem);
1675-
// Silence error messages about testably importing a Clang module.
1676-
result->setTestingEnabled();
1675+
result->setIsNonSwiftModule();
16771676
result->setHasResolvedImports();
16781677

16791678
wrapperUnit =
@@ -1842,8 +1841,7 @@ ClangModuleUnit *ClangImporter::Implementation::getWrapperForModule(
18421841
Identifier name = SwiftContext.getIdentifier(underlying->Name);
18431842
auto wrapper = ModuleDecl::create(name, SwiftContext);
18441843
wrapper->setIsSystemModule(underlying->IsSystem);
1845-
// Silence error messages about testably importing a Clang module.
1846-
wrapper->setTestingEnabled();
1844+
wrapper->setIsNonSwiftModule();
18471845
wrapper->setHasResolvedImports();
18481846

18491847
auto file = new (SwiftContext) ClangModuleUnit(*wrapper, *this,

branches/rxwei-patch-1/lib/DWARFImporter/DWARFImporter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ class DWARFImporter::Implementation {
120120
return it->second->getParentModule();
121121

122122
auto *decl = ModuleDecl::create(name, SwiftContext);
123-
// Silence error messages about testably importing a Clang module.
124-
decl->setTestingEnabled();
123+
decl->setIsNonSwiftModule();
125124
decl->setHasResolvedImports();
126125
auto wrapperUnit = new (SwiftContext) DWARFModuleUnit(*decl);
127126
ModuleWrappers.insert({name, wrapperUnit});

0 commit comments

Comments
 (0)