[PATCH] D25992: [RecursiveASTVisitor] Visit the implicit expression of a CXXDefaultArgExpr

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 13:49:30 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL285239: [RecursiveASTVisitor] Visit the implicit expression of a CXXDefaultArgExpr (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25992?vs=75899&id=75944#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25992

Files:
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp


Index: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
===================================================================
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ cfe/trunk/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
Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2354,7 +2354,10 @@
 })
 DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {})
 DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {})
-DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {})
+DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {
+  if (getDerived().shouldVisitImplicitCode())
+    TRY_TO(TraverseStmt(S->getExpr()));
+})
 DEF_TRAVERSE_STMT(CXXDefaultInitExpr, {})
 DEF_TRAVERSE_STMT(CXXDeleteExpr, {})
 DEF_TRAVERSE_STMT(ExprWithCleanups, {})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25992.75944.patch
Type: text/x-patch
Size: 1540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161026/c5a03903/attachment.bin>


More information about the cfe-commits mailing list