[clang] [C++20][Modules] Improve namespace look-up performance for modules. (PR #171769)
Michael Park via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 08:02:55 PST 2025
mpark wrote:
> Why is the namespace decl special? Can we make this optimization more general?
I did try to generalize it for all redeclarable decls, but it failed a bunch of unit tests. My understanding is that namespaces are indeed special in this aspect, according to [this comment in `getAcceptableDeclSlow`](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaLookup.cpp#L2129-L2134):
```
if (auto *ND = dyn_cast<NamespaceDecl>(D)) {
// Namespaces are a bit of a special case: we expect there to be a lot of
// redeclarations of some namespaces, all declarations of a namespace are
// essentially interchangeable, all declarations are found by name lookup
// if any is, and namespaces are never looked up during template
// instantiation. So we benefit from caching the check in this case, and
// it is correct to do so.
...
}
...
```
https://github.com/llvm/llvm-project/pull/171769
More information about the cfe-commits
mailing list