[clang] [Clang] skip default argument instantiation for non-defining friend declarations without specialization info to meet [dcl.fct.default] p4 (PR #113777)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 01:33:18 PST 2024


zyn0217 wrote:

Further reduced to:

```cpp
struct CacheRequestImpl {
  friend void LoadOrRun(CacheRequestImpl, int = 42) {}
};
void CacheRequestTests_MakesCacheKey_TestTestBody() {
  CacheRequestImpl req;
  LoadOrRun(req);
}
```

There is no template in this case, so obviously, `FDecl->getMemberSpecializationInfo()` would be null, hence the absence of the default arguments with this patch.

As I have [suggested](https://github.com/llvm/llvm-project/pull/113777#discussion_r1830858725) initially, we should probably put the checking in `Sema::InstantiateDefaultArgument()` because that is where the instantiation of default arguments in templates starts.

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


More information about the cfe-commits mailing list