Skip to content

Commit cc0c094

Browse files
committed
---
yaml --- r: 326611 b: refs/heads/tensorflow c: 19d283d h: refs/heads/master i: 326609: 9e79e67 326607: fc8bf53
1 parent 515133e commit cc0c094

40 files changed

+165
-332
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: fddc5b17f47f4bac0bb014a932cde727fe0a829f
819+
refs/heads/tensorflow: 19d283d9dcd0f58435a1941775fea97b85256a35
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/ABI/Metadata.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,12 +2340,6 @@ struct TargetProtocolConformanceDescriptor final
23402340
return TypeRef.getTypeDescriptor(getTypeKind());
23412341
}
23422342

2343-
const TargetContextDescriptor<Runtime> **_getTypeDescriptorLocation() const {
2344-
if (getTypeKind() != TypeReferenceKind::IndirectTypeDescriptor)
2345-
return nullptr;
2346-
return TypeRef.IndirectTypeDescriptor.get();
2347-
}
2348-
23492343
/// Retrieve the context of a retroactive conformance.
23502344
const TargetContextDescriptor<Runtime> *getRetroactiveContext() const {
23512345
if (!Flags.isRetroactive()) return nullptr;

branches/tensorflow/include/swift/AST/Attr.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ DECL_ATTR(_restatedObjCConformance, RestatedObjCConformance,
348348
LongAttribute | RejectByParser |
349349
NotSerialized, 70)
350350
// NOTE: 71 is unused
351-
SIMPLE_DECL_ATTR(_implicitly_unwrapped_optional, ImplicitlyUnwrappedOptional,
352-
OnFunc | OnAccessor | OnVar | OnParam | OnSubscript | OnConstructor |
353-
RejectByParser,
354-
72)
351+
// NOTE: 72 is unused
355352
DECL_ATTR(_optimize, Optimize,
356353
OnAbstractFunction | OnSubscript | OnVar |
357354
UserInaccessible,

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,13 @@ class ValueDecl : public Decl {
24122412
/// Whether this declaration is 'final'. A final class can't be subclassed,
24132413
/// a final class member can't be overriden.
24142414
unsigned isFinal : 1;
2415+
2416+
/// Whether the "isIUO" bit" has been computed yet.
2417+
unsigned isIUOComputed : 1;
2418+
2419+
/// Whether this declaration produces an implicitly unwrapped
2420+
/// optional result.
2421+
unsigned isIUO : 1;
24152422
} LazySemanticInfo = { };
24162423

24172424
friend class OverriddenDeclsRequest;
@@ -2686,6 +2693,21 @@ class ValueDecl : public Decl {
26862693
/// Returns true if this decl can be found by id-style dynamic lookup.
26872694
bool canBeAccessedByDynamicLookup() const;
26882695

2696+
/// Returns true if this declaration has an implicitly unwrapped optional
2697+
/// result. The precise meaning depends on the declaration kind:
2698+
/// - for properties, the value is IUO
2699+
/// - for subscripts, the element type is IUO
2700+
/// - for functions, the result type is IUO
2701+
/// - for constructors, the failability kind is IUO
2702+
bool isImplicitlyUnwrappedOptional() const;
2703+
2704+
/// Should only be set on imported and deserialized declarations; parsed
2705+
/// declarations compute this lazily via a request.
2706+
void setImplicitlyUnwrappedOptional(bool isIUO) {
2707+
LazySemanticInfo.isIUOComputed = 1;
2708+
LazySemanticInfo.isIUO = isIUO;
2709+
}
2710+
26892711
/// Returns the protocol requirements that this decl conforms to.
26902712
ArrayRef<ValueDecl *>
26912713
getSatisfiedProtocolRequirements(bool Sorted = false) const;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ struct PrintOptions {
292292
/// List of attribute kinds that should not be printed.
293293
std::vector<AnyAttrKind> ExcludeAttrList = {DAK_Transparent, DAK_Effects,
294294
DAK_FixedLayout,
295-
DAK_ShowInInterface,
296-
DAK_ImplicitlyUnwrappedOptional};
295+
DAK_ShowInInterface};
297296

298297
/// List of attribute kinds that should be printed exclusively.
299298
/// Empty means allow all.

branches/tensorflow/include/swift/ClangImporter/ClangImporter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ClangImporter final : public ClangModuleLoader {
9393

9494
ClangImporter(ASTContext &ctx, const ClangImporterOptions &clangImporterOpts,
9595
DependencyTracker *tracker,
96-
DWARFImporterDelegate *dwarfImporterDelegate);
96+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate);
9797

9898
ModuleDecl *loadModuleClang(SourceLoc importLoc,
9999
ArrayRef<std::pair<Identifier, SourceLoc>> path);
@@ -119,7 +119,7 @@ class ClangImporter final : public ClangModuleLoader {
119119
static std::unique_ptr<ClangImporter>
120120
create(ASTContext &ctx, const ClangImporterOptions &importerOpts,
121121
std::string swiftPCHHash = "", DependencyTracker *tracker = nullptr,
122-
DWARFImporterDelegate *dwarfImporterDelegate = nullptr);
122+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate = {});
123123

124124
ClangImporter(const ClangImporter &) = delete;
125125
ClangImporter(ClangImporter &&) = delete;

branches/tensorflow/include/swift/Serialization/ModuleFormat.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 509; // [dynamic_lifetime] sil flag
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 510; // serialize isIUO bit on ValueDecls
5656

5757
using DeclIDField = BCFixed<31>;
5858

@@ -1059,6 +1059,7 @@ namespace decls_block {
10591059
ReadWriteImplKindField, // read-write implementation
10601060
AccessorCountField, // number of accessors
10611061
TypeIDField, // interface type
1062+
BCFixed<1>, // IUO value?
10621063
DeclIDField, // overridden decl
10631064
AccessLevelField, // access level
10641065
AccessLevelField, // setter access, if applicable
@@ -1075,6 +1076,7 @@ namespace decls_block {
10751076
DeclContextIDField, // context decl
10761077
ParamDeclSpecifierField, // specifier
10771078
TypeIDField, // interface type
1079+
BCFixed<1>, // isIUO?
10781080
BCFixed<1>, // isVariadic?
10791081
BCFixed<1>, // isAutoClosure?
10801082
DefaultArgumentField, // default argument kind
@@ -1093,6 +1095,7 @@ namespace decls_block {
10931095
BCFixed<1>, // throws?
10941096
GenericEnvironmentIDField, // generic environment
10951097
TypeIDField, // result interface type
1098+
BCFixed<1>, // IUO result?
10961099
DeclIDField, // operator decl
10971100
DeclIDField, // overridden function
10981101
BCVBR<5>, // 0 for a simple name, otherwise the number of parameter name
@@ -1134,6 +1137,7 @@ namespace decls_block {
11341137
BCFixed<1>, // throws?
11351138
GenericEnvironmentIDField, // generic environment
11361139
TypeIDField, // result interface type
1140+
BCFixed<1>, // IUO result?
11371141
DeclIDField, // overridden function
11381142
DeclIDField, // AccessorStorageDecl
11391143
AccessorKindField, // accessor kind
@@ -1220,6 +1224,7 @@ namespace decls_block {
12201224
AccessorCountField, // number of accessors
12211225
GenericEnvironmentIDField, // generic environment
12221226
TypeIDField, // element interface type
1227+
BCFixed<1>, // IUO element?
12231228
DeclIDField, // overridden decl
12241229
AccessLevelField, // access level
12251230
AccessLevelField, // setter access, if applicable

branches/tensorflow/lib/AST/ASTPrinter.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ PrintOptions PrintOptions::printParseableInterfaceFile(bool preferTypeRepr) {
191191
// the default to 'public' and mark the 'internal' things.
192192
result.PrintAccess = true;
193193

194-
result.ExcludeAttrList = {DAK_ImplicitlyUnwrappedOptional, DAK_AccessControl,
195-
DAK_SetterAccess, DAK_Lazy};
194+
result.ExcludeAttrList = {DAK_AccessControl, DAK_SetterAccess, DAK_Lazy};
196195

197196
return result;
198197
}
@@ -703,9 +702,9 @@ class PrintAST : public ASTVisitor<PrintAST> {
703702

704703
void printTypeLoc(const TypeLoc &TL) { printTypeLocWithOptions(TL, Options); }
705704

706-
void printTypeLocForImplicitlyUnwrappedOptional(TypeLoc TL) {
705+
void printTypeLocForImplicitlyUnwrappedOptional(TypeLoc TL, bool IUO) {
707706
PrintOptions options = Options;
708-
options.PrintOptionalAsImplicitlyUnwrapped = true;
707+
options.PrintOptionalAsImplicitlyUnwrapped = IUO;
709708
printTypeLocWithOptions(TL, options);
710709
}
711710

@@ -993,12 +992,9 @@ void PrintAST::printTypedPattern(const TypedPattern *TP) {
993992
bool isIUO = false;
994993
if (auto *named = dyn_cast<NamedPattern>(TP->getSubPattern()))
995994
if (auto decl = named->getDecl())
996-
isIUO = decl->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>();
995+
isIUO = decl->isImplicitlyUnwrappedOptional();
997996

998-
if (isIUO)
999-
printTypeLocForImplicitlyUnwrappedOptional(TP->getTypeLoc());
1000-
else
1001-
printTypeLoc(TP->getTypeLoc());
997+
printTypeLocForImplicitlyUnwrappedOptional(TP->getTypeLoc(), isIUO);
1002998
}
1003999

10041000
/// Determines if we are required to print the name of a property declaration,
@@ -2528,10 +2524,8 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
25282524
x(Options.OpaqueReturnTypePrinting,
25292525
PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword);
25302526

2531-
if (decl->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>())
2532-
printTypeLocForImplicitlyUnwrappedOptional(tyLoc);
2533-
else
2534-
printTypeLoc(tyLoc);
2527+
printTypeLocForImplicitlyUnwrappedOptional(
2528+
tyLoc, decl->isImplicitlyUnwrappedOptional());
25352529
}
25362530

25372531
printAccessors(decl);
@@ -2608,10 +2602,8 @@ void PrintAST::printOneParameter(const ParamDecl *param,
26082602
isEscaping(type));
26092603
}
26102604

2611-
if (param->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>())
2612-
printTypeLocForImplicitlyUnwrappedOptional(TheTypeLoc);
2613-
else
2614-
printTypeLoc(TheTypeLoc);
2605+
printTypeLocForImplicitlyUnwrappedOptional(
2606+
TheTypeLoc, param->isImplicitlyUnwrappedOptional());
26152607

26162608
if (param->isVariadic())
26172609
Printer << "...";
@@ -2832,10 +2824,8 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
28322824
x(Options.OpaqueReturnTypePrinting,
28332825
PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword);
28342826

2835-
if (decl->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>())
2836-
printTypeLocForImplicitlyUnwrappedOptional(ResultTyLoc);
2837-
else
2838-
printTypeLoc(ResultTyLoc);
2827+
printTypeLocForImplicitlyUnwrappedOptional(
2828+
ResultTyLoc, decl->isImplicitlyUnwrappedOptional());
28392829
Printer.printStructurePost(PrintStructureKind::FunctionReturnType);
28402830
}
28412831
printGenericDeclGenericRequirements(decl);
@@ -2982,10 +2972,8 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
29822972
x(Options.OpaqueReturnTypePrinting,
29832973
PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword);
29842974

2985-
if (decl->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>())
2986-
printTypeLocForImplicitlyUnwrappedOptional(elementTy);
2987-
else
2988-
printTypeLoc(elementTy);
2975+
printTypeLocForImplicitlyUnwrappedOptional(
2976+
elementTy, decl->isImplicitlyUnwrappedOptional());
29892977
Printer.printStructurePost(PrintStructureKind::FunctionReturnType);
29902978
printGenericDeclGenericRequirements(decl);
29912979
printAccessors(decl);

branches/tensorflow/lib/AST/ASTVerifier.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,9 +2526,8 @@ class Verifier : public ASTWalker {
25262526
}
25272527
}
25282528

2529-
if (var->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>()) {
2530-
auto varTy = var->getInterfaceType()
2531-
->getReferenceStorageReferent();
2529+
if (var->isImplicitlyUnwrappedOptional()) {
2530+
auto varTy = var->getValueInterfaceType();
25322531

25332532
// FIXME: Update to look for plain Optional once
25342533
// ImplicitlyUnwrappedOptional is removed
@@ -2975,14 +2974,7 @@ class Verifier : public ASTWalker {
29752974
}
29762975
}
29772976

2978-
if (CD->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>()) {
2979-
if (!CD->getInterfaceType() ||
2980-
!CD->getInterfaceType()->is<AnyFunctionType>()) {
2981-
Out << "Expected ConstructorDecl to have a function type!\n";
2982-
CD->dump(llvm::errs());
2983-
abort();
2984-
}
2985-
2977+
if (CD->isImplicitlyUnwrappedOptional()) {
29862978
if (CD->getFailability() != OTK_ImplicitlyUnwrappedOptional) {
29872979
Out << "Expected IUO failability for constructor with IUO decl "
29882980
"attribute!\n";
@@ -2992,8 +2984,6 @@ class Verifier : public ASTWalker {
29922984

29932985
auto resultTy = CD->getResultInterfaceType();
29942986

2995-
// FIXME: Update to look for plain Optional once
2996-
// ImplicitlyUnwrappedOptional is removed
29972987
if (!resultTy->getOptionalObjectType()) {
29982988
Out << "implicitly unwrapped optional attribute should only be set "
29992989
"on constructors with optional return types\n";
@@ -3192,17 +3182,8 @@ class Verifier : public ASTWalker {
31923182
}
31933183
}
31943184

3195-
if (FD->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>()) {
3196-
if (!FD->getInterfaceType() ||
3197-
!FD->getInterfaceType()->is<AnyFunctionType>()) {
3198-
Out << "Expected FuncDecl to have a function type!\n";
3199-
abort();
3200-
}
3201-
3185+
if (FD->isImplicitlyUnwrappedOptional()) {
32023186
auto resultTy = FD->getResultInterfaceType();
3203-
3204-
// FIXME: Update to look for plain Optional once
3205-
// ImplicitlyUnwrappedOptional is removed
32063187
if (!resultTy->getOptionalObjectType()) {
32073188
Out << "implicitly unwrapped optional attribute should only be set "
32083189
"on functions with optional return types\n";

branches/tensorflow/lib/AST/Decl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,6 +2685,10 @@ bool ValueDecl::canBeAccessedByDynamicLookup() const {
26852685
return true;
26862686
}
26872687

2688+
bool ValueDecl::isImplicitlyUnwrappedOptional() const {
2689+
return LazySemanticInfo.isIUO;
2690+
}
2691+
26882692
ArrayRef<ValueDecl *>
26892693
ValueDecl::getSatisfiedProtocolRequirements(bool Sorted) const {
26902694
// Dig out the nominal type.
@@ -5711,10 +5715,7 @@ ParamDecl::ParamDecl(ParamDecl *PD, bool withTypes)
57115715
if (withTypes && PD->hasInterfaceType())
57125716
setInterfaceType(PD->getInterfaceType());
57135717

5714-
// FIXME: We should clone the entire attribute list.
5715-
if (PD->getAttrs().hasAttribute<ImplicitlyUnwrappedOptionalAttr>())
5716-
getAttrs().add(new (PD->getASTContext())
5717-
ImplicitlyUnwrappedOptionalAttr(/* implicit= */ true));
5718+
setImplicitlyUnwrappedOptional(PD->isImplicitlyUnwrappedOptional());
57185719
}
57195720

57205721

branches/tensorflow/lib/ClangImporter/ClangImporter.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ bool ClangImporter::Implementation::shouldIgnoreBridgeHeaderTopLevelDecl(
386386
return false;
387387
}
388388

389-
ClangImporter::ClangImporter(ASTContext &ctx,
390-
const ClangImporterOptions &clangImporterOpts,
391-
DependencyTracker *tracker,
392-
DWARFImporterDelegate *dwarfImporterDelegate)
389+
ClangImporter::ClangImporter(
390+
ASTContext &ctx, const ClangImporterOptions &clangImporterOpts,
391+
DependencyTracker *tracker,
392+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate)
393393
: ClangModuleLoader(tracker),
394-
Impl(*new Implementation(ctx, clangImporterOpts, dwarfImporterDelegate)) {
395-
}
394+
Impl(*new Implementation(ctx, clangImporterOpts,
395+
std::move(dwarfImporterDelegate))) {}
396396

397397
ClangImporter::~ClangImporter() {
398398
delete &Impl;
@@ -909,12 +909,12 @@ ClangImporter::getOrCreatePCH(const ClangImporterOptions &ImporterOptions,
909909
return PCHFilename.getValue();
910910
}
911911

912-
std::unique_ptr<ClangImporter>
913-
ClangImporter::create(ASTContext &ctx, const ClangImporterOptions &importerOpts,
914-
std::string swiftPCHHash, DependencyTracker *tracker,
915-
DWARFImporterDelegate *dwarfImporterDelegate) {
916-
std::unique_ptr<ClangImporter> importer{
917-
new ClangImporter(ctx, importerOpts, tracker, dwarfImporterDelegate)};
912+
std::unique_ptr<ClangImporter> ClangImporter::create(
913+
ASTContext &ctx, const ClangImporterOptions &importerOpts,
914+
std::string swiftPCHHash, DependencyTracker *tracker,
915+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate) {
916+
std::unique_ptr<ClangImporter> importer{new ClangImporter(
917+
ctx, importerOpts, tracker, std::move(dwarfImporterDelegate))};
918918

919919
std::vector<std::string> invocationArgStrs;
920920

@@ -1843,7 +1843,7 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable(
18431843

18441844
ClangImporter::Implementation::Implementation(
18451845
ASTContext &ctx, const ClangImporterOptions &opts,
1846-
DWARFImporterDelegate *dwarfImporterDelegate)
1846+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate)
18471847
: SwiftContext(ctx),
18481848
ImportForwardDeclarations(opts.ImportForwardDeclarations),
18491849
InferImportAsMember(opts.InferImportAsMember),
@@ -1854,7 +1854,7 @@ ClangImporter::Implementation::Implementation(
18541854
CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
18551855
BridgingHeaderLookupTable(new SwiftLookupTable(nullptr)),
18561856
platformAvailability(ctx.LangOpts), nameImporter(),
1857-
DWARFImporter(dwarfImporterDelegate) {}
1857+
DWARFImporter(std::move(dwarfImporterDelegate)) {}
18581858

18591859
ClangImporter::Implementation::~Implementation() {
18601860
#ifndef NDEBUG

branches/tensorflow/lib/ClangImporter/DWARFImporter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ void ClangImporter::Implementation::lookupValueDWARF(
138138
return;
139139

140140
SmallVector<clang::Decl *, 4> decls;
141-
DWARFImporter->lookupValue(name.getBaseIdentifier().str(), None, decls);
141+
DWARFImporter->lookupValue(name.getBaseIdentifier().str(), llvm::None, decls);
142142
for (auto *clangDecl : decls) {
143-
auto *namedDecl = dyn_cast<clang::NamedDecl>(clangDecl);
143+
auto *namedDecl = dyn_cast_or_null<clang::NamedDecl>(clangDecl);
144144
if (!namedDecl)
145145
continue;
146146
auto *swiftDecl = cast_or_null<ValueDecl>(
@@ -168,7 +168,9 @@ void ClangImporter::Implementation::lookupTypeDeclDWARF(
168168
!isa<clang::ObjCCompatibleAliasDecl>(clangDecl)) {
169169
continue;
170170
}
171-
auto *namedDecl = cast<clang::NamedDecl>(clangDecl);
171+
auto *namedDecl = dyn_cast_or_null<clang::NamedDecl>(clangDecl);
172+
if (!namedDecl)
173+
continue;
172174
Decl *importedDecl = cast_or_null<ValueDecl>(
173175
importDeclReal(namedDecl->getMostRecentDecl(), CurrentVersion));
174176

0 commit comments

Comments
 (0)