|
28 | 28 | #include <deque> |
29 | 29 | #include <memory> |
30 | 30 | #include <set> |
31 | | -#include <vector> |
32 | 31 |
|
33 | 32 | namespace clang { |
34 | 33 | namespace ast_matchers { |
@@ -423,7 +422,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, |
423 | 422 | public ASTMatchFinder { |
424 | 423 | public: |
425 | 424 | MatchASTVisitor(const MatchFinder::MatchersByType *Matchers, |
426 | | - const MatchFinderOptions &Options) |
| 425 | + const MatchFinder::MatchFinderOptions &Options) |
427 | 426 | : Matchers(Matchers), Options(Options), ActiveASTContext(nullptr) {} |
428 | 427 |
|
429 | 428 | ~MatchASTVisitor() override { |
@@ -1351,7 +1350,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, |
1351 | 1350 | /// We precalculate a list of matchers that pass the toplevel restrict check. |
1352 | 1351 | llvm::DenseMap<ASTNodeKind, std::vector<unsigned short>> MatcherFiltersMap; |
1353 | 1352 |
|
1354 | | - const MatchFinderOptions &Options; |
| 1353 | + const MatchFinder::MatchFinderOptions &Options; |
1355 | 1354 | ASTContext *ActiveASTContext; |
1356 | 1355 |
|
1357 | 1356 | // Maps a canonical type to its TypedefDecls. |
@@ -1574,41 +1573,19 @@ bool MatchASTVisitor::TraverseAttr(Attr *AttrNode) { |
1574 | 1573 | class MatchASTConsumer : public ASTConsumer { |
1575 | 1574 | public: |
1576 | 1575 | MatchASTConsumer(MatchFinder *Finder, |
1577 | | - MatchFinder::ParsingDoneTestCallback *ParsingDone, |
1578 | | - const MatchFinderOptions &Options) |
1579 | | - : Finder(Finder), ParsingDone(ParsingDone), Options(Options) {} |
| 1576 | + MatchFinder::ParsingDoneTestCallback *ParsingDone) |
| 1577 | + : Finder(Finder), ParsingDone(ParsingDone) {} |
1580 | 1578 |
|
1581 | 1579 | private: |
1582 | | - bool HandleTopLevelDecl(DeclGroupRef DG) override { |
1583 | | - if (Options.SkipSystemHeaders) { |
1584 | | - for (Decl *D : DG) { |
1585 | | - if (!isInSystemHeader(D)) |
1586 | | - TraversalScope.push_back(D); |
1587 | | - } |
1588 | | - } |
1589 | | - return true; |
1590 | | - } |
1591 | | - |
1592 | 1580 | void HandleTranslationUnit(ASTContext &Context) override { |
1593 | | - if (!TraversalScope.empty()) |
1594 | | - Context.setTraversalScope(TraversalScope); |
1595 | | - |
1596 | 1581 | if (ParsingDone != nullptr) { |
1597 | 1582 | ParsingDone->run(); |
1598 | 1583 | } |
1599 | 1584 | Finder->matchAST(Context); |
1600 | 1585 | } |
1601 | 1586 |
|
1602 | | - bool isInSystemHeader(Decl *D) { |
1603 | | - const SourceManager &SM = D->getASTContext().getSourceManager(); |
1604 | | - const SourceLocation Loc = SM.getExpansionLoc(D->getBeginLoc()); |
1605 | | - return SM.isInSystemHeader(Loc); |
1606 | | - } |
1607 | | - |
1608 | 1587 | MatchFinder *Finder; |
1609 | 1588 | MatchFinder::ParsingDoneTestCallback *ParsingDone; |
1610 | | - const MatchFinderOptions &Options; |
1611 | | - std::vector<Decl *> TraversalScope; |
1612 | 1589 | }; |
1613 | 1590 |
|
1614 | 1591 | } // end namespace |
@@ -1727,8 +1704,7 @@ bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch, |
1727 | 1704 | } |
1728 | 1705 |
|
1729 | 1706 | std::unique_ptr<ASTConsumer> MatchFinder::newASTConsumer() { |
1730 | | - return std::make_unique<internal::MatchASTConsumer>(this, ParsingDone, |
1731 | | - Options); |
| 1707 | + return std::make_unique<internal::MatchASTConsumer>(this, ParsingDone); |
1732 | 1708 | } |
1733 | 1709 |
|
1734 | 1710 | void MatchFinder::match(const clang::DynTypedNode &Node, ASTContext &Context) { |
|
0 commit comments