Skip to content

Commit 9b73fef

Browse files
authored
---
yaml --- r: 340830 b: refs/heads/rxwei-patch-1 c: 379d88c h: refs/heads/master
1 parent 76360b7 commit 9b73fef

File tree

69 files changed

+1417
-430
lines changed

Some content is hidden

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

69 files changed

+1417
-430
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: fca8106f951c0d6c43a70a43053cee42d3e189b8
1018+
refs/heads/rxwei-patch-1: 379d88cb122447bdd507b835e2f7b651ec09c6a0
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,17 @@ function(_add_swift_executable_single name)
23462346
target_link_libraries("${name}" PRIVATE ${SWIFTEXE_SINGLE_LINK_LIBRARIES})
23472347
swift_common_llvm_config("${name}" ${SWIFTEXE_SINGLE_LLVM_LINK_COMPONENTS})
23482348

2349+
# NOTE(compnerd) use the C linker language to invoke `clang` rather than
2350+
# `clang++` as we explicitly link against the C++ runtime. We were previously
2351+
# actually passing `-nostdlib++` to avoid the C++ runtime linkage.
2352+
if(SWIFTEXE_SINGLE_SDK STREQUAL ANDROID)
2353+
set_property(TARGET "${name}" PROPERTY
2354+
LINKER_LANGUAGE "C")
2355+
else()
2356+
set_property(TARGET "${name}" PROPERTY
2357+
LINKER_LANGUAGE "CXX")
2358+
endif()
2359+
23492360
set_target_properties(${name} PROPERTIES FOLDER "Swift executables")
23502361
endfunction()
23512362

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ SIMPLE_DECL_ATTR(_alwaysEmitIntoClient, AlwaysEmitIntoClient,
396396
83)
397397

398398
SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
399-
OnImport | UserInaccessible,
399+
OnImport | OnFunc | OnConstructor | OnVar | OnSubscript | UserInaccessible,
400400
84)
401401
DECL_ATTR(_custom, Custom,
402402
OnAnyDecl | UserInaccessible,

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,20 @@ class ValueDecl : public Decl {
27002700
/// True if this is a C function that was imported as a member of a type in
27012701
/// Swift.
27022702
bool isImportAsMember() const;
2703-
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+
2708+
/// Returns true if the declaration has a parameter list associated with it.
2709+
///
2710+
/// Note that not all declarations with function interface types have
2711+
/// parameter lists, for example an enum element without associated values.
2712+
bool hasParameterList() const;
2713+
2714+
/// Returns the number of curry levels in the declaration's interface type.
2715+
unsigned getNumCurryLevels() const;
2716+
27042717
/// Get the decl for this value's opaque result type, if it has one.
27052718
OpaqueTypeDecl *getOpaqueResultTypeDecl() const;
27062719

@@ -7189,6 +7202,29 @@ inline bool ValueDecl::isImportAsMember() const {
71897202
return false;
71907203
}
71917204

7205+
inline bool ValueDecl::hasCurriedSelf() const {
7206+
if (auto *afd = dyn_cast<AbstractFunctionDecl>(this))
7207+
return afd->hasImplicitSelfDecl();
7208+
if (isa<EnumElementDecl>(this))
7209+
return true;
7210+
return false;
7211+
}
7212+
7213+
inline bool ValueDecl::hasParameterList() const {
7214+
if (auto *eed = dyn_cast<EnumElementDecl>(this))
7215+
return eed->hasAssociatedValues();
7216+
return isa<AbstractFunctionDecl>(this) || isa<SubscriptDecl>(this);
7217+
}
7218+
7219+
inline unsigned ValueDecl::getNumCurryLevels() const {
7220+
unsigned curryLevels = 0;
7221+
if (hasParameterList())
7222+
curryLevels++;
7223+
if (hasCurriedSelf())
7224+
curryLevels++;
7225+
return curryLevels;
7226+
}
7227+
71927228
inline bool Decl::isPotentiallyOverridable() const {
71937229
if (isa<VarDecl>(this) ||
71947230
isa<SubscriptDecl>(this) ||
@@ -7253,7 +7289,7 @@ inline EnumElementDecl *EnumDecl::getUniqueElement(bool hasValue) const {
72537289
}
72547290

72557291
/// Retrieve parameter declaration from the given source at given index.
7256-
const ParamDecl *getParameterAt(ValueDecl *source, unsigned index);
7292+
const ParamDecl *getParameterAt(const ValueDecl *source, unsigned index);
72577293

72587294
/// Display Decl subclasses.
72597295
void simple_display(llvm::raw_ostream &out, const Decl *decl);

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
//
1818
//===----------------------------------------------------------------------===//
1919

20-
#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE)))
21-
# error Must define either DIAG or the set {ERROR,WARNING,NOTE}
20+
#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE) && defined(REMARK)))
21+
# error Must define either DIAG or the set {ERROR,WARNING,NOTE,REMARK}
2222
#endif
2323

2424
#ifndef ERROR
@@ -36,12 +36,19 @@
3636
DIAG(NOTE,ID,Options,Text,Signature)
3737
#endif
3838

39+
#ifndef REMARK
40+
# define REMARK(ID,Options,Text,Signature) \
41+
DIAG(REMARK,ID,Options,Text,Signature)
42+
#endif
43+
3944
WARNING(warning_from_clang,none,
4045
"%0", (StringRef))
4146
ERROR(error_from_clang,none,
4247
"%0", (StringRef))
4348
NOTE(note_from_clang,none,
4449
"%0", (StringRef))
50+
REMARK(remark_from_clang,none,
51+
"%0", (StringRef))
4552

4653
ERROR(clang_cannot_build_module,Fatal,
4754
"could not build %select{C|Objective-C}0 module '%1'", (bool, StringRef))

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,18 @@ WARNING(warn_implementation_only_conflict,none,
24902490
NOTE(implementation_only_conflict_here,none,
24912491
"imported as implementation-only here", ())
24922492

2493+
ERROR(implementation_only_decl_non_override,none,
2494+
"'@_implementationOnly' can only be used on overrides", ())
2495+
ERROR(implementation_only_override_changed_type,none,
2496+
"'@_implementationOnly' override must have the same type as the "
2497+
"declaration it overrides (%0)", (Type))
2498+
ERROR(implementation_only_override_without_attr,none,
2499+
"override of '@_implementationOnly' %0 should also be declared "
2500+
"'@_implementationOnly'", (DescriptiveDeclKind))
2501+
ERROR(implementation_only_override_import_without_attr,none,
2502+
"override of %0 imported as implementation-only must be declared "
2503+
"'@_implementationOnly'", (DescriptiveDeclKind))
2504+
24932505
// Derived conformances
24942506
ERROR(cannot_synthesize_init_in_extension_of_nonfinal,none,
24952507
"implementation of %0 for non-final class cannot be automatically "
@@ -3643,6 +3655,10 @@ ERROR(unsupported_opaque_type,none,
36433655
ERROR(opaque_type_unsupported_pattern,none,
36443656
"'some' type can only be declared on a single property declaration", ())
36453657

3658+
ERROR(opaque_type_in_protocol_requirement,none,
3659+
"'some' type cannot be the return type of a protocol requirement; did you mean to add an associated type?",
3660+
())
3661+
36463662
// SIL
36473663
ERROR(opened_non_protocol,none,
36483664
"@opened cannot be applied to non-protocol type %0", (Type))

branches/rxwei-patch-1/include/swift/Parse/Parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ class Parser {
10121012
ParserResult<VarDecl> parseDeclVarGetSet(Pattern *pattern,
10131013
ParseDeclOptions Flags,
10141014
SourceLoc StaticLoc,
1015+
StaticSpellingKind StaticSpelling,
10151016
SourceLoc VarLoc,
10161017
bool hasInitializer,
10171018
const DeclAttributes &Attributes,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ PrintOptions PrintOptions::printParseableInterfaceFile(bool preferTypeRepr) {
126126

127127
class ShouldPrintForParseableInterface : public ShouldPrintChecker {
128128
bool shouldPrint(const Decl *D, const PrintOptions &options) override {
129+
// Skip anything that is marked `@_implementationOnly` itself.
130+
if (D->getAttrs().hasAttribute<ImplementationOnlyAttr>())
131+
return false;
132+
129133
// Skip anything that isn't 'public' or '@usableFromInline'.
130134
if (auto *VD = dyn_cast<ValueDecl>(D)) {
131135
if (!isPublicOrUsableFromInline(VD)) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,7 +2400,7 @@ CanType ValueDecl::getOverloadSignatureType() const {
24002400
/*topLevelFunction=*/true,
24012401
isMethod,
24022402
/*isInitializer=*/isa<ConstructorDecl>(afd),
2403-
isMethod ? 2 : 1)->getCanonicalType();
2403+
getNumCurryLevels())->getCanonicalType();
24042404
}
24052405

24062406
if (isa<AbstractStorageDecl>(this)) {
@@ -2416,7 +2416,7 @@ CanType ValueDecl::getOverloadSignatureType() const {
24162416
/*topLevelFunction=*/true,
24172417
/*isMethod=*/false,
24182418
/*isInitializer=*/false,
2419-
1)->getCanonicalType();
2419+
getNumCurryLevels())->getCanonicalType();
24202420
}
24212421

24222422
// We want to curry the default signature type with the 'self' type of the
@@ -2430,7 +2430,7 @@ CanType ValueDecl::getOverloadSignatureType() const {
24302430
if (isa<EnumElementDecl>(this)) {
24312431
auto mappedType = mapSignatureFunctionType(
24322432
getASTContext(), getInterfaceType(), /*topLevelFunction=*/false,
2433-
/*isMethod=*/false, /*isInitializer=*/false, /*curryLevels=*/0);
2433+
/*isMethod=*/false, /*isInitializer=*/false, getNumCurryLevels());
24342434
return mappedType->getCanonicalType();
24352435
}
24362436

@@ -6108,7 +6108,7 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
61086108
return DeclName();
61096109
}
61106110

6111-
const ParamDecl *swift::getParameterAt(ValueDecl *source, unsigned index) {
6111+
const ParamDecl *swift::getParameterAt(const ValueDecl *source, unsigned index) {
61126112
const ParameterList *paramList;
61136113
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(source)) {
61146114
paramList = AFD->getParameters();

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,8 @@ ResilienceExpansion DeclContext::getResilienceExpansion() const {
317317
if (isa<DefaultArgumentInitializer>(dc)) {
318318
dc = dc->getParent();
319319

320-
const ValueDecl *VD;
321-
if (auto *FD = dyn_cast<AbstractFunctionDecl>(dc)) {
322-
VD = FD;
323-
} else if (auto *EED = dyn_cast<EnumElementDecl>(dc)) {
324-
VD = EED;
325-
} else {
326-
VD = cast<SubscriptDecl>(dc);
327-
}
320+
auto *VD = cast<ValueDecl>(dc->getAsDecl());
321+
assert(VD->hasParameterList());
328322

329323
auto access =
330324
VD->getFormalAccessScope(/*useDC=*/nullptr,

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -743,26 +743,26 @@ ParameterListInfo::ParameterListInfo(
743743
if (!paramOwner)
744744
return;
745745

746+
// If the decl has a curried self, but we're not allowed to skip it, return.
747+
if (paramOwner->hasCurriedSelf() && !skipCurriedSelf)
748+
return;
749+
746750
// Find the corresponding parameter list.
747751
const ParameterList *paramList = nullptr;
748752
if (auto *func = dyn_cast<AbstractFunctionDecl>(paramOwner)) {
749-
if (func->hasImplicitSelfDecl()) {
750-
if (skipCurriedSelf)
751-
paramList = func->getParameters();
752-
} else if (!skipCurriedSelf)
753-
paramList = func->getParameters();
753+
paramList = func->getParameters();
754754
} else if (auto *subscript = dyn_cast<SubscriptDecl>(paramOwner)) {
755-
if (skipCurriedSelf)
756-
paramList = subscript->getIndices();
755+
paramList = subscript->getIndices();
757756
} else if (auto *enumElement = dyn_cast<EnumElementDecl>(paramOwner)) {
758-
if (skipCurriedSelf)
759-
paramList = enumElement->getParameterList();
757+
paramList = enumElement->getParameterList();
760758
}
761759

762760
// No parameter list means no default arguments - hand back the zeroed
763761
// bitvector.
764-
if (!paramList)
762+
if (!paramList) {
763+
assert(!paramOwner->hasParameterList());
765764
return;
765+
}
766766

767767
switch (params.size()) {
768768
case 0:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void UnqualifiedLookupFactory::performUnqualifiedLookup() {
504504
void UnqualifiedLookupFactory::lookUpTopLevelNamesInModuleScopeContext(
505505
DeclContext *DC) {
506506
// TODO: Does the debugger client care about compound names?
507-
if (Name.isSimpleName() && DebugClient &&
507+
if (Name.isSimpleName() && !Name.isSpecial() && DebugClient &&
508508
DebugClient->lookupOverrides(Name.getBaseName(), DC, Loc,
509509
isOriginallyTypeLookup, Results))
510510
return;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ void ClangDiagnosticConsumer::HandleDiagnostic(
227227
diagKind = diag::note_from_clang;
228228
break;
229229
case clang::DiagnosticsEngine::Remark:
230-
// FIXME: We don't handle remarks yet.
231-
return;
230+
diagKind = diag::remark_from_clang;
231+
break;
232232
case clang::DiagnosticsEngine::Warning:
233233
diagKind = diag::warning_from_clang;
234234
break;

branches/rxwei-patch-1/lib/IDE/CodeCompletion.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ protocolForLiteralKind(CodeCompletionLiteralKind kind) {
14641464
static bool hasTrivialTrailingClosure(const FuncDecl *FD,
14651465
AnyFunctionType *funcType) {
14661466
ParameterListInfo paramInfo(funcType->getParams(), FD,
1467-
/*level*/ FD->isInstanceMember() ? 1 : 0);
1467+
/*skipCurriedSelf*/ FD->hasCurriedSelf());
14681468

14691469
if (paramInfo.size() - paramInfo.numNonDefaultedParameters() == 1) {
14701470
auto param = funcType->getParams().back();
@@ -5375,9 +5375,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53755375
case CompletionKind::AttributeBegin: {
53765376
Lookup.getAttributeDeclCompletions(IsInSil, AttTargetDK);
53775377

5378-
// Provide any type name for property delegate.
5378+
// TypeName at attribute position after '@'.
5379+
// - VarDecl: Property Wrappers.
5380+
// - ParamDecl/VarDecl/FuncDecl: Function Buildres.
53795381
if (!AttTargetDK || *AttTargetDK == DeclKind::Var ||
5380-
*AttTargetDK == DeclKind::Param)
5382+
*AttTargetDK == DeclKind::Param || *AttTargetDK == DeclKind::Func)
53815383
Lookup.getTypeCompletionsInDeclContext(
53825384
P.Context.SourceMgr.getCodeCompletionLoc());
53835385
break;

branches/rxwei-patch-1/lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4684,8 +4684,9 @@ static void fillInAccessorTypeErrors(Parser &P,
46844684
/// Parse the brace-enclosed getter and setter for a variable.
46854685
ParserResult<VarDecl>
46864686
Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
4687-
SourceLoc StaticLoc, SourceLoc VarLoc,
4688-
bool hasInitializer,
4687+
SourceLoc StaticLoc,
4688+
StaticSpellingKind StaticSpelling,
4689+
SourceLoc VarLoc, bool hasInitializer,
46894690
const DeclAttributes &Attributes,
46904691
SmallVectorImpl<Decl *> &Decls) {
46914692
bool Invalid = false;
@@ -4749,7 +4750,7 @@ Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
47494750
PatternBindingEntry entry(pattern, /*EqualLoc*/ SourceLoc(),
47504751
/*Init*/ nullptr, /*InitContext*/ nullptr);
47514752
auto binding = PatternBindingDecl::create(Context, StaticLoc,
4752-
StaticSpellingKind::None,
4753+
StaticSpelling,
47534754
VarLoc, entry, CurDeclContext);
47544755
binding->setInvalid(true);
47554756
storage->setParentPatternBinding(binding);
@@ -5371,9 +5372,9 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
53715372
// var-get-set clause, parse the var-get-set clause.
53725373
if (Tok.is(tok::l_brace)) {
53735374
HasAccessors = true;
5374-
auto boundVar = parseDeclVarGetSet(pattern, Flags, StaticLoc, VarLoc,
5375-
PatternInit != nullptr,Attributes,
5376-
Decls);
5375+
auto boundVar =
5376+
parseDeclVarGetSet(pattern, Flags, StaticLoc, StaticSpelling, VarLoc,
5377+
PatternInit != nullptr, Attributes, Decls);
53775378
if (boundVar.hasCodeCompletion())
53785379
return makeResult(makeParserCodeCompletionStatus());
53795380
if (PatternInit && boundVar.isNonNull() &&

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,18 +2028,9 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Member, bool FnTypeRequired) {
20282028
for (unsigned I = 0, E = values.size(); I < E; I++) {
20292029
auto *decl = values[I];
20302030

2031-
unsigned numArgumentLabels = 0;
2032-
if (auto *eed = dyn_cast<EnumElementDecl>(decl)) {
2033-
numArgumentLabels =
2034-
(eed->hasAssociatedValues() ? 2 : 1);
2035-
} else if (auto *afd = dyn_cast<AbstractFunctionDecl>(decl)) {
2036-
numArgumentLabels =
2037-
(decl->getDeclContext()->isTypeContext() ? 2 : 1);
2038-
}
2039-
20402031
auto lookupTy =
20412032
decl->getInterfaceType()
2042-
->removeArgumentLabels(numArgumentLabels);
2033+
->removeArgumentLabels(decl->getNumCurryLevels());
20432034
if (declTy == lookupTy->getCanonicalType()) {
20442035
TheDecl = decl;
20452036
// Update SILDeclRef to point to the right Decl.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
204204
}
205205

206206
bool shouldInclude(const ValueDecl *VD) {
207-
return isVisibleToObjC(VD, minRequiredAccess);
207+
return isVisibleToObjC(VD, minRequiredAccess) &&
208+
!VD->getAttrs().hasAttribute<ImplementationOnlyAttr>();
208209
}
209210

210211
private:

branches/rxwei-patch-1/lib/SIL/SILDeclRef.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,10 +1018,10 @@ unsigned SILDeclRef::getParameterListCount() const {
10181018

10191019
auto *vd = getDecl();
10201020

1021-
if (auto *func = dyn_cast<AbstractFunctionDecl>(vd)) {
1022-
return func->hasImplicitSelfDecl() ? 2 : 1;
1023-
} else if (auto *ed = dyn_cast<EnumElementDecl>(vd)) {
1024-
return ed->hasAssociatedValues() ? 2 : 1;
1021+
if (isa<AbstractFunctionDecl>(vd) || isa<EnumElementDecl>(vd)) {
1022+
// For functions and enum elements, the number of parameter lists is the
1023+
// same as in their interface type.
1024+
return vd->getNumCurryLevels();
10251025
} else if (isa<ClassDecl>(vd)) {
10261026
return 2;
10271027
} else if (isa<VarDecl>(vd)) {

0 commit comments

Comments
 (0)