[cfe-commits] [PATCH] Allow RecursiveASTVisitor to visit implicit ctor initializers (for which isWritten() returns false)

Manuel Klimek reviews at llvm-reviews.chandlerc.com
Thu Aug 23 16:28:39 PDT 2012



================
Comment at: unittests/Tooling/RecursiveASTVisitorTest.cpp:413-416
@@ +412,6 @@
+  // to use them in order to force them to appear in the AST.
+  EXPECT_TRUE(Visitor.runOver(
+      "struct WithCtor { WithCtor(); }; \n"
+      "struct Simple { Simple(); WithCtor w; }; \n"
+      "int main() { Simple s; Simple t(s); }\n"));
+}
----------------
James Dennett wrote:
> Manuel Klimek wrote:
> > I'd probably quickly add a EXPECT_FALSE for everything but the copy constructor, so that we are actually sure the test passes for the right reason.
> The test passes because the visitor visits the implicit (un-written) construction of a WithCtor object -- nothing else satisfies the expectations.  I've added another test that a suitable visitors does *not* visit it (because it's implicit, and that visitor skips implicit code).
Two questions:
1. why was the Simple t(s) there at all?
2. why the second test not possible with EXPECT_FALSE and a visitor that does not visit implicit code?


http://llvm-reviews.chandlerc.com/D26



More information about the cfe-commits mailing list