@@ -1695,7 +1695,7 @@ class PlaceholderExpansionScanner {
1695
1695
std::pair<ArgumentList *, bool > enclosingCallExprArg (SourceFile &SF,
1696
1696
SourceLoc SL) {
1697
1697
1698
- class CallExprFinder : public SourceEntityWalker {
1698
+ class CallExprFinder : public ASTWalker {
1699
1699
public:
1700
1700
const SourceManager &SM;
1701
1701
SourceLoc TargetLoc;
@@ -1719,7 +1719,11 @@ class PlaceholderExpansionScanner {
1719
1719
return true ;
1720
1720
}
1721
1721
1722
- bool walkToExprPre (Expr *E) override {
1722
+ MacroWalking getMacroWalkingBehavior () const override {
1723
+ return MacroWalking::Arguments;
1724
+ }
1725
+
1726
+ PreWalkResult<Expr *> walkToExprPre (Expr *E) override {
1723
1727
auto SR = E->getSourceRange ();
1724
1728
if (SR.isValid () && SM.rangeContainsTokenLoc (SR, TargetLoc) &&
1725
1729
!checkCallExpr (E) && !EnclosingCallAndArg.first ) {
@@ -1732,13 +1736,13 @@ class PlaceholderExpansionScanner {
1732
1736
OuterExpr = E;
1733
1737
}
1734
1738
}
1735
- return true ;
1739
+ return Action::Continue (E) ;
1736
1740
}
1737
1741
1738
- bool walkToExprPost (Expr *E) override {
1742
+ PostWalkResult<Expr *> walkToExprPost (Expr *E) override {
1739
1743
if (E->getStartLoc () == TargetLoc)
1740
- return false ; // found what we needed to find, stop walking.
1741
- return true ;
1744
+ return Action::Stop () ; // found what we needed to find, stop walking.
1745
+ return Action::Continue (E) ;
1742
1746
}
1743
1747
1744
1748
// / Whether this statement body consists of only an implicit "return",
@@ -1756,7 +1760,7 @@ class PlaceholderExpansionScanner {
1756
1760
1757
1761
// Before pre-checking, the implicit return will not have been
1758
1762
// inserted. Look for a single expression body in a closure.
1759
- if (auto *ParentE = getWalker (). Parent .getAsExpr ()) {
1763
+ if (auto *ParentE = Parent.getAsExpr ()) {
1760
1764
if (isa<ClosureExpr>(ParentE)) {
1761
1765
if (auto *innerE = BS->getSingleActiveExpression ())
1762
1766
return innerE->getStartLoc () == TargetLoc;
@@ -1767,7 +1771,7 @@ class PlaceholderExpansionScanner {
1767
1771
return false ;
1768
1772
}
1769
1773
1770
- bool walkToStmtPre (Stmt *S) override {
1774
+ PreWalkResult<Stmt *> walkToStmtPre (Stmt *S) override {
1771
1775
auto SR = S->getSourceRange ();
1772
1776
if (SR.isValid () && SM.rangeContainsTokenLoc (SR, TargetLoc) &&
1773
1777
!isImplicitReturnBody (S)) {
@@ -1791,17 +1795,29 @@ class PlaceholderExpansionScanner {
1791
1795
break ;
1792
1796
}
1793
1797
}
1794
- return true ;
1798
+ return Action::Continue (S) ;
1795
1799
}
1796
1800
1797
- bool shouldWalkInactiveConfigRegion () override { return true ; }
1801
+ PreWalkAction walkToDeclPre (Decl *D) override {
1802
+ if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
1803
+ for (auto Clause : ICD->getClauses ()) {
1804
+ // Active clase elements are visited normally.
1805
+ if (Clause.isActive )
1806
+ continue ;
1807
+ for (auto Member : Clause.Elements )
1808
+ Member.walk (*this );
1809
+ }
1810
+ return Action::SkipNode ();
1811
+ }
1812
+ return Action::Continue ();
1813
+ }
1798
1814
1799
1815
ArgumentList *findEnclosingCallArg (SourceFile &SF, SourceLoc SL) {
1800
1816
EnclosingCallAndArg = {nullptr , nullptr };
1801
1817
OuterExpr = nullptr ;
1802
1818
OuterStmt = nullptr ;
1803
1819
TargetLoc = SL;
1804
- walk (SF );
1820
+ SF. walk (* this );
1805
1821
return EnclosingCallAndArg.second ;
1806
1822
}
1807
1823
};
0 commit comments