[clang] Use mangleType instead of mangleNameOrStandardSubstitution in mangleCXXCtorVTable function (PR #109970)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 25 05:32:16 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: tcwzxx (tcwzxx)
<details>
<summary>Changes</summary>
Fix #<!-- -->108015
The mangleNameOrStandardSubstitution function does not add the RD type into the substitution, which causes the mangling of the \<base type\> to be incorrect.
---
Full diff: https://github.com/llvm/llvm-project/pull/109970.diff
2 Files Affected:
- (modified) clang/lib/AST/ItaniumMangle.cpp (+4-2)
- (modified) clang/test/CodeGenCXX/mangle.cpp (+24)
``````````diff
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b6e1da0c3192da..962e62ef86c0ca 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -7326,11 +7326,13 @@ void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
raw_ostream &Out) {
// <special-name> ::= TC <type> <offset number> _ <base type>
CXXNameMangler Mangler(*this, Out);
+ QualType RDType = getASTContext().getRecordType(RD);
+ QualType TypeType = getASTContext().getRecordType(Type);
Mangler.getStream() << "_ZTC";
- Mangler.mangleNameOrStandardSubstitution(RD);
+ Mangler.mangleType(RDType);
Mangler.getStream() << Offset;
Mangler.getStream() << '_';
- Mangler.mangleNameOrStandardSubstitution(Type);
+ Mangler.mangleType(TypeType);
}
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; }
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/109970
More information about the cfe-commits
mailing list