mpark wrote:

> How these decls get merged if:
> 
> ```
> // a.h
> template <typename T>
> struct S { union { T x; }; };
> 
> // b.h
> import "a.h";
> inline void f(S<int> s = {}) { s.x; }
> 
> // main.cpp
> import "a.h";
> void g(S<int>) {}
> 
> import "b.h";
> void h() { f(); }
> ```
> 
> I feel we can get some ideas from it.

In this case, because of the missing `using SI = S<int>;` in `a.h`, when we 
import it in `main.cpp`, there's no `ClassTemplateSpecializationDecl` to be 
imported from `a.h` at all. We create a new instance of 
`ClassTemplateSpecializationDecl` where the `isFromASTFile` is set to `false` 
(since we created within `main.cpp`). The "[not 
`isFromASTFile`](https://github.com/llvm/llvm-project/blob/main/clang/lib/Serialization/ASTReaderDecl.cpp#L3430)"
 condition in this case works.

https://github.com/llvm/llvm-project/pull/155948
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to