Skip to content

[ABI] mangleCXXCtorVTable mangles an incorrect name #108015

Closed
@tcwzxx

Description

@tcwzxx
namespace A {

class VBase {
 public:
  virtual ~VBase() {};
};

struct Wrap {};

template <typename T>
class Impl : public virtual VBase {
 public:
};

}  // namespace A

struct Inst : public A::Impl<A::Wrap> {};

void Test() { Inst a; }

The code above will generate a CtorVTable with the name _ZTC4Inst0_N1A4ImplINS_4WrapEEE. After demangling, the result is construction vtable for A::Impl<Inst::Wrap>-in-Inst. However, Inst::Wrap is incorrect.

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";
Mangler.mangleNameOrStandardSubstitution(RD);
Mangler.getStream() << Offset;
Mangler.getStream() << '_';
Mangler.mangleNameOrStandardSubstitution(Type);
}

Because mangleNameOrStandardSubstitution never adds RD as a substitution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ABIApplication Binary Interfaceclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions