[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 16 18:43:50 PST 2020
rsmith created this revision.
rsmith added a reviewer: rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
We previously listed first declared members, then implicit operator=,
then implicit operator==, then implicit destructors. Per discussion on
https://github.com/itanium-cxx-abi/cxx-abi/issues/88, put the implicit
equality comparison operators at the very end, after all special member
functions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72897
Files:
clang/lib/AST/VTableBuilder.cpp
clang/test/CodeGenCXX/virtual-compare.cpp
Index: clang/test/CodeGenCXX/virtual-compare.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/virtual-compare.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/std-compare.h"
+
+// CHECK: @_ZTV1A =
+struct A;
+struct X {
+ // CHECK-SAME: @_ZN1X1xEv
+ virtual void x();
+ friend auto operator<=>(X, X) = default;
+};
+struct Y {
+ virtual ~Y();
+ virtual A &operator=(const A &);
+ friend auto operator<=>(Y, Y) = default;
+};
+struct A : X, Y {
+ // CHECK-SAME: @_ZN1A1fEv
+ virtual void f();
+ // CHECK-SAME: @_ZNKR1AssERKS_
+ virtual std::strong_ordering operator<=>(const A &) const & = default;
+ // CHECK-SAME: @_ZN1A1gEv
+ virtual void g();
+ // CHECK-SAME: @_ZNKO1AssERKS_
+ virtual std::strong_ordering operator<=>(const A &) const && = default;
+ // CHECK-SAME: @_ZN1A1hEv
+ virtual void h();
+
+ // CHECK-SAME: @_ZN1AaSERKS_
+ // implicit virtual A &operator=(const A&) = default;
+
+ // CHECK-SAME: @_ZN1AD1Ev
+ // CHECK-SAME: @_ZN1AD0Ev
+ // implicit virtual ~A();
+
+ // CHECK-SAME: @_ZNKR1AeqERKS_
+ // implicit virtual A &operator==(const A&) const & = default;
+
+ // CHECK-SAME: @_ZNKO1AeqERKS_
+ // implicit virtual A &operator==(const A&) const && = default;
+};
+
+// For Y:
+// CHECK-SAME: @_ZTI1A
+
+// CHECK-SAME: @_ZThn8_N1AD1Ev
+// CHECK-SAME: @_ZThn8_N1AD0Ev
+// virtual ~Y();
+
+// CHECK-SAME: @_ZThn8_N1AaSERKS_
+// virtual A &operator=(const A &);
+
+void A::f() {}
Index: clang/lib/AST/VTableBuilder.cpp
===================================================================
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -1474,8 +1474,6 @@
llvm_unreachable("Found a duplicate primary base!");
}
- const CXXDestructorDecl *ImplicitVirtualDtor = nullptr;
-
typedef llvm::SmallVector<const CXXMethodDecl *, 8> NewVirtualFunctionsTy;
NewVirtualFunctionsTy NewVirtualFunctions;
@@ -1542,25 +1540,9 @@
}
}
- if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
- if (MD->isImplicit()) {
- // Itanium C++ ABI 2.5.2:
- // If a class has an implicitly-defined virtual destructor,
- // its entries come after the declared virtual function pointers.
-
- assert(!ImplicitVirtualDtor &&
- "Did already see an implicit virtual dtor!");
- ImplicitVirtualDtor = DD;
- continue;
- }
- }
-
NewVirtualFunctions.push_back(MD);
}
- if (ImplicitVirtualDtor)
- NewVirtualFunctions.push_back(ImplicitVirtualDtor);
-
for (const CXXMethodDecl *MD : NewVirtualFunctions) {
// Get the final overrider.
FinalOverriders::OverriderInfo Overrider =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72897.238680.patch
Type: text/x-patch
Size: 2799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200117/5203fed3/attachment.bin>
More information about the cfe-commits
mailing list