[clang] [ItaniumMangle] Use mangleType instead of mangleNameOrStandardSubstitution in mangleCXXCtorVTable function (PR #109970)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 26 01:04:11 PDT 2024
https://github.com/tcwzxx updated https://github.com/llvm/llvm-project/pull/109970
>From f9a25251087a160f2dc9e7f589aeb7b215bef60f Mon Sep 17 00:00:00 2001
From: tcwzxx <tcwzxx at gmail.com>
Date: Wed, 25 Sep 2024 19:19:08 +0800
Subject: [PATCH] Rename mangleNameOrStandardSubstitution to
mangleCXXRecordDecl and add Record to the substitution
---
clang/lib/AST/ItaniumMangle.cpp | 18 ++++++++++--------
clang/test/CodeGenCXX/mangle.cpp | 24 ++++++++++++++++++++++++
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b6e1da0c3192da..2c3321ad564781 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -464,7 +464,7 @@ class CXXNameMangler {
void mangleSeqID(unsigned SeqID);
void mangleName(GlobalDecl GD);
void mangleType(QualType T);
- void mangleNameOrStandardSubstitution(const NamedDecl *ND);
+ void mangleCXXRecordDecl(const CXXRecordDecl *Record);
void mangleLambdaSig(const CXXRecordDecl *Lambda);
void mangleModuleNamePrefix(StringRef Name, bool IsPartition = false);
void mangleVendorQualifier(StringRef Name);
@@ -3029,9 +3029,11 @@ void CXXNameMangler::mangleType(QualType T) {
addSubstitution(T);
}
-void CXXNameMangler::mangleNameOrStandardSubstitution(const NamedDecl *ND) {
- if (!mangleStandardSubstitution(ND))
- mangleName(ND);
+void CXXNameMangler::mangleCXXRecordDecl(const CXXRecordDecl *Record) {
+ if (mangleSubstitution(Record))
+ return;
+ mangleName(Record);
+ addSubstitution(Record);
}
void CXXNameMangler::mangleType(const BuiltinType *T) {
@@ -7309,7 +7311,7 @@ void ItaniumMangleContextImpl::mangleCXXVTable(const CXXRecordDecl *RD,
// <special-name> ::= TV <type> # virtual table
CXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "_ZTV";
- Mangler.mangleNameOrStandardSubstitution(RD);
+ Mangler.mangleCXXRecordDecl(RD);
}
void ItaniumMangleContextImpl::mangleCXXVTT(const CXXRecordDecl *RD,
@@ -7317,7 +7319,7 @@ void ItaniumMangleContextImpl::mangleCXXVTT(const CXXRecordDecl *RD,
// <special-name> ::= TT <type> # VTT structure
CXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "_ZTT";
- Mangler.mangleNameOrStandardSubstitution(RD);
+ Mangler.mangleCXXRecordDecl(RD);
}
void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
@@ -7327,10 +7329,10 @@ void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
// <special-name> ::= TC <type> <offset number> _ <base type>
CXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "_ZTC";
- Mangler.mangleNameOrStandardSubstitution(RD);
+ Mangler.mangleCXXRecordDecl(RD);
Mangler.getStream() << Offset;
Mangler.getStream() << '_';
- Mangler.mangleNameOrStandardSubstitution(Type);
+ Mangler.mangleCXXRecordDecl(Type);
}
void ItaniumMangleContextImpl::mangleCXXRTTI(QualType Ty, raw_ostream &Out) {
diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp
index d0800af55c87e8..848b026028be76 100644
--- a/clang/test/CodeGenCXX/mangle.cpp
+++ b/clang/test/CodeGenCXX/mangle.cpp
@@ -11,6 +11,8 @@ struct Y { };
//CHECK: @pr5966_i = external global
//CHECK: @_ZL8pr5966_j = internal global
+//CHECK: @_ZTCN6test624InstE0_NS_1A4ImplINS1_4WrapEEE
+
// CHECK-LABEL: define{{.*}} zeroext i1 @_ZplRK1YRA100_P1X
bool operator+(const Y&, X* (&xs)[100]) { return false; }
@@ -1214,3 +1216,25 @@ namespace test61 {
// CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE
template void f<X>(int, int);
}
+
+namespace test62 {
+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; }
+}
More information about the cfe-commits
mailing list