[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

Michael Jabbour via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 21 00:58:30 PST 2025


================
@@ -2551,18 +2551,7 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
       // Make the old tag definition visible.
       makeMergedDefinitionVisible(Hidden);
 
-      // If this was an unscoped enumeration, yank all of its enumerators
-      // out of the scope.
-      if (isa<EnumDecl>(NewTag)) {
-        Scope *EnumScope = getNonFieldDeclScope(S);
-        for (auto *D : NewTag->decls()) {
-          auto *ED = cast<EnumConstantDecl>(D);
-          assert(EnumScope->isDeclScope(ED));
-          EnumScope->RemoveDecl(ED);
-          IdResolver.RemoveDecl(ED);
-          ED->getLexicalDeclContext()->removeDecl(ED);
----------------
michael-jabbour-sonarsource wrote:

I can try to dig deeper to answer the points I mentioned (especially point 2) if desired, but I would need to allocate some time (maybe at the end of the week).

Any pointers/hints/thoughts would be appreciated.

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


More information about the cfe-commits mailing list