[cfe-commits] r161236 - in /cfe/trunk:

David Blaikie dblaikie at gmail.com
Fri Aug 3 07:34:01 PDT 2012


 lib/AST/RecordLayoutBuilder.cpp

 test/CodeGenCXX/cxx11-vtable-key-function.cpp
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

Why can't the key function have a (non inline) = default definition?
What happens if the only non inline virtual functions are = defaulted?
From: Benjamin Kramer
Sent: 8/3/2012 1:42 AM
To: cfe-commits at cs.uiuc.edu
Subject: [cfe-commits] r161236 - in /cfe/trunk:
lib/AST/RecordLayoutBuilder.cpp
test/CodeGenCXX/cxx11-vtable-key-function.cpp
Author: d0k
Date: Fri Aug  3 03:39:58 2012
New Revision: 161236

URL: http://llvm.org/viewvc/llvm-project?rev=161236&view=rev
Log:
Fix failed to generate vtables in certain cases.

By C++ standard, the vtable should be generated if the first non-inline
virtual function is defined in the TU.  Current version of clang doesn't
generate vtable if the first virtual function is defaulted, because the
key function is regarded as the defaulted function.

Patch by Li Kan!

Added:
    cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp
Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=161236&r1=161235&r2=161236&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Aug  3 03:39:58 2012
@@ -2351,6 +2351,9 @@
     if (MD->hasInlineBody())
       continue;

+    if (!MD->isUserProvided())
+      continue;
+
     // We found it.
     return MD;
   }

Added: cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp?rev=161236&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/cxx11-vtable-key-function.cpp Fri Aug  3
03:39:58 2012
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o -
-std=c++11 | FileCheck %s
+// PR13424
+
+struct X {
+  virtual ~X() = default;
+  virtual void f();
+};
+
+void X::f() {}
+
+// CHECK: @_ZTV1X = unnamed_addr constant


_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list