[clang] No longer add enumeration constants to the wrong scope (PR #134998)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 9 07:08:43 PDT 2025
================
@@ -1523,7 +1523,10 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
// Out-of-line definitions shouldn't be pushed into scope in C++, unless they
// are function-local declarations.
- if (getLangOpts().CPlusPlus && D->isOutOfLine() && !S->getFnParent())
+ bool OutOfLine = D->isOutOfLine();
+ if (const auto *ECD = dyn_cast<EnumConstantDecl>(D))
+ OutOfLine = OutOfLine || cast<Decl>(ECD->getDeclContext())->isOutOfLine();
----------------
AaronBallman wrote:
Hmmm I see that `isOutOfLine()` is actually a virtual function, so yeah, I think I can hide this logic in there for `EnumConstantDecl` itself. Good call!
https://github.com/llvm/llvm-project/pull/134998
More information about the cfe-commits
mailing list