Skip to content

Commit 2af3286

Browse files
committed
---
yaml --- r: 340841 b: refs/heads/rxwei-patch-1 c: 7b37072 h: refs/heads/master i: 340839: 9ee60c9
1 parent ae9dec3 commit 2af3286

38 files changed

+256
-593
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: 00d78615e08e1a76d063e98e1f28b6094af4f7e4
1018+
refs/heads/rxwei-patch-1: 7b37072adf9cf4c7e5254e4e9d2600ee658e04cd
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/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@ endif()
621621
if(SWIFT_HOST_VARIANT_ARCH)
622622
set(SWIFT_HOST_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
623623
else()
624-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
624+
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
625625
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
626-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64")
626+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
627627
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
628628
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
629629
set(SWIFT_HOST_VARIANT_ARCH_default "powerpc64")
@@ -636,6 +636,8 @@ else()
636636
set(SWIFT_HOST_VARIANT_ARCH_default "armv6")
637637
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "armv7l|armv7-a")
638638
set(SWIFT_HOST_VARIANT_ARCH_default "armv7")
639+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
640+
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
639641
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
640642
set(SWIFT_HOST_VARIANT_ARCH_default "itanium")
641643
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86|i686)")

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

Lines changed: 2 additions & 9 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) && defined(REMARK)))
21-
# error Must define either DIAG or the set {ERROR,WARNING,NOTE,REMARK}
20+
#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE)))
21+
# error Must define either DIAG or the set {ERROR,WARNING,NOTE}
2222
#endif
2323

2424
#ifndef ERROR
@@ -36,19 +36,12 @@
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-
4439
WARNING(warning_from_clang,none,
4540
"%0", (StringRef))
4641
ERROR(error_from_clang,none,
4742
"%0", (StringRef))
4843
NOTE(note_from_clang,none,
4944
"%0", (StringRef))
50-
REMARK(remark_from_clang,none,
51-
"%0", (StringRef))
5245

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

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,10 +3655,6 @@ ERROR(unsupported_opaque_type,none,
36553655
ERROR(opaque_type_unsupported_pattern,none,
36563656
"'some' type can only be declared on a single property declaration", ())
36573657

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-
36623658
// SIL
36633659
ERROR(opened_non_protocol,none,
36643660
"@opened cannot be applied to non-protocol type %0", (Type))

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

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

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,16 +1907,6 @@ bool AbstractStorageDecl::requiresOpaqueModifyCoroutine() const {
19071907
if (!supportsMutation())
19081908
return false;
19091909

1910-
auto *dc = getDeclContext();
1911-
1912-
// Local properties don't have modify accessors.
1913-
if (dc->isLocalContext())
1914-
return false;
1915-
1916-
// Fixed-layout global properties don't have modify accessors.
1917-
if (dc->isModuleScopeContext() && !isResilient())
1918-
return false;
1919-
19201910
// Imported storage declarations don't have eagerly-generated modify
19211911
// accessors.
19221912
if (hasClangNode())
@@ -1929,6 +1919,7 @@ bool AbstractStorageDecl::requiresOpaqueModifyCoroutine() const {
19291919
return false;
19301920

19311921
// Requirements of ObjC protocols don't support the modify coroutine.
1922+
auto *dc = getDeclContext();
19321923
if (auto protoDecl = dyn_cast<ProtocolDecl>(dc))
19331924
if (protoDecl->isObjC())
19341925
return false;

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() && !Name.isSpecial() && DebugClient &&
507+
if (Name.isSimpleName() && 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-
diagKind = diag::remark_from_clang;
231-
break;
230+
// FIXME: We don't handle remarks yet.
231+
return;
232232
case clang::DiagnosticsEngine::Warning:
233233
diagKind = diag::warning_from_clang;
234234
break;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5375,11 +5375,9 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53755375
case CompletionKind::AttributeBegin: {
53765376
Lookup.getAttributeDeclCompletions(IsInSil, AttTargetDK);
53775377

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

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4684,9 +4684,8 @@ 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,
4688-
StaticSpellingKind StaticSpelling,
4689-
SourceLoc VarLoc, bool hasInitializer,
4687+
SourceLoc StaticLoc, SourceLoc VarLoc,
4688+
bool hasInitializer,
46904689
const DeclAttributes &Attributes,
46914690
SmallVectorImpl<Decl *> &Decls) {
46924691
bool Invalid = false;
@@ -4750,7 +4749,7 @@ Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
47504749
PatternBindingEntry entry(pattern, /*EqualLoc*/ SourceLoc(),
47514750
/*Init*/ nullptr, /*InitContext*/ nullptr);
47524751
auto binding = PatternBindingDecl::create(Context, StaticLoc,
4753-
StaticSpelling,
4752+
StaticSpellingKind::None,
47544753
VarLoc, entry, CurDeclContext);
47554754
binding->setInvalid(true);
47564755
storage->setParentPatternBinding(binding);
@@ -4969,6 +4968,32 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
49694968
if (auto *subscript = dyn_cast<SubscriptDecl>(storage))
49704969
genericParams = subscript->getGenericParams();
49714970

4971+
// Create an implicit accessor declaration.
4972+
auto createImplicitAccessor = [&](AccessorKind kind,
4973+
AccessorDecl *funcForParams = nullptr) {
4974+
// We never use this to create addressors.
4975+
assert(kind != AccessorKind::Address &&
4976+
kind != AccessorKind::MutableAddress);
4977+
4978+
// Create the paramter list for a setter.
4979+
ParameterList *argList = nullptr;
4980+
if (kind == AccessorKind::Set) {
4981+
assert(funcForParams);
4982+
auto argLoc = funcForParams->getStartLoc();
4983+
4984+
auto argument = createSetterAccessorArgument(
4985+
argLoc, Identifier(), AccessorKind::Set, P, elementTy);
4986+
argList = ParameterList::create(P.Context, argument);
4987+
}
4988+
4989+
auto accessor = createAccessorFunc(SourceLoc(), argList,
4990+
genericParams, indices, elementTy,
4991+
staticLoc, flags, kind,
4992+
storage, &P, SourceLoc());
4993+
accessor->setImplicit();
4994+
add(accessor);
4995+
};
4996+
49724997
// If there was a problem parsing accessors, mark all parsed accessors
49734998
// as invalid to avoid tripping up later invariants.
49744999
// We also want to avoid diagnose missing accessors if something
@@ -4995,6 +5020,12 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
49955020

49965021
// Otherwise, we have either a stored or inherited observing property.
49975022
} else {
5023+
// Observing properties will have getters and setters synthesized
5024+
// by Sema. Create their prototypes now.
5025+
auto argFunc = (WillSet ? WillSet : DidSet);
5026+
createImplicitAccessor(AccessorKind::Get);
5027+
createImplicitAccessor(AccessorKind::Set, argFunc);
5028+
49985029
if (attrs.hasAttribute<OverrideAttr>()) {
49995030
return StorageImplInfo(ReadImplKind::Inherited,
50005031
WriteImplKind::InheritedWithObservers,
@@ -5035,7 +5066,7 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
50355066
isa<SubscriptDecl>(storage),
50365067
getAccessorNameForDiagnostic(mutator, /*article*/ true));
50375068
}
5038-
5069+
createImplicitAccessor(AccessorKind::Get);
50395070
readImpl = ReadImplKind::Get;
50405071

50415072
// Subscripts always have to have some sort of accessor; they can't be
@@ -5045,6 +5076,7 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
50455076
P.diagnose(LBLoc, diag::subscript_without_get);
50465077
}
50475078

5079+
createImplicitAccessor(AccessorKind::Get);
50485080
readImpl = ReadImplKind::Get;
50495081

50505082
// Otherwise, it's stored.
@@ -5339,9 +5371,9 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
53395371
// var-get-set clause, parse the var-get-set clause.
53405372
if (Tok.is(tok::l_brace)) {
53415373
HasAccessors = true;
5342-
auto boundVar =
5343-
parseDeclVarGetSet(pattern, Flags, StaticLoc, StaticSpelling, VarLoc,
5344-
PatternInit != nullptr, Attributes, Decls);
5374+
auto boundVar = parseDeclVarGetSet(pattern, Flags, StaticLoc, VarLoc,
5375+
PatternInit != nullptr,Attributes,
5376+
Decls);
53455377
if (boundVar.hasCodeCompletion())
53465378
return makeResult(makeParserCodeCompletionStatus());
53475379
if (PatternInit && boundVar.isNonNull() &&

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
584584
Parser::StructureMarkerRAII ParsingDecl(
585585
*this, Tok.getLoc(), Parser::StructureMarkerKind::IfConfig);
586586

587+
bool shouldEvaluate =
588+
// Don't evaluate if it's in '-parse' mode, etc.
589+
State->PerformConditionEvaluation &&
590+
// If it's in inactive #if ... #endif block, there's no point to do it.
591+
!getScopeInfo().isInactiveConfigBlock();
592+
587593
bool foundActive = false;
588594
bool isVersionCondition = false;
589595
while (1) {
@@ -604,7 +610,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
604610
// Parse the condition. Evaluate it to determine the active
605611
// clause unless we're doing a parse-only pass.
606612
if (isElse) {
607-
isActive = !foundActive && State->PerformConditionEvaluation;
613+
isActive = !foundActive && shouldEvaluate;
608614
} else {
609615
llvm::SaveAndRestore<bool> S(InPoundIfEnvironment, true);
610616
ParserResult<Expr> Result = parseExprSequence(diag::expected_expr,
@@ -619,7 +625,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
619625
// Error in the condition;
620626
isActive = false;
621627
isVersionCondition = false;
622-
} else if (!foundActive && State->PerformConditionEvaluation) {
628+
} else if (!foundActive && shouldEvaluate) {
623629
// Evaluate the condition only if we haven't found any active one and
624630
// we're not in parse-only mode.
625631
isActive = evaluateIfConfigCondition(Condition, Context);

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,17 +1316,48 @@ void SILGenModule::visitVarDecl(VarDecl *vd) {
13161316
if (vd->hasStorage())
13171317
addGlobalVariable(vd);
13181318

1319-
for (auto *accessor : vd->getAllAccessors())
1319+
// Emit the variable's opaque accessors.
1320+
vd->visitExpectedOpaqueAccessors([&](AccessorKind kind) {
1321+
auto accessor = vd->getAccessor(kind);
1322+
if (!accessor) return;
1323+
1324+
// Only emit the accessor if it wasn't added to the surrounding decl
1325+
// list by the parser. We can test that easily by looking at the impl
1326+
// info, since all of these accessors have a corresponding access kind
1327+
// whose impl should definitely point at the accessor if it was parsed.
1328+
//
1329+
// This is an unfortunate formation rule, but it's easier than messing
1330+
// with the invariants for now.
1331+
bool shouldEmit = [&] {
1332+
auto impl = vd->getImplInfo();
1333+
switch (kind) {
1334+
case AccessorKind::Get:
1335+
return impl.getReadImpl() != ReadImplKind::Get &&
1336+
!(impl.getReadImpl() == ReadImplKind::Stored &&
1337+
impl.getWriteImpl() == WriteImplKind::StoredWithObservers);
1338+
case AccessorKind::Read:
1339+
return impl.getReadImpl() != ReadImplKind::Read;
1340+
case AccessorKind::Set:
1341+
return impl.getWriteImpl() != WriteImplKind::Set &&
1342+
impl.getWriteImpl() != WriteImplKind::StoredWithObservers;
1343+
case AccessorKind::Modify:
1344+
return impl.getReadWriteImpl() != ReadWriteImplKind::Modify;
1345+
#define ACCESSOR(ID) \
1346+
case AccessorKind::ID:
1347+
#define OPAQUE_ACCESSOR(ID, KEYWORD)
1348+
#include "swift/AST/AccessorKinds.def"
1349+
llvm_unreachable("not an opaque accessor");
1350+
}
1351+
llvm_unreachable("covered switch");
1352+
}();
1353+
if (!shouldEmit) return;
1354+
13201355
emitFunction(accessor);
1356+
});
13211357

13221358
tryEmitPropertyDescriptor(vd);
13231359
}
13241360

1325-
void SILGenModule::visitSubscriptDecl(SubscriptDecl *sd) {
1326-
for (auto *accessor : sd->getAllAccessors())
1327-
emitFunction(accessor);
1328-
}
1329-
13301361
bool
13311362
SILGenModule::canStorageUseStoredKeyPathComponent(AbstractStorageDecl *decl,
13321363
ResilienceExpansion expansion) {

branches/rxwei-patch-1/lib/SILGen/SILGen.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,12 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
188188
void visitTypeAliasDecl(TypeAliasDecl *d) {}
189189
void visitOpaqueTypeDecl(OpaqueTypeDecl *d) {}
190190
void visitAbstractTypeParamDecl(AbstractTypeParamDecl *d) {}
191+
void visitSubscriptDecl(SubscriptDecl *d) {}
191192
void visitConstructorDecl(ConstructorDecl *d) {}
192193
void visitDestructorDecl(DestructorDecl *d) {}
193194
void visitModuleDecl(ModuleDecl *d) { }
194195
void visitMissingMemberDecl(MissingMemberDecl *d) {}
195196

196-
// Emitted as part of its storage.
197-
void visitAccessorDecl(AccessorDecl *ad) {}
198-
199197
void visitFuncDecl(FuncDecl *fd);
200198
void visitPatternBindingDecl(PatternBindingDecl *vd);
201199
void visitTopLevelCodeDecl(TopLevelCodeDecl *td);
@@ -204,7 +202,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
204202
void visitNominalTypeDecl(NominalTypeDecl *ntd);
205203
void visitExtensionDecl(ExtensionDecl *ed);
206204
void visitVarDecl(VarDecl *vd);
207-
void visitSubscriptDecl(SubscriptDecl *sd);
208205

209206
void emitAbstractFuncDecl(AbstractFunctionDecl *AFD);
210207

branches/rxwei-patch-1/lib/SILGen/SILGenDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,10 +1192,6 @@ void SILGenFunction::visitPatternBindingDecl(PatternBindingDecl *PBD) {
11921192

11931193
void SILGenFunction::visitVarDecl(VarDecl *D) {
11941194
// We handle emitting the variable storage when we see the pattern binding.
1195-
1196-
// Emit the variable's accessors.
1197-
for (auto *accessor : D->getAllAccessors())
1198-
SGM.emitFunction(accessor);
11991195
}
12001196

12011197
/// Emit literals for the major, minor, and subminor components of the version

branches/rxwei-patch-1/lib/SILGen/SILGenFunction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,9 +1787,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
17871787
llvm_unreachable("Not yet implemented");
17881788
}
17891789

1790-
// Emitted as part of its storage.
1791-
void visitAccessorDecl(AccessorDecl *D) {}
1792-
17931790
void visitFuncDecl(FuncDecl *D);
17941791
void visitPatternBindingDecl(PatternBindingDecl *D);
17951792

branches/rxwei-patch-1/lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,9 @@ bool MemberAccessOnOptionalBaseFailure::diagnoseAsError() {
901901

902902
void MissingOptionalUnwrapFailure::offerDefaultValueUnwrapFixIt(
903903
DeclContext *DC, Expr *expr) const {
904-
assert(expr);
905-
906904
auto *anchor = getAnchor();
907-
// If anchor is n explicit address-of, or expression which produces
905+
906+
// If anchor is an explicit address-of, or expression which produces
908907
// an l-value (e.g. first argument of `+=` operator), let's not
909908
// suggest default value here because that would produce r-value type.
910909
if (isa<InOutExpr>(anchor))
@@ -1048,10 +1047,7 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
10481047
if (singleUse && binding && binding->getNumPatternEntries() == 1 &&
10491048
varDecl->getTypeSourceRangeForDiagnostics().isInvalid()) {
10501049

1051-
auto *initializer = varDecl->getParentInitializer();
1052-
if (!initializer)
1053-
return true;
1054-
1050+
Expr *initializer = varDecl->getParentInitializer();
10551051
if (auto declRefExpr = dyn_cast<DeclRefExpr>(initializer)) {
10561052
if (declRefExpr->getDecl()
10571053
->getAttrs()

0 commit comments

Comments
 (0)