[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 11:47:51 PDT 2025


================
@@ -5585,6 +5585,18 @@ SourceRange EnumConstantDecl::getSourceRange() const {
   return SourceRange(getLocation(), End);
 }
 
+bool EnumConstantDecl::isOutOfLine() const {
+  if (Decl::isOutOfLine())
+    return true;
+
+  // In C++, if the enumeration is out of line, the enumeration constants are
+  // also out of line.
+  if (getLangOpts().CPlusPlus)
+    return cast<Decl>(getDeclContext())->isOutOfLine();
----------------
AaronBallman wrote:

I don't think it can be, but this function is a virtual method of `Decl`, so no need to cast to a specific kind of `Decl` to get the correct behavior.

https://github.com/llvm/llvm-project/pull/134998


More information about the cfe-commits mailing list