Skip to content

Commit ed5bd18

Browse files
authored
---
yaml --- r: 340846 b: refs/heads/rxwei-patch-1 c: e71bfd3 h: refs/heads/master
1 parent f6c36a9 commit ed5bd18

File tree

32 files changed

+549
-219
lines changed

32 files changed

+549
-219
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: 70aba4d1fe200dd1d747829eca7eb93d16a63d3e
1018+
refs/heads/rxwei-patch-1: e71bfd38c7b7cd7cac7181222e8db3a4aaa100c6
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: 2 additions & 4 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}" STREQUAL "x86_64")
624+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
625625
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
626-
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
626+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64")
627627
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
628628
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
629629
set(SWIFT_HOST_VARIANT_ARCH_default "powerpc64")
@@ -636,8 +636,6 @@ 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")
641639
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
642640
set(SWIFT_HOST_VARIANT_ARCH_default "itanium")
643641
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86|i686)")

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/Decl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,16 @@ 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+
19101920
// Imported storage declarations don't have eagerly-generated modify
19111921
// accessors.
19121922
if (hasClangNode())
@@ -1919,7 +1929,6 @@ bool AbstractStorageDecl::requiresOpaqueModifyCoroutine() const {
19191929
return false;
19201930

19211931
// Requirements of ObjC protocols don't support the modify coroutine.
1922-
auto *dc = getDeclContext();
19231932
if (auto protoDecl = dyn_cast<ProtocolDecl>(dc))
19241933
if (protoDecl->isObjC())
19251934
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() && 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/IDE/CodeCompletion.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 8 additions & 40 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);
@@ -4968,32 +4969,6 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
49684969
if (auto *subscript = dyn_cast<SubscriptDecl>(storage))
49694970
genericParams = subscript->getGenericParams();
49704971

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-
49974972
// If there was a problem parsing accessors, mark all parsed accessors
49984973
// as invalid to avoid tripping up later invariants.
49994974
// We also want to avoid diagnose missing accessors if something
@@ -5020,12 +4995,6 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
50204995

50214996
// Otherwise, we have either a stored or inherited observing property.
50224997
} 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-
50294998
if (attrs.hasAttribute<OverrideAttr>()) {
50304999
return StorageImplInfo(ReadImplKind::Inherited,
50315000
WriteImplKind::InheritedWithObservers,
@@ -5066,7 +5035,7 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
50665035
isa<SubscriptDecl>(storage),
50675036
getAccessorNameForDiagnostic(mutator, /*article*/ true));
50685037
}
5069-
createImplicitAccessor(AccessorKind::Get);
5038+
50705039
readImpl = ReadImplKind::Get;
50715040

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

5079-
createImplicitAccessor(AccessorKind::Get);
50805048
readImpl = ReadImplKind::Get;
50815049

50825050
// Otherwise, it's stored.
@@ -5371,9 +5339,9 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
53715339
// var-get-set clause, parse the var-get-set clause.
53725340
if (Tok.is(tok::l_brace)) {
53735341
HasAccessors = true;
5374-
auto boundVar = parseDeclVarGetSet(pattern, Flags, StaticLoc, VarLoc,
5375-
PatternInit != nullptr,Attributes,
5376-
Decls);
5342+
auto boundVar =
5343+
parseDeclVarGetSet(pattern, Flags, StaticLoc, StaticSpelling, VarLoc,
5344+
PatternInit != nullptr, Attributes, Decls);
53775345
if (boundVar.hasCodeCompletion())
53785346
return makeResult(makeParserCodeCompletionStatus());
53795347
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: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,48 +1316,17 @@ void SILGenModule::visitVarDecl(VarDecl *vd) {
13161316
if (vd->hasStorage())
13171317
addGlobalVariable(vd);
13181318

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-
1319+
for (auto *accessor : vd->getAllAccessors())
13551320
emitFunction(accessor);
1356-
});
13571321

13581322
tryEmitPropertyDescriptor(vd);
13591323
}
13601324

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

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,14 @@ 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) {}
192191
void visitConstructorDecl(ConstructorDecl *d) {}
193192
void visitDestructorDecl(DestructorDecl *d) {}
194193
void visitModuleDecl(ModuleDecl *d) { }
195194
void visitMissingMemberDecl(MissingMemberDecl *d) {}
196195

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

206209
void emitAbstractFuncDecl(AbstractFunctionDecl *AFD);
207210

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,10 @@ 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);
11951199
}
11961200

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,9 @@ 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+
17901793
void visitFuncDecl(FuncDecl *D);
17911794
void visitPatternBindingDecl(PatternBindingDecl *D);
17921795

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

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

902902
void MissingOptionalUnwrapFailure::offerDefaultValueUnwrapFixIt(
903903
DeclContext *DC, Expr *expr) const {
904-
auto *anchor = getAnchor();
904+
assert(expr);
905905

906-
// If anchor is an explicit address-of, or expression which produces
906+
auto *anchor = getAnchor();
907+
// If anchor is n explicit address-of, or expression which produces
907908
// an l-value (e.g. first argument of `+=` operator), let's not
908909
// suggest default value here because that would produce r-value type.
909910
if (isa<InOutExpr>(anchor))
@@ -1047,7 +1048,10 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
10471048
if (singleUse && binding && binding->getNumPatternEntries() == 1 &&
10481049
varDecl->getTypeSourceRangeForDiagnostics().isInvalid()) {
10491050

1050-
Expr *initializer = varDecl->getParentInitializer();
1051+
auto *initializer = varDecl->getParentInitializer();
1052+
if (!initializer)
1053+
return true;
1054+
10511055
if (auto declRefExpr = dyn_cast<DeclRefExpr>(initializer)) {
10521056
if (declRefExpr->getDecl()
10531057
->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((isa<AbstractFunctionDecl>(DC) || isa<FileUnit>(DC)) &&
75+
assert((DC->isLocalContext() || 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 variables don't otherwise get accessors.
2040-
if (dc->isLocalContext())
2039+
// Local stored variables don't otherwise get accessors.
2040+
if (dc->isLocalContext() && storage->getImplInfo().isSimpleStored())
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())
2056+
if (!storage->isResilient() && storage->getImplInfo().isSimpleStored())
20572057
return;
20582058

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

0 commit comments

Comments
 (0)