[clang] Reland: [clang] Track function template instantiation from definition (PR #125266)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 15:35:10 PST 2025
================
@@ -2298,6 +2298,13 @@ class FunctionDecl : public DeclaratorDecl,
FunctionDeclBits.IsLateTemplateParsed = ILT;
}
+ bool isInstantiatedFromMemberTemplate() const {
+ return FunctionDeclBits.IsInstantiatedFromMemberTemplate;
+ }
+ void setInstantiatedFromMemberTemplate(bool Val = true) {
+ FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val;
+ }
+
----------------
cor3ntin wrote:
> These are for different things. getInstantiatedFromDecl is used to tell which function this "was instantiated from, if this is a function declaration declared locally inside of a function template".
UGH, completely missed that - all of this could use some more comments
> Because FunctionDecl has free bits, so this change has basically no space cost :)
Yeah, but 1/it's a bit confusing 2/ bits there are fairly precious
You could add a bit to FunctionTemplateSpecializationInfo::Function
I don't insist on it. However can you add some comments? It took me a while to understand and I suspect i won;t be the only one.
Thanks, I'll approve when i wake up (and sorry it took me a while to understand everything)
Oh, another solution would be to have a DenseMap of FunctionTemplateDecl -> FunctionTemplateDecl in Sema, storing specialization of friend functions template (only!) in it - hopefully these things are fairly rare - and it might simplify the change to InstantiateFunctionDefinition
https://github.com/llvm/llvm-project/pull/125266
More information about the cfe-commits
mailing list