[PATCH] D90763: Traverse-ignore explicit template instantiations

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 14:51:14 PST 2020


steveire marked 2 inline comments as done.
steveire added inline comments.


================
Comment at: clang/unittests/AST/ASTTraverserTest.cpp:1092
+
+// Explicit instantiation of template functions do not appear in the AST
+template float timesTwo(float);
----------------
aaron.ballman wrote:
> Huh, do you have any idea if that's a bug? We have `ClassTemplateSpecializationDecl` and `VarTemplateSpecializationDecl`, but we have `FunctionTemplateSpecializationInfo` that doesn't generate an AST node and no mention of why in the comments that I've spotted yet.
I don't know why, but this is part of the confusion in the test in the discussion below.

I can look into it after this is merged if you don't beat me to it.


================
Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2280
+    EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+    EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
----------------
aaron.ballman wrote:
> Explicitly instantiating a function template in ignore mode returns false, but explicitly instantiating a class template returns true? Is this intentional or just fallout from the lack of explicit instantiation information in the AST for functions?
I've added some more tests and comments to try to clarify this.

We should be able to match on the template arguments of explicit instantiations, but not the contents of the instantiations.

Lack of representation of explicit function instantiations makes the expected test results confusing, but hopefully the comments now clarify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90763



More information about the cfe-commits mailing list