[all-commits] [llvm/llvm-project] 9c747b: [clang] [serialization] Step into UsingShadowDecl ...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Thu Jul 9 01:52:19 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9c747b3ed9116841c48913eb06ccb5fad13ad1a7
      https://github.com/llvm/llvm-project/commit/9c747b3ed9116841c48913eb06ccb5fad13ad1a7
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M clang/lib/Serialization/ASTReaderDecl.cpp
    A clang/test/Modules/GH207581.cpp

  Log Message:
  -----------
  [clang] [serialization] Step into UsingShadowDecl when find existing decl (#208393)

Close https://github.com/llvm/llvm-project/issues/207581

The root cause of the problem is that:enum constant decl, for which its
parent is not enum class, is special. They can be accessed directly
without access its parent. When modules join the game, it becomes more
complex. As for members in other entities like class, we can assume the
member is accessable if their parent are accesable. But it is a
different story for enums. See
https://github.com/llvm/llvm-project/issues/131058 for the whole story
of the backrgound.

Then we didn't write enum constant decl to the lookup table of its
parent of parent in the ASTWriter. So that if other consumer in Sema
wants to access them, they have to get it by entities like exported
using decls. However, the problem is, in ASTReader, when we merge decls,
we use noload_lookup to find existing decls. And the absense of unnamed
enum decl in the parent of its parent's lookup table makes the merge
fails. For enum constant decl in named enum, they will still have a name
lookup table. So we will merge them somehow. But for enum constants in
unnamed enum, they were removed from the only lookup table so the merge
fails. This is the whole story of the current issue.

To fix this, when we merge decls, we step into the UsingShadowDecl to
find the real decls. This is fine as we never merge decls with different
kinds. We can even call this a tiny optimization.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list