[PATCH] D120504: [AST] RAV doesn't traverse explicitly instantiated function bodies by default

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 25 04:29:34 PST 2022


sammccall added inline comments.


================
Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:2107
 
-  if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
-    // Constructor initializers.
----------------
hokein wrote:
> moving this part of code to `if (VisitBody)` seems like a different fix (and I think it is reasonable, from the grammar, the ctor-initializer is part of the function-body), can we separate it and add a test? 
I can do it as a separate patch before if you like, but it's NFC.

Behavior only differs if there is an init list and VisitBody is false.
However !VisitBody requires one of:
 - this is a declaration only => no init list
 - this is a defaulted function => no init list


================
Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Templates.cpp:168
     extern template int foo<3>();
     // Explicit instantiation. Head traversed, body only with instantiations on.
     template int foo<4>();
----------------
hokein wrote:
> What does the Head mean? 
Within the function 

int foo<4>() { return 0; }.

I've called `int foo<4>()` the "head" and `{return 0;}` the "body".
The distinction is that the head was written, and the body was instantiated.

are there better terms? (I'd probably like this "head" better than "declaration part" so maybe we should just define these terms in the shouldVisitTemplateInstantiations() comment)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120504



More information about the cfe-commits mailing list