[clang] 70aa462 - [NFC][Clang][Codegen] Add tests with wrong attributes on this/return of thunks

Roman Lebedev via cfe-commits cfe-commits at lists.llvm.org
Thu May 13 10:34:13 PDT 2021


Author: Roman Lebedev
Date: 2021-05-13T20:32:40+03:00
New Revision: 70aa4623de9fe2f609eab8969d7ef76b4c80084b

URL: https://github.com/llvm/llvm-project/commit/70aa4623de9fe2f609eab8969d7ef76b4c80084b
DIFF: https://github.com/llvm/llvm-project/commit/70aa4623de9fe2f609eab8969d7ef76b4c80084b.diff

LOG: [NFC][Clang][Codegen] Add tests with wrong attributes on this/return of thunks

>From https://reviews.llvm.org/D100388

Added: 
    clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
    clang/test/CodeGenCXX/thunk-wrong-this.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp b/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
new file mode 100644
index 0000000000000..f6d662c8cb7a9
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+struct A {};
+struct alignas(32) B : virtual A {
+  char c[32];
+};
+struct Pad {
+  char c[7];
+};
+struct C : B, Pad, virtual A {};
+
+struct X {
+  virtual A &f();
+};
+struct U {
+  virtual ~U();
+};
+C c;
+struct Y : U, X {
+  virtual B &f() override { return c; }
+};
+
+Y y;
+
+// FIXME: The return type should be  align 1 dereferenceable(1) %struct.A.8*
+// CHECK: define linkonce_odr nonnull align 32 dereferenceable(40) %struct.B.1* @_ZTchn8_v0_n24_N1Y1fEv(%struct.Y.5* nonnull dereferenceable(16) %this) unnamed_addr #1 comdat align 2 {

diff  --git a/clang/test/CodeGenCXX/thunk-wrong-this.cpp b/clang/test/CodeGenCXX/thunk-wrong-this.cpp
new file mode 100644
index 0000000000000..664163a3b9da5
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-wrong-this.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm -o - %s | FileCheck %s
+
+class Base1 {
+  virtual void Foo1();
+};
+
+class Base2 {
+  virtual void Foo2();
+};
+
+class alignas(16) Obj : public Base1, public Base2 {
+  void Foo1() override;
+  void Foo2() override;
+  ~Obj();
+};
+
+void Obj::Foo1() {}
+void Obj::Foo2() {}
+
+// CHECK: define dso_local void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull dereferenceable(16) %this) unnamed_addr #0 align 2 {
+
+// FIXME: the argument should be  %class.Base2.2* nonnull dereferenceable(8) %this
+// CHECK: define dso_local void @_ZThn8_N3Obj4Foo2Ev(%class.Obj.0* nonnull dereferenceable(16) %this) unnamed_addr #1 align 2 {
+
+// CHECK: tail call void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull dereferenceable(16) %2)


        


More information about the cfe-commits mailing list