[RecursiveASTVisitor] Visit the implicit expression of a CXXDefaultArgExpr
Summary:
The matcher
varDecl(hasDescendant(
callExpr(hasDeclaration(functionDecl(unless(isNoThrow()))))))
didn't match calls from default arguments because the expression
for a CXXDefaultArgExpr was not visited.
Reviewers: klimek, jdennett, alexfh, aaron.ballman
Subscribers: aaron.ballman, cfe-commits
Differential Revision: https://reviews.llvm.org/D25992
llvm-svn: 285239
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
index 991ae8b..a2aedb6 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -152,4 +152,21 @@
"};\n"));
}
+// Check to ensure that implicit default argument expressions are visited.
+class IntegerLiteralVisitor
+ : public ExpectedLocationVisitor<IntegerLiteralVisitor> {
+public:
+ bool VisitIntegerLiteral(const IntegerLiteral *IL) {
+ Match("literal", IL->getLocation());
+ return true;
+ }
+};
+
+TEST(RecursiveASTVisitor, DefaultArgumentsAreVisited) {
+ IntegerLiteralVisitor Visitor;
+ Visitor.ExpectMatch("literal", 1, 15, 2);
+ EXPECT_TRUE(Visitor.runOver("int f(int i = 1);\n"
+ "static int k = f();\n"));
+}
+
} // end anonymous namespace