[PATCH] D129748: [Modules] Disable preferred_name attribute in C++20 Modules

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 15 09:47:09 PDT 2022


tahonermann added a comment.

I'm not following what the root problem is. You stated:

> When we write the attribute preferred_name(foo) in ASTWriter, the compiler would try to write the type for the argument foo. Then when the compiler write the type for foo, the compiler find the type for foo is a TypeDef type. So the compiler would write the corresponding type foo_templ<char>. The key point here is that the AST for foo_templ<char> is complete now. Since the AST for foo_templ<char> is constructed in Sema.

Are you saying that the act of writing the AST is triggering the instantiation/completion of `foo_templ<char>`? Serialization should certainly not cause such side effects.

I'm likewise not following the concern with reading the AST:

> When we read the attribute preferred_name(foo), we would read the type for the argument foo and then we would try to read the type foo_templ<char> later. However, the key problem here is that when we read foo_templ<char>, its AST is not constructed yet! So we get a different type with the writer writes. So here is the ODR violation.

I wouldn't expect the same `Sema` instance to be used to both write and read the same AST.

The test case defines two modules (`A` and `Use`) that both have definitions of `foo_templ`, `foo`, and `foo_templ<char>` in their global module fragments. It sounds to me like the issue here might be that these definitions are not getting merged (perhaps because of the issue you are trying to describe and address).

Can you try again to explain the root problem? Perhaps with references to relevant code?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129748/new/

https://reviews.llvm.org/D129748



More information about the cfe-commits mailing list