[cfe-commits] r161236 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp test/CodeGenCXX/cxx11-vtable-key-function.cpp
Benjamin Kramer
benny.kra at googlemail.com
Fri Aug 3 01:39:59 PDT 2012
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
More information about the cfe-commits
mailing list