Skip to content

Commit c9f2060

Browse files
committed
ASTScope: Remove shouldThisNodeBeScopedWhenFoundInSourceFileBraceStmtOrType()
1 parent 753d303 commit c9f2060

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,13 @@ class ScopeCreator final {
229229
ArrayRef<ASTNode> nodesOrDeclsToAdd) {
230230
auto *ip = insertionPoint;
231231
for (auto nd : sortBySourceRange(cull(nodesOrDeclsToAdd))) {
232-
if (!shouldThisNodeBeScopedWhenFoundInSourceFileBraceStmtOrType(nd)) {
233-
// FIXME: Could the range get lost if the node is ever reexpanded?
234-
ip->widenSourceRangeForIgnoredASTNode(nd);
235-
} else {
236-
const unsigned preCount = ip->getChildren().size();
237-
auto *const newIP =
238-
addToScopeTreeAndReturnInsertionPoint(nd, ip).getPtrOr(ip);
239-
if (ip != organicInsertionPoint)
240-
ip->increaseASTAncestorScopeCount(ip->getChildren().size() -
241-
preCount);
242-
ip = newIP;
243-
}
232+
const unsigned preCount = ip->getChildren().size();
233+
auto *const newIP =
234+
addToScopeTreeAndReturnInsertionPoint(nd, ip).getPtrOr(ip);
235+
if (ip != organicInsertionPoint)
236+
ip->increaseASTAncestorScopeCount(ip->getChildren().size() -
237+
preCount);
238+
ip = newIP;
244239
}
245240
return ip;
246241
}
@@ -537,32 +532,6 @@ class ScopeCreator final {
537532
return -1 == signum;
538533
}
539534

540-
static bool isVarDeclInPatternBindingDecl(ASTNode n1, ASTNode n2) {
541-
if (auto *d1 = n1.dyn_cast<Decl *>())
542-
if (auto *vd = dyn_cast<VarDecl>(d1))
543-
if (auto *d2 = n2.dyn_cast<Decl *>())
544-
if (auto *pbd = dyn_cast<PatternBindingDecl>(d2))
545-
return vd->getParentPatternBinding() == pbd;
546-
return false;
547-
}
548-
549-
public:
550-
bool shouldThisNodeBeScopedWhenFoundInSourceFileBraceStmtOrType(ASTNode n) {
551-
// Do not scope VarDecls because
552-
// they get created directly by the pattern code.
553-
// Doing otherwise distorts the source range
554-
// of their parents.
555-
ASTScopeAssert(!n.isDecl(DeclKind::Accessor),
556-
"Should not see accessors here");
557-
// Can occur in illegal code
558-
// non-empty brace stmt could define a new insertion point
559-
if (auto *const s = n.dyn_cast<Stmt *>()) {
560-
if (auto *const bs = dyn_cast<BraceStmt>(s))
561-
return !bs->empty();
562-
}
563-
return !n.isDecl(DeclKind::Var);
564-
}
565-
566535
public:
567536
/// For debugging. Return true if scope tree contains all the decl contexts in
568537
/// the AST May modify the scope tree in order to update obsolete scopes.

0 commit comments

Comments
 (0)