[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)
Michael Jabbour via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 5 00:26:32 PST 2025
================
@@ -2639,6 +2628,19 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
notePreviousDefinition(Old, New->getLocation());
}
+void Sema::CleanupMergedEnum(Scope *S, Decl *New) {
----------------
michael-jabbour-sonarsource wrote:
> Is MergeTypedefNameDecl not called for the motivating example?
Unfortunately, it seems to me that `MergeTypedefNameDecl` is only called in the typedef to anonymous enum case (`MyEnum3` in the test case I am adding). For the rest of the enum cases, the closest I found was `Sema::ActOnDuplicateDefinition`, which is called when merging all tags (and this is where I am adding the new call to `CleanupMergedEnum`).
> Can we find a common path when merging definitions to put that logic there?
I could only see that merging enums for C and Obj-C crashes in this case (C++ works differently, see [here](https://github.com/llvm/llvm-project/pull/114240#issuecomment-2614544626)), and I found `Sema::ActOnDuplicateDefinition` during my investigation to be the function that handles merging tags.
I am not aware of a central place for merging definitions in general. Could you provide some hints on what to look for?
https://github.com/llvm/llvm-project/pull/114240
More information about the cfe-commits
mailing list