[clang] [RFC][clang] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 26 14:28:41 PDT 2025


================
@@ -2572,7 +2572,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
   // Friend function defined withing class template may stop being function
   // definition during AST merges from different modules, in this case decl
   // with function body should be used for instantiation.
-  if (isFriend) {
+  if (isFriend && D->hasOwningModule()) {
----------------
mizvekov wrote:

Oh yes, I took the last free bit in FunctionDeclBits a couple of months ago :)

This is a tall order, but it may be possible to make room in there. For example:

```C++
    LLVM_PREFERRED_TYPE(bool)
    uint64_t IsDefaulted : 1;
    LLVM_PREFERRED_TYPE(bool)
    uint64_t IsExplicitlyDefaulted : 1;
 ```
 
 It looks like `IsExplicitlyDefaulted` only makes sense if `IsDefaulted` is true, and maybe your new stuff only makes sense if `IsDefaulted` is false, so you can
probably share the `IsExplicitlyDefaulted` bit.

if that doesn't work, there are some other potential candidates.

For example, some bit fields only make sense if the function has a body, like `UsesSEHTry`, and these bits would probably be free for you as well.

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


More information about the cfe-commits mailing list