Skip to content

Commit 0c11fad

Browse files
committed
ASTScope: Don't silently drop duplicate AST nodes
Instead, let's rely on the existing source range assertions. They will fire if we add two nodes with overlapping or equal source ranges.
1 parent 5e892b3 commit 0c11fad

File tree

2 files changed

+84
-253
lines changed

2 files changed

+84
-253
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ class ASTScopeImpl {
224224
virtual NullablePtr<DeclAttribute> getDeclAttributeIfAny() const {
225225
return nullptr;
226226
}
227-
virtual NullablePtr<const void> getReferrent() const { return nullptr; }
228227

229228
#pragma mark - debugging and printing
230229

@@ -470,9 +469,6 @@ class Portion {
470469
virtual NullablePtr<const ASTScopeImpl>
471470
getLookupLimitFor(const GenericTypeOrExtensionScope *) const;
472471

473-
virtual const Decl *
474-
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const;
475-
476472
virtual NullablePtr<ASTScopeImpl>
477473
insertionPointForDeferredExpansion(IterableTypeScope *) const = 0;
478474
};
@@ -493,9 +489,6 @@ class Portion {
493489
NullablePtr<const ASTScopeImpl>
494490
getLookupLimitFor(const GenericTypeOrExtensionScope *) const override;
495491

496-
const Decl *
497-
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const override;
498-
499492
NullablePtr<ASTScopeImpl>
500493
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
501494
};
@@ -570,7 +563,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
570563

571564
virtual Decl *getDecl() const = 0;
572565
NullablePtr<Decl> getDeclIfAny() const override { return getDecl(); }
573-
NullablePtr<const void> getReferrent() const override;
574566

575567
private:
576568
AnnotatedInsertionPoint
@@ -745,7 +737,6 @@ class GenericParamScope final : public ASTScopeImpl {
745737

746738
/// Actually holder is always a GenericContext, need to test if
747739
/// ProtocolDecl or SubscriptDecl but will refactor later.
748-
NullablePtr<const void> getReferrent() const override;
749740
std::string getClassName() const override;
750741
SourceRange
751742
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
@@ -788,8 +779,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
788779
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
789780
Decl *getDecl() const { return decl; }
790781

791-
NullablePtr<const void> getReferrent() const override;
792-
793782
protected:
794783
NullablePtr<const GenericParamList> genericParams() const override;
795784
};
@@ -902,7 +891,6 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
902891
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
903892
return attr;
904893
}
905-
NullablePtr<const void> getReferrent() const override;
906894

907895
private:
908896
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
@@ -970,8 +958,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
970958
SourceRange
971959
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
972960

973-
NullablePtr<const void> getReferrent() const override;
974-
975961
protected:
976962
bool lookupLocalsOrMembers(DeclConsumer) const override;
977963
bool isLabeledStmtLookupTerminator() const override;
@@ -1072,7 +1058,6 @@ class CaptureListScope final : public ASTScopeImpl {
10721058
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
10731059
NullablePtr<Expr> getExprIfAny() const override { return expr; }
10741060
Expr *getExpr() const { return expr; }
1075-
NullablePtr<const void> getReferrent() const override;
10761061
bool lookupLocalsOrMembers(DeclConsumer) const override;
10771062
};
10781063

@@ -1094,7 +1079,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
10941079
}
10951080
NullablePtr<Expr> getExprIfAny() const override { return closureExpr; }
10961081
Expr *getExpr() const { return closureExpr; }
1097-
NullablePtr<const void> getReferrent() const override;
10981082

10991083
protected:
11001084
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
@@ -1128,7 +1112,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
11281112
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
11291113
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
11301114
Decl *getDecl() const { return decl; }
1131-
NullablePtr<const void> getReferrent() const override;
11321115
};
11331116

11341117
/// The \c _@specialize attribute.
@@ -1153,7 +1136,6 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
11531136
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
11541137
return specializeAttr;
11551138
}
1156-
NullablePtr<const void> getReferrent() const override;
11571139

11581140
protected:
11591141
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
@@ -1183,7 +1165,6 @@ class DifferentiableAttributeScope final : public ASTScopeImpl {
11831165
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
11841166
return differentiableAttr;
11851167
}
1186-
NullablePtr<const void> getReferrent() const override;
11871168

11881169
protected:
11891170
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
@@ -1214,7 +1195,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
12141195
public:
12151196
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
12161197
Decl *getDecl() const { return decl; }
1217-
NullablePtr<const void> getReferrent() const override;
12181198

12191199
protected:
12201200
NullablePtr<const GenericParamList> genericParams() const override;
@@ -1244,7 +1224,6 @@ class AbstractStmtScope : public ASTScopeImpl {
12441224
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
12451225
virtual Stmt *getStmt() const = 0;
12461226
NullablePtr<Stmt> getStmtIfAny() const override { return getStmt(); }
1247-
NullablePtr<const void> getReferrent() const override;
12481227

12491228
protected:
12501229
bool isLabeledStmtLookupTerminator() const override;

0 commit comments

Comments
 (0)