ChuanqiXu9 wrote:

> > I am confused that when we try to merge the field from "b.h", the primary 
> > DC should be the definition instead of the declaration: 
> > https://github.com/llvm/llvm-project/blob/899fb7f663a973d6cef57533c85884631f08f26b/clang/lib/Serialization/ASTReaderDecl.cpp#L3385C1-L3389C42
> > I think the definition in your case should be fully instantiated in 
> > main.cpp and its value of `isFromASTFile` should be false. What's going on 
> > here?
> 
> Yeah, so as far I know:
> 
> 1. The `using SI = S<int>;` creates an instance of 
> `ClassTemplateSpecializationDecl` that's not instantiated, and gets 
> serialized to `a.pcm`.
> 2. When `a.pcm` is read into `main.cpp`, the 
> `ClassTemplateSpecializationDecl` instance is deserialized, and marked 
> `isFromASTFile`.
> 3. When `main.cpp` goes to perform the full instantiation of `S<int>`, it 
> [performs the instantiation "in-place" on the deserialized 
> instance](https://github.com/llvm/llvm-project/blob/ab0bb6db39cefa5c27aab0ac6af7c33e652ba28b/clang/lib/Sema/SemaTemplateInstantiate.cpp#L4241-L4243).
>  So the "definition" of `ClassTemplateSpecializationDecl` instance is still 
> the same one that has `isFromASTFile = true`.

Then in this case, although the `ClassTemplateSpecializationDecl` is marked as 
`isFromASTFile`, but do its children come from ASTFile? Maybe we can check the 
`CXXRecordDecl ` of the `ClassTemplateSpecializationDecl` or any other child.

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