[PATCH] D65735: [AST] Fix RecursiveASTVisitor visiting implicit constructor initializers.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 5 00:48:11 PDT 2019


hokein added a comment.

I think this is a reasonable fix, just a few comments on the test.



================
Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp:26
+  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
+    if (Init->getSourceLocation().isInvalid())
+      InvalidLocsVisited = true;
----------------
there may be other reasons to cause an invalid source location. I think we can use the `Init->isWritten()` to verify the implicit initializer is being visited. 


================
Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp:37
 
+  bool InvalidLocsVisited = false;
 private:
----------------
maybe name it `VisitedImplicitInitializer`?


================
Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp:62
+  std::vector<bool> Config{true, false};
+  for (bool VisitImplCode : Config) {
+    InitListExprPreOrderVisitor Visitor(VisitImplCode);
----------------
nit: inline the Config.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65735/new/

https://reviews.llvm.org/D65735





More information about the cfe-commits mailing list