[PATCH] D27994: Make two vtable tests tolerate C++11

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 20 11:38:40 PST 2016


probinson created this revision.
probinson added a reviewer: rjmccall.
probinson added a subscriber: cfe-commits.

In C++11, we don't emit vtables as eagerly as we do for C++03, so fiddle the tests to emit them when the test expects them.

In the C++11 test cleanup project, we're commonly making the tests run in both dialects and sometimes with no dialect specified (as Clang's default will presumably advance to C++14/17 at some point).  I didn't do that for vtable-layout.cpp because it runs FileCheck 46 times, and replicating that really seemed like too much.
If it also seems like too much for vtable-linkage.cpp, the easy thing is to force it to C++03.


https://reviews.llvm.org/D27994

Files:
  test/CodeGenCXX/vtable-layout.cpp
  test/CodeGenCXX/vtable-linkage.cpp


Index: test/CodeGenCXX/vtable-linkage.cpp
===================================================================
--- test/CodeGenCXX/vtable-linkage.cpp
+++ test/CodeGenCXX/vtable-linkage.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template<typename T>
 struct E {
Index: test/CodeGenCXX/vtable-layout.cpp
===================================================================
--- test/CodeGenCXX/vtable-layout.cpp
+++ test/CodeGenCXX/vtable-layout.cpp
@@ -1919,6 +1919,8 @@
     virtual int i(int);
     virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27994.82126.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161220/43b67cf9/attachment-0001.bin>


More information about the cfe-commits mailing list