Skip to content

Commit 58779b0

Browse files
committed
---
yaml --- r: 340847 b: refs/heads/rxwei-patch-1 c: 57aa612 h: refs/heads/master i: 340845: f6c36a9 340843: a99dd96 340839: 9ee60c9 340831: 719546e
1 parent ed5bd18 commit 58779b0

File tree

27 files changed

+216
-362
lines changed

27 files changed

+216
-362
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: e71bfd38c7b7cd7cac7181222e8db3a4aaa100c6
1018+
refs/heads/rxwei-patch-1: 57aa612df413d1929433fe7828f899e5e8fc4c25
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/Decl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,11 +2853,6 @@ class OpaqueTypeDecl : public GenericTypeDecl {
28532853

28542854
ValueDecl *getNamingDecl() const { return NamingDecl; }
28552855

2856-
void setNamingDecl(ValueDecl *D) {
2857-
assert(!NamingDecl && "already have naming decl");
2858-
NamingDecl = D;
2859-
}
2860-
28612856
GenericSignature *getOpaqueInterfaceGenericSignature() const {
28622857
return OpaqueInterfaceGenericSignature;
28632858
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,5 @@ WARNING(clang_vfs_overlay_is_ignored,none,
102102
# undef NOTE
103103
# undef WARNING
104104
# undef ERROR
105+
# undef REMARK
105106
#endif

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/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: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,6 @@ 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-
593587
bool foundActive = false;
594588
bool isVersionCondition = false;
595589
while (1) {
@@ -610,7 +604,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
610604
// Parse the condition. Evaluate it to determine the active
611605
// clause unless we're doing a parse-only pass.
612606
if (isElse) {
613-
isActive = !foundActive && shouldEvaluate;
607+
isActive = !foundActive && State->PerformConditionEvaluation;
614608
} else {
615609
llvm::SaveAndRestore<bool> S(InPoundIfEnvironment, true);
616610
ParserResult<Expr> Result = parseExprSequence(diag::expected_expr,
@@ -625,7 +619,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
625619
// Error in the condition;
626620
isActive = false;
627621
isVersionCondition = false;
628-
} else if (!foundActive && shouldEvaluate) {
622+
} else if (!foundActive && State->PerformConditionEvaluation) {
629623
// Evaluate the condition only if we haven't found any active one and
630624
// we're not in parse-only mode.
631625
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()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void addMemberToContextIfNeeded(Decl *D, DeclContext *DC,
7272
} else if (auto *ed = dyn_cast<ExtensionDecl>(DC)) {
7373
ed->addMember(D, Hint);
7474
} else {
75-
assert((DC->isLocalContext() || isa<FileUnit>(DC)) &&
75+
assert((isa<AbstractFunctionDecl>(DC) || isa<FileUnit>(DC)) &&
7676
"Unknown declcontext");
7777
}
7878
}
@@ -2036,8 +2036,8 @@ void swift::maybeAddAccessorsToStorage(AbstractStorageDecl *storage) {
20362036

20372037
auto *dc = storage->getDeclContext();
20382038

2039-
// Local stored variables don't otherwise get accessors.
2040-
if (dc->isLocalContext() && storage->getImplInfo().isSimpleStored())
2039+
// Local variables don't otherwise get accessors.
2040+
if (dc->isLocalContext())
20412041
return;
20422042

20432043
// Implicit properties don't get accessors.
@@ -2053,7 +2053,7 @@ void swift::maybeAddAccessorsToStorage(AbstractStorageDecl *storage) {
20532053
return;
20542054
}
20552055
// Fixed-layout global variables don't get accessors.
2056-
if (!storage->isResilient() && storage->getImplInfo().isSimpleStored())
2056+
if (!storage->isResilient())
20572057
return;
20582058

20592059
// In a protocol context, variables written as just "var x : Int" or

0 commit comments

Comments
 (0)