ChuanqiXu9 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` within `main.cpp` 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 kicks in, and therefore behaves correctly.
Got it. And I am curious, how does it handle the case that the previous class
template specialization comes from AST case?
https://github.com/llvm/llvm-project/pull/155948
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits