Skip to content

Commit 23b62ad

Browse files
authored
---
yaml --- r: 326587 b: refs/heads/tensorflow c: 1afd0f7 h: refs/heads/master i: 326585: edca0c1 326583: 623179c
1 parent d633c8e commit 23b62ad

File tree

96 files changed

+9325
-7852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+9325
-7852
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: 73e5a64bd1f3c4a86024a34f062b5dd6c83a3f11
819+
refs/heads/tensorflow: 1afd0f7cf757ba6b12d2af0d151eafb022acf439
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/ASTScope.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ class ASTScopeImpl {
177177
void addChild(ASTScopeImpl *child, ASTContext &);
178178
std::vector<ASTScopeImpl *> rescueYoungestChildren(unsigned count);
179179

180-
virtual std::vector<ASTScopeImpl *> rescueScopesToReuse();
181-
virtual void addReusedScopes(ArrayRef<ASTScopeImpl *>);
180+
/// When reexpanding, do we always create a new body?
181+
virtual NullablePtr<ASTScopeImpl> getParentOfRescuedScopes();
182+
std::vector<ASTScopeImpl *> rescueScopesToReuse();
183+
void addReusedScopes(ArrayRef<ASTScopeImpl *>);
182184

183185
private:
184186
void removeChildren();
@@ -201,7 +203,8 @@ class ASTScopeImpl {
201203
/// InterpolatedStringLiteralExprs and EditorPlaceHolders respond to
202204
/// getSourceRange with the starting point. But we might be asked to lookup an
203205
/// identifer within one of them. So, find the real source range of them here.
204-
/// /// FIXME: Alter how these are parsed so getSourceRange is enough.
206+
///
207+
/// FIXME: Alter how these are parsed so getSourceRange is enough.
205208
SourceRange getEffectiveSourceRange(ASTNode) const;
206209

207210
void cacheSourceRangeOfMeAndDescendants(bool omitAssertions = false) const;
@@ -303,6 +306,12 @@ class ASTScopeImpl {
303306
virtual void beCurrent();
304307
virtual bool isCurrent() const;
305308

309+
/// Some scopes can be expanded lazily.
310+
/// Such scopes must: not change their source ranges after expansion, and
311+
/// their expansion must return an insertion point outside themselves.
312+
virtual NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion();
313+
virtual SourceRange sourceRangeForDeferredExpansion() const;
314+
306315
public:
307316
// Some nodes (VarDecls and Accessors) are created directly from
308317
// pattern scope code and should neither be deferred nor should
@@ -548,6 +557,10 @@ class Portion {
548557

549558
virtual void beCurrent(IterableTypeScope *) const;
550559
virtual bool isCurrent(const IterableTypeScope *) const;
560+
virtual NullablePtr<ASTScopeImpl>
561+
insertionPointForDeferredExpansion(IterableTypeScope *) const;
562+
virtual SourceRange
563+
sourceRangeForDeferredExpansion(const IterableTypeScope *) const;
551564
};
552565

553566
// For the whole Decl scope of a GenericType or an Extension
@@ -623,6 +636,10 @@ class IterableTypeBodyPortion final
623636

624637
void beCurrent(IterableTypeScope *) const override;
625638
bool isCurrent(const IterableTypeScope *) const override;
639+
NullablePtr<ASTScopeImpl>
640+
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
641+
SourceRange
642+
sourceRangeForDeferredExpansion(const IterableTypeScope *) const override;
626643
};
627644

628645
/// GenericType or Extension scope
@@ -702,7 +719,6 @@ class IterableTypeScope : public GenericTypeScope {
702719
/// Because of \c parseDelayedDecl members can get added after the tree is
703720
/// constructed, and they can be out of order. Detect this happening by
704721
/// remembering the member count.
705-
/// TODO: unify with \c numberOfDeclsAlreadySeen
706722
unsigned memberCount = 0;
707723

708724
public:
@@ -721,6 +737,8 @@ class IterableTypeScope : public GenericTypeScope {
721737
public:
722738
void makeBodyCurrent();
723739
bool isBodyCurrent() const;
740+
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
741+
SourceRange sourceRangeForDeferredExpansion() const override;
724742
};
725743

726744
class NominalTypeScope final : public IterableTypeScope {
@@ -958,8 +976,7 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
958976
Decl *getDecl() const { return decl; }
959977
static bool isAMethod(const AbstractFunctionDecl *);
960978

961-
std::vector<ASTScopeImpl *> rescueScopesToReuse() override;
962-
void addReusedScopes(ArrayRef<ASTScopeImpl *>) override;
979+
NullablePtr<ASTScopeImpl> getParentOfRescuedScopes() override;
963980

964981
protected:
965982
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
@@ -1122,7 +1139,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
11221139
SourceRange
11231140
getChildlessSourceRange(bool omitAssertions = false) const override;
11241141

1125-
static bool isHandledSpecially(const ASTNode n);
11261142
NullablePtr<const void> getReferrent() const override;
11271143

11281144
protected:
@@ -1372,8 +1388,7 @@ class TopLevelCodeScope final : public ASTScopeImpl {
13721388
Decl *getDecl() const { return decl; }
13731389
NullablePtr<const void> getReferrent() const override;
13741390

1375-
std::vector<ASTScopeImpl *> rescueScopesToReuse() override;
1376-
void addReusedScopes(ArrayRef<ASTScopeImpl *>) override;
1391+
NullablePtr<ASTScopeImpl> getParentOfRescuedScopes() override;
13771392
};
13781393

13791394
/// The \c _@specialize attribute.

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

Lines changed: 16 additions & 30 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,37 +68,11 @@ 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;
62-
63-
/// Look for declarations associated with the given name.
64-
///
65-
/// \param name The name we're searching for.
66-
virtual void lookupValue(DeclName name, VisibleDeclConsumer &consumer) {}
67-
68-
/// Look up a type declaration by its Clang name.
69-
///
70-
/// Note that this method does no filtering. If it finds the type in a loaded
71-
/// module, it returns it. This is intended for use in reflection / debugging
72-
/// contexts where access is not a problem.
73-
virtual void lookupTypeDecl(StringRef clangName, Demangle::Node::Kind kind,
74-
llvm::function_ref<void(TypeDecl *)> receiver) {}
75-
76-
/// Look up type a declaration synthesized by the Clang importer itself, using
77-
/// a "related entity kind" to determine which type it should be. For example,
78-
/// this can be used to find the synthesized error struct for an
79-
/// NS_ERROR_ENUM.
80-
///
81-
/// Note that this method does no filtering. If it finds the type in a loaded
82-
/// module, it returns it. This is intended for use in reflection / debugging
83-
/// contexts where access is not a problem.
84-
virtual void
85-
lookupRelatedEntity(StringRef clangName, StringRef relatedEntityKind,
86-
llvm::function_ref<void(TypeDecl *)> receiver) {}
71+
virtual bool
72+
isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
73+
const DeclContext *importedDC) = 0;
8774
};
8875

8976
} // namespace swift
9077

9178
#endif // LLVM_SWIFT_AST_CLANG_MODULE_LOADER_H
92-

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,17 @@ class GenericContext : private _GenericContext, public DeclContext {
15231523

15241524
/// Determine whether this context has generic parameters
15251525
/// of its own.
1526+
///
1527+
/// \code
1528+
/// class C<T> {
1529+
/// func f1() {} // isGeneric == false
1530+
/// func f2<T>() {} // isGeneric == true
1531+
/// }
1532+
///
1533+
/// protocol P { // isGeneric == true due to implicit Self param
1534+
/// func p() // isGeneric == false
1535+
/// }
1536+
/// \endcode
15261537
bool isGeneric() const { return GenericParams != nullptr; }
15271538

15281539
/// Retrieve the trailing where clause for this extension, if any.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ERROR(lex_illegal_multiline_string_end,none,
163163
"multi-line string literal closing delimiter must begin on a new line", ())
164164
ERROR(lex_multiline_string_indent_inconsistent,none,
165165
"%select{unexpected space in|unexpected tab in|insufficient}2 indentation of "
166-
"%select{line|next %1 lines}0 in multi-line string literal",
166+
"%select{line|next %1 lines}0 in multi-line string literal",
167167
(bool, unsigned, unsigned))
168168
NOTE(lex_multiline_string_indent_should_match_here,none,
169169
"should match %select{space|tab}0 here", (unsigned))
@@ -252,7 +252,7 @@ ERROR(cskeyword_not_attribute,none,
252252
"'%0' is a declaration modifier, not an attribute", (StringRef))
253253

254254
ERROR(decl_already_static,none,
255-
"%0 specified twice", (StaticSpellingKind))
255+
"%0 cannot appear after another 'static' or 'class' keyword", (StaticSpellingKind))
256256

257257
ERROR(enum_case_dot_prefix,none,
258258
"extraneous '.' in enum 'case' declaration", ())
@@ -881,7 +881,7 @@ WARNING(parameter_extraneous_double_up,none,
881881
"extraneous duplicate parameter name; %0 already has an argument "
882882
"label", (Identifier))
883883
ERROR(parameter_operator_keyword_argument,none,
884-
"%select{operator|closure|enum case}0 cannot have keyword arguments",
884+
"%select{operator|closure|enum case}0 cannot have keyword arguments",
885885
(unsigned))
886886

887887
ERROR(parameter_unnamed,none,

branches/tensorflow/include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ namespace swift {
115115
/// Only used by lldb-moduleimport-test.
116116
bool EnableMemoryBufferImporter = false;
117117

118-
/// Enable the DWARFImporter. Only used by lldb-moduleimport-test.
119-
bool EnableDWARFImporter = false;
120-
121118
/// Allows using identifiers with a leading dollar.
122119
bool EnableDollarIdentifiers = false;
123120

@@ -271,6 +268,9 @@ namespace swift {
271268
/// whether it is. The warning is useful for testing.
272269
bool WarnIfASTScopeLookup = false;
273270

271+
/// Build the ASTScope tree lazily
272+
bool LazyASTScopes = false;
273+
274274
/// Whether to use the import as member inference system
275275
///
276276
/// When importing a global, try to infer whether we can import it as a

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,28 @@ class TypeDecl;
6060
class VisibleDeclConsumer;
6161
enum class SelectorSplitKind;
6262

63-
/// Represents the different namespaces for types in C.
63+
/// This interface is implemented by LLDB to serve as a fallback when Clang
64+
/// modules can't be imported from source in the debugger.
6465
///
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,
66+
/// During compile time, ClangImporter-imported Clang modules are compiled with
67+
/// -gmodules, which emits a DWARF rendition of all types defined in the module
68+
/// into the .pcm file. On Darwin, these types can be collected by
69+
/// dsymutil. This delegate allows DWARFImporter to ask LLDB to look up a Clang
70+
/// type by name, synthesize a Clang AST from it. DWARFImporter then hands this
71+
/// Clang AST to ClangImporter to import the type into Swift.
72+
class DWARFImporterDelegate {
73+
public:
74+
virtual ~DWARFImporterDelegate() {}
75+
/// Perform a qualified lookup of a Clang type with this name.
76+
/// \param kind Only return results with this type kind.
77+
virtual void lookupValue(StringRef name, llvm::Optional<ClangTypeKind> kind,
78+
SmallVectorImpl<clang::Decl *> &results) {}
7279
};
7380

7481
/// Class that imports Clang modules into Swift, mapping directly
7582
/// from Clang ASTs over to Swift ASTs.
7683
class ClangImporter final : public ClangModuleLoader {
7784
friend class ClangModuleUnit;
78-
friend class DWARFImporter;
7985

8086
public:
8187
class Implementation;
@@ -84,8 +90,11 @@ class ClangImporter final : public ClangModuleLoader {
8490
Implementation &Impl;
8591

8692
ClangImporter(ASTContext &ctx, const ClangImporterOptions &clangImporterOpts,
87-
DependencyTracker *tracker);
93+
DependencyTracker *tracker,
94+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate);
8895

96+
ModuleDecl *loadModuleClang(SourceLoc importLoc,
97+
ArrayRef<std::pair<Identifier, SourceLoc>> path);
8998
public:
9099
/// Create a new Clang importer that can import a suitable Clang
91100
/// module into the given ASTContext.
@@ -100,13 +109,15 @@ class ClangImporter final : public ClangModuleLoader {
100109
///
101110
/// \param tracker The object tracking files this compilation depends on.
102111
///
112+
/// \param dwarfImporterDelegate A helper object that can synthesize
113+
/// Clang Decls from debug info. Used by LLDB.
114+
///
103115
/// \returns a new Clang module importer, or null (with a diagnostic) if
104116
/// an error occurred.
105117
static std::unique_ptr<ClangImporter>
106-
create(ASTContext &ctx,
107-
const ClangImporterOptions &importerOpts,
108-
std::string swiftPCHHash = "",
109-
DependencyTracker *tracker = nullptr);
118+
create(ASTContext &ctx, const ClangImporterOptions &importerOpts,
119+
std::string swiftPCHHash = "", DependencyTracker *tracker = nullptr,
120+
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate = {});
110121

111122
ClangImporter(const ClangImporter &) = delete;
112123
ClangImporter(ClangImporter &&) = delete;
@@ -161,15 +172,15 @@ class ClangImporter final : public ClangModuleLoader {
161172
/// Look for declarations associated with the given name.
162173
///
163174
/// \param name The name we're searching for.
164-
void lookupValue(DeclName name, VisibleDeclConsumer &consumer) override;
175+
void lookupValue(DeclName name, VisibleDeclConsumer &consumer);
165176

166177
/// Look up a type declaration by its Clang name.
167178
///
168179
/// Note that this method does no filtering. If it finds the type in a loaded
169180
/// module, it returns it. This is intended for use in reflection / debugging
170181
/// contexts where access is not a problem.
171-
void lookupTypeDecl(StringRef clangName, Demangle::Node::Kind kind,
172-
llvm::function_ref<void(TypeDecl*)> receiver) override;
182+
void lookupTypeDecl(StringRef clangName, ClangTypeKind kind,
183+
llvm::function_ref<void(TypeDecl *)> receiver);
173184

174185
/// Look up type a declaration synthesized by the Clang importer itself, using
175186
/// a "related entity kind" to determine which type it should be. For example,
@@ -180,8 +191,9 @@ class ClangImporter final : public ClangModuleLoader {
180191
/// module, it returns it. This is intended for use in reflection / debugging
181192
/// contexts where access is not a problem.
182193
void
183-
lookupRelatedEntity(StringRef clangName, StringRef relatedEntityKind,
184-
llvm::function_ref<void(TypeDecl *)> receiver) override;
194+
lookupRelatedEntity(StringRef clangName, ClangTypeKind kind,
195+
StringRef relatedEntityKind,
196+
llvm::function_ref<void(TypeDecl *)> receiver);
185197

186198
/// Look for textually included declarations from the bridging header.
187199
///

0 commit comments

Comments
 (0)