Skip to content

Commit c9826b7

Browse files
committed
---
yaml --- r: 326318 b: refs/heads/master-next c: a42bdf4 h: refs/heads/master
1 parent 3ccdd26 commit c9826b7

File tree

357 files changed

+2496
-3202
lines changed

Some content is hidden

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

357 files changed

+2496
-3202
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e052da7d8886fa0439677852e8f7830b20c2e1da
3-
refs/heads/master-next: a7b4da64479e2653c10918120a239e80433fd471
3+
refs/heads/master-next: a42bdf4c20eafaaceb65206b984f3497edac7ef5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/cmake/modules/SwiftXcodeSupport.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ macro(swift_common_xcode_cxx_config)
100100
# Force usage of Clang.
101101
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0"
102102
CACHE STRING "Xcode Compiler")
103-
# Use C++'14.
104-
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14"
103+
# Use C++'11.
104+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11"
105105
CACHE STRING "Xcode C++ Language Standard")
106106
# Use libc++.
107107
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++"

branches/master-next/include/swift/AST/ASTNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ namespace swift {
3636
enum class DeclKind : uint8_t;
3737
enum class StmtKind;
3838

39-
struct ASTNode : public llvm::PointerUnion<Expr*, Stmt*, Decl*> {
39+
struct ASTNode : public llvm::PointerUnion3<Expr*, Stmt*, Decl*> {
4040
// Inherit the constructors from PointerUnion.
41-
using PointerUnion::PointerUnion;
42-
41+
using PointerUnion3::PointerUnion3;
42+
4343
SourceRange getSourceRange() const;
4444

4545
/// Return the location of the start of the statement.

branches/master-next/include/swift/AST/ASTScope.h

Lines changed: 28 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@
3838
#include "llvm/ADT/STLExtras.h"
3939
#include "llvm/ADT/SmallVector.h"
4040

41-
/// In case there's a bug in the ASTScope lookup system, suggest that the user
42-
/// try disabling it.
43-
/// \p message must be a string literal
44-
#define ASTScopeAssert(predicate, message) \
45-
assert((predicate) && message \
46-
" Try compiling with '-disable-astscope-lookup'.")
47-
48-
#define ASTScope_unreachable(message) \
49-
llvm_unreachable(message " Try compiling with '-disable-astscope-lookup'.")
50-
5141
namespace swift {
5242

5343
#pragma mark Forward-references
@@ -135,10 +125,10 @@ class ASTScopeImpl {
135125
/// Must clear source range change whenever this changes
136126
Children storedChildren;
137127

138-
bool wasExpanded = false;
139-
140-
/// For use-before-def, ASTAncestor scopes may be added to a BraceStmt.
141-
unsigned astAncestorScopeCount = 0;
128+
/// Because expansion returns an insertion point,
129+
/// if a scope is reexpanded, the children added NOT by expansion must be
130+
/// rescued and reused.
131+
unsigned childrenCountWhenLastExpanded = 0;
142132

143133
/// Can clear storedChildren, so must remember this
144134
bool haveAddedCleanup = false;
@@ -172,7 +162,7 @@ class ASTScopeImpl {
172162
void *operator new(size_t bytes, const ASTContext &ctx,
173163
unsigned alignment = alignof(ASTScopeImpl));
174164
void *operator new(size_t Bytes, void *Mem) {
175-
ASTScopeAssert(Mem, "Allocation failed");
165+
assert(Mem);
176166
return Mem;
177167
}
178168

@@ -190,13 +180,12 @@ class ASTScopeImpl {
190180

191181
public: // for addReusedBodyScopes
192182
void addChild(ASTScopeImpl *child, ASTContext &);
193-
std::vector<ASTScopeImpl *> rescueASTAncestorScopesForReuseFromMe();
183+
std::vector<ASTScopeImpl *> rescueYoungestChildren(unsigned count);
194184

195185
/// When reexpanding, do we always create a new body?
196-
virtual NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued();
197-
std::vector<ASTScopeImpl *>
198-
rescueASTAncestorScopesForReuseFromMeOrDescendants();
199-
void replaceASTAncestorScopes(ArrayRef<ASTScopeImpl *>);
186+
virtual NullablePtr<ASTScopeImpl> getParentOfRescuedScopes();
187+
std::vector<ASTScopeImpl *> rescueScopesToReuse();
188+
void addReusedScopes(ArrayRef<ASTScopeImpl *>);
200189

201190
private:
202191
void removeChildren();
@@ -207,8 +196,6 @@ class ASTScopeImpl {
207196

208197
public:
209198
void preOrderDo(function_ref<void(ASTScopeImpl *)>);
210-
/// Like preorderDo but without myself.
211-
void preOrderChildrenDo(function_ref<void(ASTScopeImpl *)>);
212199
void postOrderDo(function_ref<void(ASTScopeImpl *)>);
213200

214201
#pragma mark - source ranges
@@ -232,12 +219,6 @@ class ASTScopeImpl {
232219
bool doesRangeMatch(unsigned start, unsigned end, StringRef file = "",
233220
StringRef className = "");
234221

235-
unsigned countDescendants() const;
236-
237-
/// Make sure that when the argument is executed, there are as many
238-
/// descendants after as before.
239-
void assertThatTreeDoesNotShrink(function_ref<void()>);
240-
241222
private:
242223
SourceRange computeSourceRangeOfScope(bool omitAssertions = false) const;
243224
SourceRange
@@ -272,8 +253,6 @@ class ASTScopeImpl {
272253
void ensureSourceRangesAreCorrectWhenAddingDescendants(function_ref<void()>);
273254

274255
public: // public for debugging
275-
/// Returns source range of this node alone, without factoring in any
276-
/// children.
277256
virtual SourceRange
278257
getSourceRangeOfThisASTNode(bool omitAssertions = false) const = 0;
279258

@@ -335,17 +314,10 @@ class ASTScopeImpl {
335314
/// Return the scope into which to place subsequent decls
336315
ASTScopeImpl *expandAndBeCurrent(ScopeCreator &);
337316

338-
unsigned getASTAncestorScopeCount() const { return astAncestorScopeCount; }
339-
bool getWasExpanded() const { return wasExpanded; }
340-
341317
protected:
342-
void resetASTAncestorScopeCount() { astAncestorScopeCount = 0; }
343-
void increaseASTAncestorScopeCount(unsigned c) { astAncestorScopeCount += c; }
344-
void setWasExpanded() { wasExpanded = true; }
345318
virtual ASTScopeImpl *expandSpecifically(ScopeCreator &) = 0;
346319
virtual void beCurrent();
347-
bool isCurrent() const;
348-
virtual bool isCurrentIfWasExpanded() const;
320+
virtual bool isCurrent() const;
349321

350322
private:
351323
/// Compare the pre-expasion range with the post-expansion range and return
@@ -356,8 +328,6 @@ class ASTScopeImpl {
356328
/// Some scopes can be expanded lazily.
357329
/// Such scopes must: not change their source ranges after expansion, and
358330
/// their expansion must return an insertion point outside themselves.
359-
/// After a node is expanded, its source range (getSourceRangeofThisASTNode
360-
/// union children's ranges) must be same as this.
361331
virtual NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion();
362332
virtual SourceRange sourceRangeForDeferredExpansion() const;
363333

@@ -386,6 +356,9 @@ class ASTScopeImpl {
386356

387357
virtual ScopeCreator &getScopeCreator();
388358

359+
protected:
360+
void setChildrenCountWhenLastExpanded();
361+
389362
#pragma mark - - creation queries
390363
public:
391364
virtual bool isThisAnAbstractStorageDecl() const { return false; }
@@ -533,7 +506,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
533506
/// The number of \c Decls in the \c SourceFile that were already seen.
534507
/// Since parsing can be interleaved with type-checking, on every
535508
/// lookup, look at creating scopes for any \c Decls beyond this number.
536-
/// rdar://55562483 Unify with numberOfChildrenWhenLastExpanded
537509
int numberOfDeclsAlreadySeen = 0;
538510

539511
ASTSourceFileScope(SourceFile *SF, ScopeCreator *scopeCreator);
@@ -549,9 +521,7 @@ class ASTSourceFileScope final : public ASTScopeImpl {
549521
NullablePtr<DeclContext> getDeclContext() const override;
550522

551523
void addNewDeclsToScopeTree();
552-
void buildFullyExpandedTree();
553-
void
554-
buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals();
524+
void buildScopeTreeEagerly();
555525

556526
const SourceFile *getSourceFile() const override;
557527
NullablePtr<const void> addressForPrinting() const override { return SF; }
@@ -582,7 +552,7 @@ class Portion {
582552
void *operator new(size_t bytes, const ASTContext &ctx,
583553
unsigned alignment = alignof(ASTScopeImpl));
584554
void *operator new(size_t Bytes, void *Mem) {
585-
ASTScopeAssert(Mem, "Allocation failed");
555+
assert(Mem);
586556
return Mem;
587557
}
588558

@@ -605,12 +575,12 @@ class Portion {
605575
virtual const Decl *
606576
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const;
607577

608-
virtual void beCurrent(IterableTypeScope *) const = 0;
609-
virtual bool isCurrentIfWasExpanded(const IterableTypeScope *) const = 0;
578+
virtual void beCurrent(IterableTypeScope *) const;
579+
virtual bool isCurrent(const IterableTypeScope *) const;
610580
virtual NullablePtr<ASTScopeImpl>
611-
insertionPointForDeferredExpansion(IterableTypeScope *) const = 0;
581+
insertionPointForDeferredExpansion(IterableTypeScope *) const;
612582
virtual SourceRange
613-
sourceRangeForDeferredExpansion(const IterableTypeScope *) const = 0;
583+
sourceRangeForDeferredExpansion(const IterableTypeScope *) const;
614584
};
615585

616586
// For the whole Decl scope of a GenericType or an Extension
@@ -631,24 +601,6 @@ class Portion {
631601

632602
const Decl *
633603
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const override;
634-
635-
/// Make whole portion lazy to avoid circularity in lookup of generic
636-
/// parameters of extensions. When \c bindExtension is called, it needs to
637-
/// unqualifed-lookup the type being extended. That causes an \c
638-
/// ExtensionScope
639-
/// (\c GenericTypeOrExtensionWholePortion) to be built.
640-
/// The building process needs the generic parameters, but that results in a
641-
/// request for the extended nominal type of the \c ExtensionDecl, which is
642-
/// an endless recursion. Although we only need to make \c ExtensionScope
643-
/// lazy, might as well do it for all \c IterableTypeScopes.
644-
645-
void beCurrent(IterableTypeScope *) const override;
646-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
647-
648-
NullablePtr<ASTScopeImpl>
649-
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
650-
SourceRange
651-
sourceRangeForDeferredExpansion(const IterableTypeScope *) const override;
652604
};
653605

654606
/// GenericTypeOrExtension = GenericType or Extension
@@ -687,14 +639,6 @@ class GenericTypeOrExtensionWherePortion final
687639

688640
SourceRange getChildlessSourceRangeOf(const GenericTypeOrExtensionScope *,
689641
bool omitAssertions) const override;
690-
691-
void beCurrent(IterableTypeScope *) const override;
692-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
693-
694-
NullablePtr<ASTScopeImpl>
695-
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
696-
SourceRange
697-
sourceRangeForDeferredExpansion(const IterableTypeScope *) const override;
698642
};
699643

700644
/// Behavior specific to representing the Body of a NominalTypeDecl or
@@ -711,7 +655,7 @@ class IterableTypeBodyPortion final
711655
bool omitAssertions) const override;
712656

713657
void beCurrent(IterableTypeScope *) const override;
714-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
658+
bool isCurrent(const IterableTypeScope *) const override;
715659
NullablePtr<ASTScopeImpl>
716660
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
717661
SourceRange
@@ -750,17 +694,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
750694
SourceRange
751695
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
752696

753-
/// \c tryBindExtension needs to get the extended nominal, and the DeclContext
754-
/// is the parent of the \c ExtensionDecl. If the \c SourceRange of an \c
755-
/// ExtensionScope were to start where the \c ExtensionDecl says, the lookup
756-
/// source locaiton would fall within the \c ExtensionScope. This inclusion
757-
/// would cause the lazy \c ExtensionScope to be expanded which would ask for
758-
/// its generic parameters in order to create those sub-scopes. That request
759-
/// would cause a cycle because it would ask for the extended nominal. So,
760-
/// move the source range of an \c ExtensionScope *past* the extended nominal
761-
/// type, which is not in-scope there anyway.
762-
virtual SourceRange moveStartPastExtendedNominal(SourceRange) const = 0;
763-
764697
virtual GenericContext *getGenericContext() const = 0;
765698
std::string getClassName() const override;
766699
virtual std::string declKindName() const = 0;
@@ -799,8 +732,6 @@ class GenericTypeScope : public GenericTypeOrExtensionScope {
799732
public:
800733
GenericTypeScope(const Portion *p) : GenericTypeOrExtensionScope(p) {}
801734
virtual ~GenericTypeScope() {}
802-
SourceRange moveStartPastExtendedNominal(SourceRange) const override;
803-
804735
protected:
805736
NullablePtr<const GenericParamList> genericParams() const override;
806737
};
@@ -822,11 +753,9 @@ class IterableTypeScope : public GenericTypeScope {
822753

823754
protected:
824755
void beCurrent() override;
825-
bool isCurrentIfWasExpanded() const override;
756+
bool isCurrent() const override;
826757

827758
public:
828-
void makeWholeCurrent();
829-
bool isWholeCurrent() const;
830759
void makeBodyCurrent();
831760
bool isBodyCurrent() const;
832761
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
@@ -875,7 +804,6 @@ class ExtensionScope final : public IterableTypeScope {
875804
NullablePtr<NominalTypeDecl> getCorrespondingNominalTypeDecl() const override;
876805
std::string declKindName() const override { return "Extension"; }
877806
SourceRange getBraces() const override;
878-
SourceRange moveStartPastExtendedNominal(SourceRange) const override;
879807
ASTScopeImpl *createTrailingWhereClauseScope(ASTScopeImpl *parent,
880808
ScopeCreator &) override;
881809
void createBodyScope(ASTScopeImpl *leaf, ScopeCreator &) override;
@@ -1056,7 +984,7 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1056984
protected:
1057985
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
1058986
void beCurrent() override;
1059-
bool isCurrentIfWasExpanded() const override;
987+
bool isCurrent() const override;
1060988

1061989
private:
1062990
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
@@ -1072,7 +1000,7 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
10721000
Decl *getDecl() const { return decl; }
10731001
static bool isAMethod(const AbstractFunctionDecl *);
10741002

1075-
NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued() override;
1003+
NullablePtr<ASTScopeImpl> getParentOfRescuedScopes() override;
10761004

10771005
protected:
10781006
bool lookupLocalsOrMembers(ArrayRef<const ASTScopeImpl *>,
@@ -1148,14 +1076,11 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
11481076
/// false positives, that that doesn't hurt anything. However, the result of
11491077
/// the conservative source range computation doesn't seem to be stable. So
11501078
/// keep the original here, and use it for source range queries.
1151-
/// rdar://55263708
1152-
11531079
const SourceRange sourceRangeWhenCreated;
11541080

11551081
AttachedPropertyWrapperScope(VarDecl *e)
11561082
: decl(e), sourceRangeWhenCreated(getSourceRangeOfVarDecl(e)) {
1157-
ASTScopeAssert(sourceRangeWhenCreated.isValid(),
1158-
"VarDecls must have ranges to be looked-up");
1083+
assert(sourceRangeWhenCreated.isValid());
11591084
}
11601085
virtual ~AttachedPropertyWrapperScope() {}
11611086

@@ -1232,7 +1157,7 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
12321157
protected:
12331158
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
12341159
void beCurrent() override;
1235-
bool isCurrentIfWasExpanded() const override;
1160+
bool isCurrent() const override;
12361161

12371162
private:
12381163
AnnotatedInsertionPoint
@@ -1406,7 +1331,7 @@ class WholeClosureScope final : public AbstractClosureScope {
14061331
protected:
14071332
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
14081333
void beCurrent() override;
1409-
bool isCurrentIfWasExpanded() const override;
1334+
bool isCurrent() const override;
14101335

14111336
private:
14121337
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
@@ -1477,7 +1402,7 @@ class TopLevelCodeScope final : public ASTScopeImpl {
14771402
protected:
14781403
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
14791404
void beCurrent() override;
1480-
bool isCurrentIfWasExpanded() const override;
1405+
bool isCurrent() const override;
14811406

14821407
private:
14831408
AnnotatedInsertionPoint
@@ -1495,7 +1420,7 @@ class TopLevelCodeScope final : public ASTScopeImpl {
14951420
Decl *getDecl() const { return decl; }
14961421
NullablePtr<const void> getReferrent() const override;
14971422

1498-
NullablePtr<ASTScopeImpl> getParentOfASTAncestorScopesToBeRescued() override;
1423+
NullablePtr<ASTScopeImpl> getParentOfRescuedScopes() override;
14991424
};
15001425

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

branches/master-next/include/swift/AST/Builtins.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ class IntrinsicInfo {
131131

132132
/// Turn a string like "release" into the LLVM enum.
133133
llvm::AtomicOrdering decodeLLVMAtomicOrdering(StringRef O);
134-
135-
/// Returns true if the builtin with ID \p ID has a defined static overload for
136-
/// the type \p Ty.
137-
bool canBuiltinBeOverloadedForType(BuiltinValueKind ID, Type Ty);
134+
138135
}
139136

140137
#endif

0 commit comments

Comments
 (0)