As you can see from the test-plugin output, the VarParmDecl node for D::f::c is visited twice, while the VarParmDecl node for D::f::c (which is also referenced later in a DeclRefExpr) is never visited. I've also attached the AST dump output, which shows the missing node.
I've done a little research, and it seems that this is a little different from bug 16182. In this case, the implicitly instantiated function DOES have TypeSourceInfo, but its TypeLoc is the same for D::f and D::f. I can't tell if this is correct or not. I can work around this issue by ensuring that the first branch (ie. TraverseTypeLoc(TSI->getTypeLoc())) is not taken when D->getTemplateSpecializationKind() == TSK_ImplicitInstantiation, and adding " || || getDerived().shouldVisitTemplateInstantiations()" to the second branch test. I'm not too sure whether the shouldVisit checks for the second branch are necessary because -- correct me if I'm wrong -- if shouldVisit returned false, we wouldn't have traversed an implicit FunctionDecl in the first place?
Extended Description
Run the attached testcase with:
clang++ -Xclang -load -Xclang ./test-plugin.so -Xclang -add-plugin -Xclang test -o code test.cpp
As you can see from the test-plugin output, the VarParmDecl node for D::f::c is visited twice, while the VarParmDecl node for D::f::c (which is also referenced later in a DeclRefExpr) is never visited. I've also attached the AST dump output, which shows the missing node.