Skip to content

Commit 24b455d

Browse files
committed
---
yaml --- r: 292863 b: refs/heads/tensorflow c: 5b2e95d h: refs/heads/master i: 292861: 5f876b8 292859: 7d48efd 292855: 77ae05c 292847: 5a5e603 292831: 3c8a001 292799: 9d3c53a 292735: e05bb7d 292607: dc9395b 292351: 37f91d4 291839: 6a55e34 290815: 153f385
1 parent 08fdeb7 commit 24b455d

File tree

19 files changed

+137
-583
lines changed

19 files changed

+137
-583
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: 5a2e73f7c8896dd1981375bb29df6416fc147b84
819+
refs/heads/tensorflow: 5b2e95d01f2c1b8603f2ee130f4f851b0fa9b7f3
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/include/swift/AST/Pattern.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ class alignas(8) Pattern {
221221

222222
void print(llvm::raw_ostream &OS,
223223
const PrintOptions &Options = PrintOptions()) const;
224-
LLVM_ATTRIBUTE_DEPRECATED(
225-
void dump() const LLVM_ATTRIBUTE_USED,
226-
"only for use within the debugger");
224+
void dump() const;
227225

228226
/// walk - This recursively walks the AST rooted at this pattern.
229227
Pattern *walk(ASTWalker &walker);

branches/tensorflow/include/swift/AST/TypeRepr.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ class alignas(8) TypeRepr {
160160

161161
void print(raw_ostream &OS, const PrintOptions &Opts = PrintOptions()) const;
162162
void print(ASTPrinter &Printer, const PrintOptions &Opts) const;
163-
LLVM_ATTRIBUTE_DEPRECATED(
164-
void dump() const LLVM_ATTRIBUTE_USED,
165-
"only for use within the debugger");
163+
void dump() const;
166164

167165
/// Clone the given type representation.
168166
TypeRepr *clone(const ASTContext &ctx) const;

branches/tensorflow/include/swift/Reflection/ReflectionContext.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class ReflectionContext
310310
sizeof(llvm::object::coff_section) * COFFFileHdr->NumberOfSections);
311311

312312
auto findCOFFSectionByName = [&](llvm::StringRef Name)
313-
-> std::pair<std::pair<const char *, const char *>, uint32_t> {
313+
-> std::pair<const char *, const char *> {
314314
for (size_t i = 0; i < COFFFileHdr->NumberOfSections; ++i) {
315315
const llvm::object::coff_section *COFFSec =
316316
reinterpret_cast<const llvm::object::coff_section *>(
@@ -336,45 +336,43 @@ class ReflectionContext
336336
End -= 8;
337337
}
338338

339-
return {{Begin, End}, 0};
339+
return {Begin, End};
340340
}
341-
return {{nullptr, nullptr}, 0};
341+
return {nullptr, nullptr};
342342
};
343343

344-
std::pair<std::pair<const char *, const char *>, uint32_t> CaptureSec =
344+
std::pair<const char *, const char *> CaptureSec =
345345
findCOFFSectionByName(".sw5cptr");
346-
std::pair<std::pair<const char *, const char *>, uint32_t> TypeRefMdSec =
346+
std::pair<const char *, const char *> TypeRefMdSec =
347347
findCOFFSectionByName(".sw5tyrf");
348-
std::pair<std::pair<const char *, const char *>, uint32_t> FieldMdSec =
348+
std::pair<const char *, const char *> FieldMdSec =
349349
findCOFFSectionByName(".sw5flmd");
350-
std::pair<std::pair<const char *, const char *>, uint32_t> AssocTySec =
350+
std::pair<const char *, const char *> AssocTySec =
351351
findCOFFSectionByName(".sw5asty");
352-
std::pair<std::pair<const char *, const char *>, uint32_t> BuiltinTySec =
352+
std::pair<const char *, const char *> BuiltinTySec =
353353
findCOFFSectionByName(".sw5bltn");
354-
std::pair<std::pair<const char *, const char *>, uint32_t> ReflStrMdSec =
354+
std::pair<const char *, const char *> ReflStrMdSec =
355355
findCOFFSectionByName(".sw5rfst");
356356

357-
if (FieldMdSec.first.first == nullptr &&
358-
AssocTySec.first.first == nullptr &&
359-
BuiltinTySec.first.first == nullptr &&
360-
CaptureSec.first.first == nullptr &&
361-
TypeRefMdSec.first.first == nullptr &&
362-
ReflStrMdSec.first.first == nullptr)
357+
if (FieldMdSec.first == nullptr &&
358+
AssocTySec.first == nullptr &&
359+
BuiltinTySec.first == nullptr &&
360+
CaptureSec.first == nullptr &&
361+
TypeRefMdSec.first == nullptr &&
362+
ReflStrMdSec.first == nullptr)
363363
return false;
364+
364365
auto LocalStartAddress = reinterpret_cast<uintptr_t>(DOSHdrBuf.get());
365366
auto RemoteStartAddress =
366367
static_cast<uintptr_t>(ImageStart.getAddressData());
367368

368369
ReflectionInfo Info = {
369-
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
370-
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
371-
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
372-
BuiltinTySec.second},
373-
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
374-
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
375-
TypeRefMdSec.second},
376-
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
377-
ReflStrMdSec.second},
370+
{{FieldMdSec.first, FieldMdSec.second}, 0},
371+
{{AssocTySec.first, AssocTySec.second}, 0},
372+
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
373+
{{CaptureSec.first, CaptureSec.second}, 0},
374+
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
375+
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
378376
LocalStartAddress,
379377
RemoteStartAddress};
380378
this->addReflectionInfo(Info);

branches/tensorflow/lib/AST/ASTPrinter.cpp

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -985,33 +985,6 @@ void PrintAST::printTypedPattern(const TypedPattern *TP) {
985985
printTypeLoc(TP->getTypeLoc());
986986
}
987987

988-
/// Determines if we are required to print the name of a property declaration,
989-
/// or if we can elide it by printing a '_' instead.
990-
static bool mustPrintPropertyName(VarDecl *decl, PrintOptions opts) {
991-
// If we're not allowed to omit the name, we must print it.
992-
if (!opts.OmitNameOfInaccessibleProperties) return true;
993-
994-
// If it contributes to the parent's storage, we must print it because clients
995-
// need to be able to directly access the storage.
996-
// FIXME: We might be able to avoid printing names for some of these
997-
// if we serialized references to them using field indices.
998-
if (contributesToParentTypeStorage(decl)) return true;
999-
1000-
// If it's public or @usableFromInline, we must print the name because it's a
1001-
// visible entry-point.
1002-
if (isPublicOrUsableFromInline(decl)) return true;
1003-
1004-
// If it has an initial value, we must print the name because it's used in
1005-
// the mangled name of the initializer expression generator function.
1006-
// FIXME: We _could_ figure out a way to generate an entry point
1007-
// for the initializer expression without revealing the name. We just
1008-
// don't have a mangling for it.
1009-
if (decl->hasInitialValue()) return true;
1010-
1011-
// If none of those are true, we can elide the name of the variable.
1012-
return false;
1013-
}
1014-
1015988
void PrintAST::printPattern(const Pattern *pattern) {
1016989
switch (pattern->getKind()) {
1017990
case PatternKind::Any:
@@ -1022,13 +995,16 @@ void PrintAST::printPattern(const Pattern *pattern) {
1022995
auto named = cast<NamedPattern>(pattern);
1023996
auto decl = named->getDecl();
1024997
recordDeclLoc(decl, [&]{
1025-
// FIXME: This always returns true now, because of the FIXMEs listed in
1026-
// mustPrintPropertyName.
1027-
if (mustPrintPropertyName(decl, Options))
1028-
Printer.printName(named->getBoundName());
1029-
else
998+
if (Options.OmitNameOfInaccessibleProperties &&
999+
contributesToParentTypeStorage(decl) &&
1000+
!isPublicOrUsableFromInline(decl) &&
1001+
// FIXME: We need to figure out a way to generate an entry point
1002+
// for the initializer expression without revealing the name.
1003+
!decl->hasInitialValue())
10301004
Printer << "_";
1031-
});
1005+
else
1006+
Printer.printName(named->getBoundName());
1007+
});
10321008
break;
10331009
}
10341010

branches/tensorflow/lib/ClangImporter/ImportType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ namespace {
515515
type->getElementType(), ImportTypeKind::Abstract,
516516
false /* No NSUIntegerAsInt */, Bridgeability::None,
517517
OptionalTypeKind::OTK_None);
518-
if (!element) { return Type(); }
519518
unsigned count = type->getNumElements();
520519
// Import vector-of-one as the element type.
521520
if (count == 1) { return element; }

branches/tensorflow/lib/Sema/MiscDiagnostics.cpp

Lines changed: 31 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,8 +2276,7 @@ class VarDeclUsageChecker : public ASTWalker {
22762276
vdi->second |= Flag;
22772277
}
22782278

2279-
void markBaseOfStorageUse(Expr *E, ConcreteDeclRef decl, unsigned flags);
2280-
void markBaseOfStorageUse(Expr *E, bool isMutating);
2279+
void markBaseOfAbstractStorageDeclStore(Expr *E, ConcreteDeclRef decl);
22812280

22822281
void markStoredOrInOutExpr(Expr *E, unsigned Flags);
22832282

@@ -2656,57 +2655,29 @@ VarDeclUsageChecker::~VarDeclUsageChecker() {
26562655
}
26572656
}
26582657

2659-
/// Handle a use of "x.y" or "x[0]" where 'base' is the expression for x and
2660-
/// 'decl' is the property or subscript.
2661-
///
2662-
/// TODO: Rip this out and just rely on LValueAccessKind.
2663-
void VarDeclUsageChecker::markBaseOfStorageUse(Expr *base, ConcreteDeclRef decl,
2664-
unsigned flags) {
2665-
// If the base is an rvalue, then we know that this is a non-mutating access.
2666-
// Note that we can have mutating accesses even when the base has class or
2667-
// metatype type due to protocols and protocol extensions.
2668-
if (!base->getType()->hasLValueType() &&
2669-
!base->isSemanticallyInOutExpr()) {
2658+
/// Handle a store to "x.y" where 'base' is the expression for x and 'decl' is
2659+
/// the decl for 'y'.
2660+
void VarDeclUsageChecker::
2661+
markBaseOfAbstractStorageDeclStore(Expr *base, ConcreteDeclRef decl) {
2662+
// If the base is a class or an rvalue, then this store just loads the base.
2663+
if (base->getType()->isAnyClassReferenceType() ||
2664+
!(base->getType()->hasLValueType() || base->isSemanticallyInOutExpr())) {
26702665
base->walk(*this);
26712666
return;
26722667
}
26732668

2674-
// Compute whether this access is to a mutating member.
2675-
auto *ASD = dyn_cast_or_null<AbstractStorageDecl>(decl.getDecl());
2676-
bool isMutating = false;
2677-
if (!ASD) {
2678-
// If there's no abstract storage declaration (which should hopefully
2679-
// only happen with invalid code), treat the base access as mutating if
2680-
// the subobject is being mutated and the base type is not a class
2681-
// or metatype.
2682-
if (flags & RK_Written) {
2683-
Type type = base->getType()->getRValueType()->getInOutObjectType();
2684-
if (!type->isAnyClassReferenceType() && !type->is<AnyMetatypeType>())
2685-
isMutating = true;
2686-
}
2687-
} else {
2688-
// Otherwise, consider whether the accessors are mutating.
2689-
if (flags & RK_Read)
2690-
isMutating |= ASD->isGetterMutating();
2691-
if (flags & RK_Written)
2692-
isMutating |= ASD->isSettable(nullptr) && ASD->isSetterMutating();
2693-
}
2694-
2695-
markBaseOfStorageUse(base, isMutating);
2696-
}
2697-
2698-
void VarDeclUsageChecker::markBaseOfStorageUse(Expr *base, bool isMutating) {
2699-
// CSApply sometimes wraps the base in an InOutExpr just because the
2700-
// base is an l-value; look through that so we can get more precise
2701-
// checking.
2702-
if (auto *ioe = dyn_cast<InOutExpr>(base))
2703-
base = ioe->getSubExpr();
2704-
2705-
if (!isMutating) {
2669+
// If the store is to a non-mutating member, then this is just a load, even
2670+
// if the base is an inout expr.
2671+
auto *ASD = cast<AbstractStorageDecl>(decl.getDecl());
2672+
if (ASD->isSettable(nullptr) && !ASD->isSetterMutating()) {
2673+
// Sema conservatively converts the base to inout expr when it is an lvalue.
2674+
// Look through it because we know it isn't actually doing a load/store.
2675+
if (auto *ioe = dyn_cast<InOutExpr>(base))
2676+
base = ioe->getSubExpr();
27062677
base->walk(*this);
27072678
return;
27082679
}
2709-
2680+
27102681
// Otherwise this is a read and write of the base.
27112682
return markStoredOrInOutExpr(base, RK_Written|RK_Read);
27122683
}
@@ -2741,33 +2712,36 @@ void VarDeclUsageChecker::markStoredOrInOutExpr(Expr *E, unsigned Flags) {
27412712
if (auto *SE = dyn_cast<SubscriptExpr>(E)) {
27422713
// The index of the subscript is evaluated as an rvalue.
27432714
SE->getIndex()->walk(*this);
2744-
markBaseOfStorageUse(SE->getBase(), SE->getDecl(), Flags);
2715+
if (SE->hasDecl())
2716+
markBaseOfAbstractStorageDeclStore(SE->getBase(), SE->getDecl());
2717+
else // FIXME: Should not be needed!
2718+
markStoredOrInOutExpr(SE->getBase(), RK_Written|RK_Read);
2719+
27452720
return;
27462721
}
27472722

27482723
// Likewise for key path applications. An application of a WritableKeyPath
2749-
// reads and writes its base; an application of a ReferenceWritableKeyPath
2750-
// only reads its base; the other KeyPath types cannot be written at all.
2724+
// reads and writes its base.
27512725
if (auto *KPA = dyn_cast<KeyPathApplicationExpr>(E)) {
27522726
auto &C = KPA->getType()->getASTContext();
27532727
KPA->getKeyPath()->walk(*this);
2754-
2755-
bool isMutating =
2756-
(Flags & RK_Written) &&
2757-
KPA->getKeyPath()->getType()->getAnyNominal()
2758-
== C.getWritableKeyPathDecl();
2759-
markBaseOfStorageUse(KPA->getBase(), isMutating);
2728+
if (KPA->getKeyPath()->getType()->getAnyNominal()
2729+
== C.getWritableKeyPathDecl())
2730+
markStoredOrInOutExpr(KPA->getBase(), RK_Written|RK_Read);
2731+
if (KPA->getKeyPath()->getType()->getAnyNominal()
2732+
== C.getReferenceWritableKeyPathDecl())
2733+
markStoredOrInOutExpr(KPA->getBase(), RK_Read);
27602734
return;
27612735
}
27622736

27632737
if (auto *ioe = dyn_cast<InOutExpr>(E))
27642738
return markStoredOrInOutExpr(ioe->getSubExpr(), RK_Written|RK_Read);
27652739

27662740
if (auto *MRE = dyn_cast<MemberRefExpr>(E)) {
2767-
markBaseOfStorageUse(MRE->getBase(), MRE->getMember(), Flags);
2741+
markBaseOfAbstractStorageDeclStore(MRE->getBase(), MRE->getMember());
27682742
return;
27692743
}
2770-
2744+
27712745
if (auto *TEE = dyn_cast<TupleElementExpr>(E))
27722746
return markStoredOrInOutExpr(TEE->getBase(), Flags);
27732747

@@ -2776,12 +2750,6 @@ void VarDeclUsageChecker::markStoredOrInOutExpr(Expr *E, unsigned Flags) {
27762750

27772751
if (auto *BOE = dyn_cast<BindOptionalExpr>(E))
27782752
return markStoredOrInOutExpr(BOE->getSubExpr(), Flags);
2779-
2780-
// Bind existential expressions.
2781-
if (auto *OEE = dyn_cast<OpenExistentialExpr>(E)) {
2782-
OpaqueValueMap[OEE->getOpaqueValue()] = OEE->getExistentialValue();
2783-
return markStoredOrInOutExpr(OEE->getSubExpr(), Flags);
2784-
}
27852753

27862754
// If this is an OpaqueValueExpr that we've seen a mapping for, jump to the
27872755
// mapped value.
@@ -2820,16 +2788,8 @@ std::pair<bool, Expr *> VarDeclUsageChecker::walkToExprPre(Expr *E) {
28202788
if (auto VD = dyn_cast<VarDecl>(MRE->getMember().getDecl())) {
28212789
if (AssociatedGetter == VD && AssociatedGetterRefExpr == nullptr)
28222790
AssociatedGetterRefExpr = MRE;
2823-
markBaseOfStorageUse(MRE->getBase(), MRE->getMember(), RK_Read);
2824-
return { false, E };
28252791
}
28262792
}
2827-
if (auto SE = dyn_cast<SubscriptExpr>(E)) {
2828-
SE->getIndex()->walk(*this);
2829-
markBaseOfStorageUse(SE->getBase(), SE->getDecl(), RK_Read);
2830-
return { false, E };
2831-
}
2832-
28332793
// If this is an AssignExpr, see if we're mutating something that we know
28342794
// about.
28352795
if (auto *assign = dyn_cast<AssignExpr>(E)) {
@@ -2850,13 +2810,6 @@ std::pair<bool, Expr *> VarDeclUsageChecker::walkToExprPre(Expr *E) {
28502810
// If we see an OpenExistentialExpr, remember the mapping for its OpaqueValue.
28512811
if (auto *oee = dyn_cast<OpenExistentialExpr>(E))
28522812
OpaqueValueMap[oee->getOpaqueValue()] = oee->getExistentialValue();
2853-
2854-
// Visit bindings.
2855-
if (auto ove = dyn_cast<OpaqueValueExpr>(E)) {
2856-
if (auto mapping = OpaqueValueMap.lookup(ove))
2857-
mapping->walk(*this);
2858-
return { false, E };
2859-
}
28602813

28612814
// If we saw an ErrorExpr, take note of this.
28622815
if (isa<ErrorExpr>(E))

branches/tensorflow/lib/Sema/TypeCheckAccess.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,11 +1494,11 @@ class ImplementationOnlyImportChecker
14941494
offendingType->getFullName(), M->getName());
14951495
highlightOffendingType(TC, diag, complainRepr);
14961496
}
1497-
};
14981497

1499-
static_assert(std::is_convertible<DiagnoseGenerically,
1500-
CheckImplementationOnlyCallback>::value,
1501-
"DiagnoseGenerically has wrong call signature");
1498+
static_assert(std::is_convertible<DiagnoseGenerically,
1499+
CheckImplementationOnlyCallback>::value,
1500+
"DiagnoseGenerically has wrong call signature");
1501+
};
15021502

15031503
DiagnoseGenerically getDiagnoseCallback(const Decl *D) {
15041504
return DiagnoseGenerically(TC, D);

branches/tensorflow/stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ func _parseDottedVersion(_ s: String) -> [Int] {
17771777
}
17781778

17791779
public func _parseDottedVersionTriple(_ s: String) -> (Int, Int, Int) {
1780-
let array = _parseDottedVersion(s)
1780+
var array = _parseDottedVersion(s)
17811781
if array.count >= 4 {
17821782
fatalError("unexpected version")
17831783
}

0 commit comments

Comments
 (0)