[clang] [analyzer] Fix [[clang::suppress]] for template instantiations (PR #168954)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 21 15:41:32 PST 2025
steakhal wrote:
> > I'm somewhat surprised that it's necessary to visit template instantiations. This machine simply memorizes source locations. Template instantiations have the same source locations as the template itself right? (...right? 😳)
> > LGTM because I'm sure there's a perfectly reasonable explanation for that.
>
> I see what you mean. I'll have a look tomorrow. Thanks for the reviews!
It actually didn't take long. Check the AST of the example: https://godbolt.org/z/MsT5jx3nE
Funnily, the primary template is outside of the CXXRecordDecl. Only the template instantiation is under the CXXRecordDecl.
That should explain the traversal. IDK why don't we have a primary template within the class. Maybe because there can only be exactly 1 primary template. And that is "spelled" outside of the class declaration, thus to remain truthful to the sources, then the primary template AST must also live where it's spelled. I think this is the explanation.
Yeah, there are days when I hate C++, if you ask me.
https://github.com/llvm/llvm-project/pull/168954
More information about the cfe-commits
mailing list