Fix use of directly-nested traverse() matchers

This commit is contained in:
Stephen Kelly 2020-11-09 18:59:30 +00:00
parent 121d51dc83
commit 23f17ab5ff
2 changed files with 7 additions and 0 deletions

View File

@ -1206,6 +1206,8 @@ public:
}
llvm::Optional<clang::TraversalKind> TraversalKind() const override {
if (auto NestedKind = this->InnerMatcher.getTraversalKind())
return NestedKind;
return Traversal;
}
};

View File

@ -2372,6 +2372,11 @@ void foo()
callExpr(has(callExpr(traverse(
TK_AsIs, callExpr(has(implicitCastExpr(
has(floatLiteral())))))))))));
EXPECT_TRUE(matches(
Code,
traverse(TK_IgnoreImplicitCastsAndParentheses,
traverse(TK_AsIs, implicitCastExpr(has(floatLiteral()))))));
}
TEST(Traversal, traverseMatcherThroughImplicit) {