[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed May 7 13:51:37 PDT 2025


================
@@ -3102,11 +3103,15 @@ void CXXNameMangler::mangleType(QualType T) {
     addSubstitution(T);
 }
 
-void CXXNameMangler::mangleCXXRecordDecl(const CXXRecordDecl *Record) {
+void CXXNameMangler::mangleCXXRecordDecl(const CXXRecordDecl *Record,
+                                         bool IsManglingVTable) {
   if (mangleSubstitution(Record))
     return;
   mangleName(Record);
-  if (isCompatibleWith(LangOptions::ClangABI::Ver19))
+  // If we are mangling vtables, return early without adding the record to the
+  // dictionary of substitution candidates to maintain compatibility with older
+  // ABIs.
+  if (IsManglingVTable && isCompatibleWith(LangOptions::ClangABI::Ver19))
----------------
mizvekov wrote:

So the previous buggy behavior is a bit interesting.

You are saying we used to mangle a substitution here, but not actually consider this site a user of the type for future substitutions?

Do you have a specific test case for that?

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


More information about the cfe-commits mailing list