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

via cfe-commits cfe-commits at lists.llvm.org
Sat May 10 01:37:38 PDT 2025


tcwzxx wrote:

> > Given that the mangleCXXRecordDecl function is used outside of the `MangleVTable` , I think the ABI compatibility logic should be moved to mangleCXXCtorVTable
> 
> Could you elaborate on how to separate just the ABI compatibility logic from `mangleCXXRecordDecl`?
> 
> Wouldn't you have to move the code to `mangleCXXVTable` and `mangleCXXVTT` too? I'm not sure we want to duplicate code in multiple functions.

This compatibility occurs only here. My last patch wasn't perfect.



```C++
void mangleCXXRecordDecl(const CXXRecordDecl *Record, bool DontAddSubstitutionForCompat = false);

void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
                                                   int64_t Offset,
                                                   const CXXRecordDecl *Type,
                                                   raw_ostream &Out) {
  // <special-name> ::= TC <type> <offset number> _ <base type>
  CXXNameMangler Mangler(*this, Out);
  Mangler.getStream() << "_ZTC";
  bool CompatibilityForV19   = getASTContext().getLangOpts().getClangABICompat() <=
                    clang::LangOptionsBase::ClangABI::Ver19;
  Mangler.mangleCXXRecordDecl(RD, CompatibilityForV19);
  Mangler.getStream() << Offset;
  Mangler.getStream() << '_';
  Mangler.mangleCXXRecordDecl(Type);
}

```

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


More information about the cfe-commits mailing list