Skip to content

Commit faceeed

Browse files
committed
---
yaml --- r: 326535 b: refs/heads/tensorflow c: 8ef3658 h: refs/heads/master i: 326533: b4c3880 326531: b7e2ba2 326527: e67cc5e
1 parent 1b18d99 commit faceeed

21 files changed

+104
-139
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: 7b9a51108a0be8437f2f9b255a57c81e4e295cc7
819+
refs/heads/tensorflow: 8ef36588d151ff36793468f5552919018851f19f
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/ClangModuleLoader.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define SWIFT_AST_CLANG_MODULE_LOADER_H
1515

1616
#include "swift/AST/ModuleLoader.h"
17-
#include "swift/Demangling/Demangle.h"
1817

1918
namespace clang {
2019
class ASTContext;
@@ -28,11 +27,24 @@ namespace swift {
2827
class DeclContext;
2928
class VisibleDeclConsumer;
3029

30+
/// Represents the different namespaces for types in C.
31+
///
32+
/// A simplified version of clang::Sema::LookupKind.
33+
enum class ClangTypeKind {
34+
Typedef,
35+
ObjCClass = Typedef,
36+
/// Structs, enums, and unions.
37+
Tag,
38+
ObjCProtocol,
39+
};
40+
3141
class ClangModuleLoader : public ModuleLoader {
3242
private:
3343
virtual void anchor();
44+
3445
protected:
3546
using ModuleLoader::ModuleLoader;
47+
3648
public:
3749
virtual clang::ASTContext &getClangASTContext() const = 0;
3850
virtual clang::Preprocessor &getClangPreprocessor() const = 0;
@@ -56,9 +68,9 @@ class ClangModuleLoader : public ModuleLoader {
5668
///
5769
/// This routine is used for various hacks that are only permitted within
5870
/// overlays of imported modules, e.g., Objective-C bridging conformances.
59-
virtual bool isInOverlayModuleForImportedModule(
60-
const DeclContext *overlayDC,
61-
const DeclContext *importedDC) = 0;
71+
virtual bool
72+
isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
73+
const DeclContext *importedDC) = 0;
6274

6375
/// Look for declarations associated with the given name.
6476
///
@@ -70,7 +82,7 @@ class ClangModuleLoader : public ModuleLoader {
7082
/// Note that this method does no filtering. If it finds the type in a loaded
7183
/// module, it returns it. This is intended for use in reflection / debugging
7284
/// contexts where access is not a problem.
73-
virtual void lookupTypeDecl(StringRef clangName, Demangle::Node::Kind kind,
85+
virtual void lookupTypeDecl(StringRef clangName, ClangTypeKind kind,
7486
llvm::function_ref<void(TypeDecl *)> receiver) {}
7587

7688
/// Look up type a declaration synthesized by the Clang importer itself, using
@@ -89,4 +101,3 @@ class ClangModuleLoader : public ModuleLoader {
89101
} // namespace swift
90102

91103
#endif // LLVM_SWIFT_AST_CLANG_MODULE_LOADER_H
92-

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ class TypeDecl;
6060
class VisibleDeclConsumer;
6161
enum class SelectorSplitKind;
6262

63-
/// Represents the different namespaces for types in C.
64-
///
65-
/// A simplified version of clang::Sema::LookupKind.
66-
enum class ClangTypeKind {
67-
Typedef,
68-
ObjCClass = Typedef,
69-
/// Structs, enums, and unions.
70-
Tag,
71-
ObjCProtocol,
72-
};
73-
7463
/// Class that imports Clang modules into Swift, mapping directly
7564
/// from Clang ASTs over to Swift ASTs.
7665
class ClangImporter final : public ClangModuleLoader {
@@ -168,8 +157,8 @@ class ClangImporter final : public ClangModuleLoader {
168157
/// Note that this method does no filtering. If it finds the type in a loaded
169158
/// module, it returns it. This is intended for use in reflection / debugging
170159
/// contexts where access is not a problem.
171-
void lookupTypeDecl(StringRef clangName, Demangle::Node::Kind kind,
172-
llvm::function_ref<void(TypeDecl*)> receiver) override;
160+
void lookupTypeDecl(StringRef clangName, ClangTypeKind kind,
161+
llvm::function_ref<void(TypeDecl *)> receiver) override;
173162

174163
/// Look up type a declaration synthesized by the Clang importer itself, using
175164
/// a "related entity kind" to determine which type it should be. For example,

branches/tensorflow/include/swift/DWARFImporter/DWARFImporter.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "swift/AST/ClangModuleLoader.h"
2121
#include "swift/AST/Module.h"
22-
#include "swift/Demangling/Demangle.h"
2322

2423
namespace llvm {
2524
}
@@ -40,11 +39,10 @@ namespace swift {
4039
/// Clang AST to ClangImporter to import the type into Swift.
4140
class DWARFImporterDelegate {
4241
public:
43-
virtual ~DWARFImporterDelegate() = default;
42+
virtual ~DWARFImporterDelegate() {}
4443
/// Perform a qualified lookup of a Clang type with this name.
4544
/// \param kind Only return results with this type kind.
46-
virtual void lookupValue(StringRef name,
47-
llvm::Optional<Demangle::Node::Kind> kind,
45+
virtual void lookupValue(StringRef name, llvm::Optional<ClangTypeKind> kind,
4846
SmallVectorImpl<clang::Decl *> &results) {}
4947
};
5048

@@ -111,7 +109,7 @@ class DWARFImporter final : public ClangModuleLoader {
111109
NLKind lookupKind, SmallVectorImpl<ValueDecl *> &results);
112110
/// Perform a qualified lookup of a Clang type with this name and only return
113111
/// results with the specified type kind.
114-
void lookupTypeDecl(StringRef rawName, Demangle::Node::Kind kind,
112+
void lookupTypeDecl(StringRef rawName, ClangTypeKind kind,
115113
llvm::function_ref<void(TypeDecl *)> receiver) override;
116114
bool
117115
isInOverlayModuleForImportedModule(const DeclContext *overlayDC,

branches/tensorflow/lib/AST/ASTDemangler.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,23 @@ ASTBuilder::findTypeDecl(DeclContext *dc,
10231023
return result;
10241024
}
10251025

1026+
static Optional<ClangTypeKind>
1027+
getClangTypeKindForNodeKind(Demangle::Node::Kind kind) {
1028+
switch (kind) {
1029+
case Demangle::Node::Kind::Protocol:
1030+
return ClangTypeKind::ObjCProtocol;
1031+
case Demangle::Node::Kind::Class:
1032+
return ClangTypeKind::ObjCClass;
1033+
case Demangle::Node::Kind::TypeAlias:
1034+
return ClangTypeKind::Typedef;
1035+
case Demangle::Node::Kind::Structure:
1036+
case Demangle::Node::Kind::Enum:
1037+
return ClangTypeKind::Tag;
1038+
default:
1039+
return None;
1040+
}
1041+
}
1042+
10261043
GenericTypeDecl *ASTBuilder::findForeignTypeDecl(StringRef name,
10271044
StringRef relatedEntityKind,
10281045
ForeignModuleKind foreignKind,
@@ -1060,6 +1077,10 @@ GenericTypeDecl *ASTBuilder::findForeignTypeDecl(StringRef name,
10601077
consumer.foundDecl(found, DeclVisibilityKind::VisibleAtTopLevel);
10611078
};
10621079

1080+
Optional<ClangTypeKind> lookupKind = getClangTypeKindForNodeKind(kind);
1081+
if (!lookupKind)
1082+
return nullptr;
1083+
10631084
switch (foreignKind) {
10641085
case ForeignModuleKind::SynthesizedByImporter:
10651086
if (!relatedEntityKind.empty()) {
@@ -1071,12 +1092,12 @@ GenericTypeDecl *ASTBuilder::findForeignTypeDecl(StringRef name,
10711092
consumer.Result = getAcceptableTypeDeclCandidate(consumer.Result, kind);
10721093
break;
10731094
case ForeignModuleKind::Imported:
1074-
importer->lookupTypeDecl(name, kind, found);
1095+
importer->lookupTypeDecl(name, *lookupKind, found);
10751096

10761097
// Try the DWARFImporter if it exists.
10771098
if (!consumer.Result)
10781099
if (auto *dwarf_importer = Ctx.getDWARFModuleLoader())
1079-
dwarf_importer->lookupTypeDecl(name, kind, found);
1100+
dwarf_importer->lookupTypeDecl(name, *lookupKind, found);
10801101
}
10811102

10821103
return consumer.Result;

branches/tensorflow/lib/AST/Decl.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,11 +1366,9 @@ ParamDecl *PatternBindingInitializer::getImplicitSelfDecl() {
13661366
}
13671367

13681368
VarDecl *PatternBindingInitializer::getInitializedLazyVar() const {
1369-
if (auto binding = getBinding()) {
1370-
if (auto var = binding->getSingleVar()) {
1371-
if (var->getAttrs().hasAttribute<LazyAttr>())
1372-
return var;
1373-
}
1369+
if (auto var = getBinding()->getSingleVar()) {
1370+
if (var->getAttrs().hasAttribute<LazyAttr>())
1371+
return var;
13741372
}
13751373
return nullptr;
13761374
}

branches/tensorflow/lib/AST/UnqualifiedLookup.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,18 @@ void UnqualifiedLookupFactory::lookupInModuleScopeContext(
598598

599599
void UnqualifiedLookupFactory::lookupNamesIntroducedByPatternBindingInitializer(
600600
PatternBindingInitializer *PBI, Optional<bool> isCascadingUse) {
601+
assert(PBI->getBinding());
601602
// Lazy variable initializer contexts have a 'self' parameter for
602603
// instance member lookup.
603604
if (auto *selfParam = PBI->getImplicitSelfDecl())
604605
lookupNamesIntroducedByLazyVariableInitializer(PBI, selfParam,
605606
isCascadingUse);
606-
else if (PBI->getParent()->isTypeContext())
607+
else if (PBI->getBinding()->getDeclContext()->isTypeContext())
607608
lookupNamesIntroducedByInitializerOfStoredPropertyOfAType(PBI,
608609
isCascadingUse);
609610
else
610611
lookupNamesIntroducedByInitializerOfGlobalOrLocal(PBI, isCascadingUse);
611-
}
612+
}
612613

613614
void UnqualifiedLookupFactory::lookupNamesIntroducedByLazyVariableInitializer(
614615
PatternBindingInitializer *PBI, ParamDecl *selfParam,

branches/tensorflow/lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,34 +2495,14 @@ void ClangImporter::lookupValue(DeclName name, VisibleDeclConsumer &consumer){
24952495
});
24962496
}
24972497

2498-
static Optional<ClangTypeKind>
2499-
getClangTypeKindForNodeKind(Demangle::Node::Kind kind) {
2500-
switch (kind) {
2501-
case Demangle::Node::Kind::Protocol:
2502-
return ClangTypeKind::ObjCProtocol;
2503-
case Demangle::Node::Kind::Class:
2504-
return ClangTypeKind::ObjCClass;
2505-
case Demangle::Node::Kind::TypeAlias:
2506-
return ClangTypeKind::Typedef;
2507-
case Demangle::Node::Kind::Structure:
2508-
case Demangle::Node::Kind::Enum:
2509-
return ClangTypeKind::Tag;
2510-
default:
2511-
return None;
2512-
}
2513-
}
2514-
25152498
void ClangImporter::lookupTypeDecl(
2516-
StringRef rawName, Demangle::Node::Kind kind,
2499+
StringRef rawName, ClangTypeKind kind,
25172500
llvm::function_ref<void(TypeDecl *)> receiver) {
25182501
clang::DeclarationName clangName(
25192502
&Impl.Instance->getASTContext().Idents.get(rawName));
25202503

25212504
clang::Sema::LookupNameKind lookupKind;
2522-
auto clang_kind = getClangTypeKindForNodeKind(kind);
2523-
if (!clang_kind)
2524-
return;
2525-
switch (*clang_kind) {
2505+
switch (kind) {
25262506
case ClangTypeKind::Typedef:
25272507
lookupKind = clang::Sema::LookupOrdinaryName;
25282508
break;
@@ -2560,10 +2540,10 @@ void ClangImporter::lookupRelatedEntity(
25602540
CISTAttr::manglingNameForKind(CISTAttr::Kind::NSErrorWrapper) ||
25612541
relatedEntityKind ==
25622542
CISTAttr::manglingNameForKind(CISTAttr::Kind::NSErrorWrapperAnon)) {
2563-
auto underlyingKind = Demangle::Node::Kind::Structure;
2543+
auto underlyingKind = ClangTypeKind::Tag;
25642544
if (relatedEntityKind ==
25652545
CISTAttr::manglingNameForKind(CISTAttr::Kind::NSErrorWrapperAnon)) {
2566-
underlyingKind = Demangle::Node::Kind::TypeAlias;
2546+
underlyingKind = ClangTypeKind::Typedef;
25672547
}
25682548
lookupTypeDecl(rawName, underlyingKind,
25692549
[this, receiver] (const TypeDecl *foundType) {

branches/tensorflow/lib/DWARFImporter/DWARFImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class DWARFImporter::Implementation {
177177
}
178178
}
179179

180-
void lookupTypeDecl(StringRef rawName, Demangle::Node::Kind kind,
180+
void lookupTypeDecl(StringRef rawName, ClangTypeKind kind,
181181
llvm::function_ref<void(TypeDecl *)> receiver) {
182182
SmallVector<clang::Decl *, 1> decls;
183183
delegate->lookupValue(rawName, kind, decls);
@@ -250,7 +250,7 @@ void DWARFImporter::lookupValue(ModuleDecl::AccessPathTy accessPath,
250250
}
251251

252252
void DWARFImporter::lookupTypeDecl(
253-
StringRef rawName, Demangle::Node::Kind kind,
253+
StringRef rawName, ClangTypeKind kind,
254254
llvm::function_ref<void(TypeDecl *)> receiver) {
255255
Impl.lookupTypeDecl(rawName, kind, receiver);
256256
}

branches/tensorflow/lib/SILGen/SILGenStmt.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,9 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
961961
};
962962

963963
auto buildElementRValue = [&](SILLocation loc, SGFContext ctx) {
964-
RValue result;
965-
result = SGF.emitApplyMethod(
964+
return SGF.emitApplyMethod(
966965
loc, S->getIteratorNext(), buildArgumentSource(),
967-
PreparedArguments(ArrayRef<AnyFunctionType::Param>({})),
968-
S->getElementExpr() ? SGFContext() : ctx);
969-
if (S->getElementExpr()) {
970-
SILGenFunction::OpaqueValueRAII pushOpaqueValue(
971-
SGF, S->getElementExpr(),
972-
std::move(result).getAsSingleValue(SGF, loc));
973-
result = SGF.emitRValue(S->getConvertElementExpr(), ctx);
974-
}
975-
return result;
966+
PreparedArguments(ArrayRef<AnyFunctionType::Param>({})), ctx);
976967
};
977968
// Then emit the loop destination block.
978969
//
@@ -985,7 +976,17 @@ void StmtEmitter::visitForEachStmt(ForEachStmt *S) {
985976
{
986977
ArgumentScope innerForScope(SGF, SILLocation(S));
987978
SILLocation loc = SILLocation(S);
988-
RValue result = buildElementRValue(loc, SGFContext(nextInit.get()));
979+
RValue result;
980+
if (S->getElementExpr()) {
981+
result = buildElementRValue(loc, SGFContext());
982+
SILGenFunction::OpaqueValueRAII pushOpaqueValue(
983+
SGF, S->getElementExpr(),
984+
std::move(result).getAsSingleValue(SGF, loc));
985+
result = SGF.emitRValue(S->getConvertElementExpr(),
986+
SGFContext(nextInit.get()));
987+
} else {
988+
result = buildElementRValue(loc, SGFContext(nextInit.get()));
989+
}
989990
if (!result.isInContext()) {
990991
ArgumentSource(SILLocation(S->getSequence()),
991992
std::move(result).ensurePlusOne(SGF, loc))

branches/tensorflow/stdlib/public/runtime/ImageInspection.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,10 @@ void initializeDynamicReplacementLookup();
7676

7777
// Callbacks to register metadata from an image to the runtime.
7878
void addImageProtocolsBlockCallback(const void *start, uintptr_t size);
79-
void addImageProtocolsBlockCallbackUnsafe(const void *start, uintptr_t size);
8079
void addImageProtocolConformanceBlockCallback(const void *start,
8180
uintptr_t size);
82-
void addImageProtocolConformanceBlockCallbackUnsafe(const void *start,
83-
uintptr_t size);
8481
void addImageTypeMetadataRecordBlockCallback(const void *start,
8582
uintptr_t size);
86-
void addImageTypeMetadataRecordBlockCallbackUnsafe(const void *start,
87-
uintptr_t size);
8883
void addImageDynamicReplacementBlockCallback(const void *start, uintptr_t size,
8984
const void *start2,
9085
uintptr_t size2);

branches/tensorflow/stdlib/public/runtime/ImageInspectionCOFF.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ void swift::initializeProtocolLookup() {
4848
const swift::MetadataSections::Range &protocols =
4949
sections->swift5_protocols;
5050
if (protocols.length)
51-
addImageProtocolsBlockCallbackUnsafe(
52-
reinterpret_cast<void *>(protocols.start), protocols.length);
51+
addImageProtocolsBlockCallback(reinterpret_cast<void *>(protocols.start),
52+
protocols.length);
5353

5454
if (sections->next == registered)
5555
break;
@@ -63,8 +63,8 @@ void swift::initializeProtocolConformanceLookup() {
6363
const swift::MetadataSections::Range &conformances =
6464
sections->swift5_protocol_conformances;
6565
if (conformances.length)
66-
addImageProtocolConformanceBlockCallbackUnsafe(
67-
reinterpret_cast<void *>(conformances.start), conformances.length);
66+
addImageProtocolConformanceBlockCallback(reinterpret_cast<void *>(conformances.start),
67+
conformances.length);
6868

6969
if (sections->next == registered)
7070
break;
@@ -78,8 +78,8 @@ void swift::initializeTypeMetadataRecordLookup() {
7878
const swift::MetadataSections::Range &type_metadata =
7979
sections->swift5_type_metadata;
8080
if (type_metadata.length)
81-
addImageTypeMetadataRecordBlockCallbackUnsafe(
82-
reinterpret_cast<void *>(type_metadata.start), type_metadata.length);
81+
addImageTypeMetadataRecordBlockCallback(reinterpret_cast<void *>(type_metadata.start),
82+
type_metadata.length);
8383

8484
if (sections->next == registered)
8585
break;

0 commit comments

Comments
 (0)