@@ -228,8 +228,7 @@ class ScopeCreator final {
228
228
ASTScopeImpl *const organicInsertionPoint,
229
229
ArrayRef<ASTNode> nodesOrDeclsToAdd) {
230
230
auto *ip = insertionPoint;
231
- for (auto nd : expandIfConfigClausesThenCullAndSortElementsOrMembers (
232
- nodesOrDeclsToAdd)) {
231
+ for (auto nd : sortBySourceRange (cull (nodesOrDeclsToAdd))) {
233
232
if (!shouldThisNodeBeScopedWhenFoundInSourceFileBraceStmtOrType (nd)) {
234
233
// FIXME: Could the range get lost if the node is ever reexpanded?
235
234
ip->widenSourceRangeForIgnoredASTNode (nd);
@@ -494,48 +493,9 @@ class ScopeCreator final {
494
493
fn (diffAttr);
495
494
}
496
495
497
- std::vector<ASTNode> expandIfConfigClausesThenCullAndSortElementsOrMembers (
498
- ArrayRef<ASTNode> input) const {
499
- auto cleanedupNodes = sortBySourceRange (cull (expandIfConfigClauses (input)));
500
- return cleanedupNodes;
501
- }
502
-
503
496
public:
504
497
505
498
private:
506
- static std::vector<ASTNode> expandIfConfigClauses (ArrayRef<ASTNode> input) {
507
- std::vector<ASTNode> expansion;
508
- expandIfConfigClausesInto (expansion, input, /* isInAnActiveNode=*/ true );
509
- return expansion;
510
- }
511
-
512
- static void expandIfConfigClausesInto (std::vector<ASTNode> &expansion,
513
- ArrayRef<ASTNode> input,
514
- const bool isInAnActiveNode) {
515
- for (auto n : input) {
516
- if (!n.isDecl (DeclKind::IfConfig)) {
517
- expansion.push_back (n);
518
- continue ;
519
- }
520
- auto *const icd = cast<IfConfigDecl>(n.get <Decl *>());
521
- for (auto &clause : icd->getClauses ()) {
522
- if (auto *const cond = clause.Cond )
523
- expansion.push_back (cond);
524
- if (clause.isActive ) {
525
- // TODO: Move this check into ASTVerifier
526
- ASTScopeAssert (isInAnActiveNode, " Clause should not be marked active "
527
- " unless it's context is active" );
528
- // get inactive nodes that nest in active clauses
529
- for (auto n : clause.Elements ) {
530
- if (auto *const d = n.dyn_cast <Decl *>())
531
- if (isa<IfConfigDecl>(d))
532
- expandIfConfigClausesInto (expansion, {d}, true );
533
- }
534
- }
535
- }
536
- }
537
- }
538
-
539
499
// / Remove VarDecls because we'll find them when we expand the
540
500
// / PatternBindingDecls. Remove EnunCases
541
501
// / because they overlap EnumElements and AST includes the elements in the
@@ -548,8 +508,10 @@ class ScopeCreator final {
548
508
ASTScopeAssert (
549
509
!n.isDecl (DeclKind::Accessor),
550
510
" Should not find accessors in iterable types or brace statements" );
551
- return isLocalizable (n) && !n.isDecl (DeclKind::Var) &&
552
- !n.isDecl (DeclKind::EnumCase);
511
+ return isLocalizable (n) &&
512
+ !n.isDecl (DeclKind::Var) &&
513
+ !n.isDecl (DeclKind::EnumCase) &&
514
+ !n.isDecl (DeclKind::IfConfig);
553
515
});
554
516
return culled;
555
517
}
0 commit comments