[all-commits] [llvm/llvm-project] 2b03c6: [Clang][Modules] Fix ODR handling of types found t...
Daedie-git via All-commits
all-commits at lists.llvm.org
Mon Sep 7 18:59:43 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2b03c66b5f0fdd12f616d845b61417442322f03c
https://github.com/llvm/llvm-project/commit/2b03c66b5f0fdd12f616d845b61417442322f03c
Author: Daedie-git <HC_Daedalus at hotmail.com>
Date: 2026-09-08 (Tue, 08 Sep 2026)
Changed paths:
M clang/docs/ReleaseNotes.md
M clang/docs/StandardCPlusPlusModules.md
M clang/lib/AST/ODRDiagsEmitter.cpp
M clang/lib/AST/ODRHash.cpp
A clang/test/Modules/odr-hash-using-declarations.cppm
M clang/test/Modules/pr76638.cppm
Log Message:
-----------
[Clang][Modules] Fix ODR handling of types found through using-declarations (#221839)
Fixes #78850.
Clang can diagnose an ODR violation for identical definitions when a
type is
found directly in one module's global module fragment and through a
using-declaration in another. The lookup routes produce different AST
type
wrappers even though they refer to the same declaration.
Normalize `UsingType` to the target declaration's type before hashing
it. Keep
the keyword and qualifier from the use site, rather than from the
using-declaration. This also lets the hash distinguish differently
qualified
uses without canonicalizing away meaningful spelling differences.
The normalization exposes an existing assertion in the enum ODR
diagnostic
path: `AddEnumDecl` hashes canonical underlying integer types, but the
diagnostic emitter compares hashes of their spelled types. Compare the
actual
underlying integer types instead, while retaining the original spelling
in the
diagnostic. The extended `pr76638.cppm` regression also reproduces the
assertion
without the normalization change, when both underlying types are found
through
same-named using-declarations.
Use `EnumDecl::getIntegerType()` for this comparison so ignored cv
qualifiers
in the enum-base do not incorrectly take precedence over an actual
difference
in enumerator initializers. A regression checks that diagnostic as well.
Regression coverage includes both lookup directions, typedefs and
aliases,
record and enum types, chained using-declarations, templates, and
negative
tests for qualification, elaborated keywords, and cv qualification.
Remove the
now-fixed #78850 example from the modules documentation.
## Validation
Built from main at `44a4dbf32a6b54de32e4d064756d7a6ba5b9e808` plus this
patch,
in Release mode with assertions enabled on Windows x86-64 (X86 backend,
Clang 23.1.0 bootstrap, VS 2022 SDK).
| Suite | Passed | Unsupported | Expected Failures |
| :------------ | -----: | ----------: | ----------------: |
| Clang Modules | 914 | 34 | 0 |
| Clang PCH | 289 | 6 | 2 |
| **Total** | 1,203 | 40 | 2 |
Unexpected failures: **0**.
- Removing both implementation changes and rebuilding on the same main
base
makes both affected regression tests fail: the new lookup test reports
false ODR errors, and the extended enum test asserts while diagnosing an
ODR
violation. Restoring the changes and rebuilding passes both complete
suites.
- The cv-qualifier regression also fails with the earlier comparison of
spelled underlying types, then passes with `getIntegerType()`.
- Changed implementation lines pass clang-format checks; `git diff
--check`
passes.
The original release/23.x patch was also tested: 1,180 passed, 39
unsupported,
2 expected failures, and no unexpected failures across Modules and PCH.
Its
unmodified implementation reproduced the false-positive diagnostics,
missed
qualification diagnostic, and enum assertion.
Other platforms and configurations have not been tested locally.
This is a targeted ODR fix, not a general resolution of Clang's
remaining C++
module limitations.
The fix is also relevant to release/23.x; a backport can follow upstream
review
and merge.
Assisted-by: OpenAI Codex Astra
Co-authored-by: Bjorn Schobben <bjorn.schobben at aimsport.com>
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