inlined `findAstNode()` calls (#4146)
This commit is contained in:
parent
423e67bd6a
commit
3d5d2e8fd8
|
@ -45,19 +45,6 @@
|
|||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
const Token* findAstNode(const Token* ast, const std::function<bool(const Token*)>& pred)
|
||||
{
|
||||
const Token* result = nullptr;
|
||||
visitAstNodes(ast, [&](const Token* tok) {
|
||||
if (pred(tok)) {
|
||||
result = tok;
|
||||
return ChildrenToVisit::done;
|
||||
}
|
||||
return ChildrenToVisit::op1_and_op2;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const Token* findExpression(const nonneg int exprid,
|
||||
const Token* start,
|
||||
const Token* end,
|
||||
|
|
|
@ -79,7 +79,20 @@ void visitAstNodes(T *ast, const TFunc &visitor)
|
|||
} while (true);
|
||||
}
|
||||
|
||||
const Token* findAstNode(const Token* ast, const std::function<bool(const Token*)>& pred);
|
||||
template<class TFunc>
|
||||
const Token* findAstNode(const Token* ast, const TFunc& pred)
|
||||
{
|
||||
const Token* result = nullptr;
|
||||
visitAstNodes(ast, [&](const Token* tok) {
|
||||
if (pred(tok)) {
|
||||
result = tok;
|
||||
return ChildrenToVisit::done;
|
||||
}
|
||||
return ChildrenToVisit::op1_and_op2;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const Token* findExpression(const nonneg int exprid,
|
||||
const Token* start,
|
||||
const Token* end,
|
||||
|
|
Loading…
Reference in New Issue