[clang] No longer add enumeration constants to the wrong scope (PR #134998)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 9 06:15:40 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();
----------------
erichkeane wrote:
Hmm... What is the logic to set the `EnumConstantDecl` (or, that is, just the `Decls` themselves) to be `OutOfLine`? I can't imagine this is the only logic for `OutOfLine` that could be reasonable to check, and wonder if we should just set `EnumConstantDecl::OutOfLine` 'correctly'.
WDYT?
https://github.com/llvm/llvm-project/pull/134998
More information about the cfe-commits
mailing list