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 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
