Skip to content

Commit baa182d

Browse files
committed
---
yaml --- r: 313023 b: refs/heads/tensorflow-merge c: ffb3ec2 h: refs/heads/master i: 313021: f1530ce 313019: ac6b7ac 313015: 8414eba 313007: 369378a 312991: 79494b2 312959: f5a7adc
1 parent 56826da commit baa182d

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ refs/heads/chase-my-tail: 8bb91443a9e81bbfac92a2621a0af887a1da8dbf
13791379
refs/heads/consider-outer-alternatives: 708bac749ec60a22a79e2eefbe734f9488a7370d
13801380
refs/heads/revert-25740-oops-i-linked-it-again: fdd41aeb682fc488572bdc1cf71b2ff6997ba576
13811381
refs/heads/swift-5.1-branch-06-12-2019: e63b7b2d3b93c48232d386099d0ec525d21d8f8d
1382-
refs/heads/tensorflow-merge: ef7e573d0603f447c85f54ab0c1c77b79dfda385
1382+
refs/heads/tensorflow-merge: ffb3ec2114f6001614a5fe55dc380b7449b869a6
13831383
refs/heads/update-checkout-sha-info: 5832743c5c2a842976c42a508a4c6dcceefb0aef
13841384
refs/tags/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-06-12-a: 228f0448d9bb909aacbba4afcb7c600a405d15da
13851385
refs/tags/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-06-14-a: 922861a77b5fc2bf46bc917da70ceb15eef76836

branches/tensorflow-merge/include/swift/AST/Decl.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,9 +3454,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
34543454
private:
34553455
/// Predicate used to filter StoredPropertyRange.
34563456
struct ToStoredProperty {
3457-
ToStoredProperty(bool skipInaccessible = false) :
3458-
skipUserInaccessible(skipInaccessible) {}
3459-
bool skipUserInaccessible;
3457+
ToStoredProperty() {}
34603458
Optional<VarDecl *> operator()(Decl *decl) const;
34613459
};
34623460

@@ -3466,7 +3464,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
34663464
ToStoredProperty>;
34673465

34683466
/// Return a collection of the stored member variables of this type.
3469-
StoredPropertyRange getStoredProperties(bool skipInaccessible = false) const;
3467+
StoredPropertyRange getStoredProperties() const;
34703468

34713469
private:
34723470
/// Predicate used to filter StoredPropertyRange.
@@ -7150,32 +7148,6 @@ inline bool ValueDecl::isSettable(const DeclContext *UseDC,
71507148
return false;
71517149
}
71527150

7153-
inline Optional<VarDecl *>
7154-
NominalTypeDecl::ToStoredProperty::operator()(Decl *decl) const {
7155-
if (auto var = dyn_cast<VarDecl>(decl)) {
7156-
if (!var->isStatic() && var->hasStorage() &&
7157-
(!skipUserInaccessible || var->isUserAccessible()))
7158-
return var;
7159-
}
7160-
7161-
return None;
7162-
}
7163-
7164-
inline Optional<Decl *>
7165-
NominalTypeDecl::ToStoredPropertyOrMissingMemberPlaceholder
7166-
::operator()(Decl *decl) const {
7167-
if (auto var = dyn_cast<VarDecl>(decl)) {
7168-
if (!var->isStatic() && var->hasStorage())
7169-
return var;
7170-
}
7171-
if (auto missing = dyn_cast<MissingMemberDecl>(decl)) {
7172-
if (missing->getNumberOfFieldOffsetVectorEntries() > 0)
7173-
return missing;
7174-
}
7175-
7176-
return None;
7177-
}
7178-
71797151
inline void
71807152
AbstractStorageDecl::overwriteSetterAccess(AccessLevel accessLevel) {
71817153
Accessors.setInt(accessLevel);

branches/tensorflow-merge/lib/AST/Decl.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,31 @@ ImportDecl::findBestImportKind(ArrayRef<ValueDecl *> Decls) {
10291029
return FirstKind;
10301030
}
10311031

1032+
Optional<VarDecl *>
1033+
NominalTypeDecl::ToStoredProperty::operator()(Decl *decl) const {
1034+
if (auto var = dyn_cast<VarDecl>(decl)) {
1035+
if (!var->isStatic() && var->hasStorage())
1036+
return var;
1037+
}
1038+
1039+
return None;
1040+
}
1041+
1042+
Optional<Decl *>
1043+
NominalTypeDecl::ToStoredPropertyOrMissingMemberPlaceholder
1044+
::operator()(Decl *decl) const {
1045+
if (auto var = dyn_cast<VarDecl>(decl)) {
1046+
if (!var->isStatic() && var->hasStorage())
1047+
return var;
1048+
}
1049+
if (auto missing = dyn_cast<MissingMemberDecl>(decl)) {
1050+
if (missing->getNumberOfFieldOffsetVectorEntries() > 0)
1051+
return missing;
1052+
}
1053+
1054+
return None;
1055+
}
1056+
10321057
void NominalTypeDecl::setConformanceLoader(LazyMemberLoader *lazyLoader,
10331058
uint64_t contextData) {
10341059
assert(!Bits.NominalTypeDecl.HasLazyConformances &&
@@ -3419,7 +3444,7 @@ void NominalTypeDecl::addExtension(ExtensionDecl *extension) {
34193444
addedExtension(extension);
34203445
}
34213446

3422-
auto NominalTypeDecl::getStoredProperties(bool skipInaccessible) const
3447+
auto NominalTypeDecl::getStoredProperties() const
34233448
-> StoredPropertyRange {
34243449
// This should be called at most once per SIL instruction that accesses a
34253450
// VarDecl.
@@ -3432,10 +3457,9 @@ auto NominalTypeDecl::getStoredProperties(bool skipInaccessible) const
34323457
// Clang-imported classes never have stored properties.
34333458
if (hasClangNode() && isa<ClassDecl>(this))
34343459
return StoredPropertyRange(DeclRange(nullptr, nullptr),
3435-
ToStoredProperty(skipInaccessible));
3460+
ToStoredProperty());
34363461

3437-
return StoredPropertyRange(getMembers(),
3438-
ToStoredProperty(skipInaccessible));
3462+
return StoredPropertyRange(getMembers(), ToStoredProperty());
34393463
}
34403464

34413465
bool NominalTypeDecl::isOptionalDecl() const {

branches/tensorflow-merge/lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ static bool validateCodingKeysEnum(DerivedConformance &derived,
162162
// Here we'll hold on to properties by name -- when we've validated a property
163163
// against its CodingKey entry, it will get removed.
164164
llvm::SmallDenseMap<Identifier, VarDecl *, 8> properties;
165-
for (auto *varDecl :
166-
derived.Nominal->getStoredProperties(/*skipInaccessible=*/true)) {
165+
for (auto *varDecl : derived.Nominal->getStoredProperties()) {
166+
if (!varDecl->isUserAccessible())
167+
continue;
168+
167169
if (varDecl->getAttrs().hasAttribute<LazyAttr>())
168170
continue;
169171

@@ -357,7 +359,10 @@ static EnumDecl *synthesizeCodingKeysEnum(DerivedConformance &derived) {
357359
// Each of these vars needs a case in the enum. For each var decl, if the type
358360
// conforms to {En,De}codable, add it to the enum.
359361
bool allConform = true;
360-
for (auto *varDecl : target->getStoredProperties(/*skipInaccessible=*/true)) {
362+
for (auto *varDecl : target->getStoredProperties()) {
363+
if (!varDecl->isUserAccessible())
364+
continue;
365+
361366
if (varDecl->getAttrs().hasAttribute<LazyAttr>())
362367
continue;
363368

branches/tensorflow-merge/lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ static SmallVector<VarDecl *, 3>
8686
storedPropertiesNotConformingToProtocol(DeclContext *DC, StructDecl *theStruct,
8787
ProtocolDecl *protocol) {
8888
auto lazyResolver = DC->getASTContext().getLazyResolver();
89-
auto storedProperties =
90-
theStruct->getStoredProperties(/*skipInaccessible=*/true);
89+
auto storedProperties = theStruct->getStoredProperties();
9190
SmallVector<VarDecl *, 3> nonconformingProperties;
9291
for (auto propertyDecl : storedProperties) {
92+
if (!propertyDecl->isUserAccessible())
93+
continue;
94+
9395
if (!propertyDecl->hasInterfaceType())
9496
lazyResolver->resolveDeclSignature(propertyDecl);
9597
if (!propertyDecl->hasInterfaceType())
@@ -596,12 +598,14 @@ deriveBodyEquatable_struct_eq(AbstractFunctionDecl *eqDecl, void *) {
596598

597599
SmallVector<ASTNode, 6> statements;
598600

599-
auto storedProperties =
600-
structDecl->getStoredProperties(/*skipInaccessible=*/true);
601+
auto storedProperties = structDecl->getStoredProperties();
601602

602603
// For each stored property element, generate a guard statement that returns
603604
// false if a property is not pairwise-equal.
604605
for (auto propertyDecl : storedProperties) {
606+
if (!propertyDecl->isUserAccessible())
607+
continue;
608+
605609
auto aPropertyRef = new (C) DeclRefExpr(propertyDecl, DeclNameLoc(),
606610
/*implicit*/ true);
607611
auto aParamRef = new (C) DeclRefExpr(aParam, DeclNameLoc(),
@@ -1099,11 +1103,13 @@ deriveBodyHashable_struct_hashInto(AbstractFunctionDecl *hashIntoDecl, void *) {
10991103
// Extract the decl for the hasher parameter.
11001104
auto hasherParam = hashIntoDecl->getParameters()->get(0);
11011105

1102-
auto storedProperties =
1103-
structDecl->getStoredProperties(/*skipInaccessible=*/true);
1106+
auto storedProperties = structDecl->getStoredProperties();
11041107

11051108
// Feed each stored property into the hasher.
11061109
for (auto propertyDecl : storedProperties) {
1110+
if (!propertyDecl->isUserAccessible())
1111+
continue;
1112+
11071113
auto propertyRef = new (C) DeclRefExpr(propertyDecl, DeclNameLoc(),
11081114
/*implicit*/ true);
11091115
auto selfRef = new (C) DeclRefExpr(selfDecl, DeclNameLoc(),

0 commit comments

Comments
 (0)