[clang] [Serialization] Load Specializations Lazily (PR #76774)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 21 18:14:34 PST 2024


ChuanqiXu9 wrote:

> > I tried applying this patch to ROOT/Cling and it fails to build because something is of the opinion that `std::is_integral<int>::value` is not true. I don't have time right now to investigate further, but since this is the only change I did it is highly likely that it's caused by this...
> 
> In that case we need to understand how this patch differs from the one I pasted in phabricator since the one there works for that case I assume.

I had a guess. `{ClassTemplateDecl, VarTemplateDecl, FunctionTemplateDecl}::specializations()` will iterate all the specializations. However, after this patch, there are maybe some specializations not loaded at the time of invocation. Then during the process of iterating `specializations()`, it may require to complete the redecl chain to trigger the process of loading specializations (https://github.com/llvm/llvm-project/blob/2e30e31e1e80184d9b2c8aa98f617b4d1cb56d55/clang/include/clang/AST/DeclTemplate.h#L779-L781). Then boom!

To fix this, maybe we need to add a `loadAllExternalSpecializations(Decl*)` method to be called before `{ClassTemplateDecl, VarTemplateDecl, FunctionTemplateDecl}::specializations()`. But I am not sure if it is really the case and I feel better if we can add new things with the corresponding test.

https://github.com/llvm/llvm-project/pull/76774


More information about the cfe-commits mailing list