[cfe-commits] r103763 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/key-function-vtable.cpp

Douglas Gregor dgregor at apple.com
Thu May 13 21:08:48 PDT 2010


Author: dgregor
Date: Thu May 13 23:08:48 2010
New Revision: 103763

URL: http://llvm.org/viewvc/llvm-project?rev=103763&view=rev
Log:
A vtable is used if the key function is defined... even if that key
function's definition is an out-of-class definition marked
"inline". Fixes an assertion in WebKit.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CodeGenCXX/key-function-vtable.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=103763&r1=103762&r2=103763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu May 13 23:08:48 2010
@@ -6066,8 +6066,7 @@
     if (const CXXMethodDecl *KeyFunction
                              = Context.getKeyFunction(DynamicClasses[I])) {
       const FunctionDecl *Definition = 0;
-      if (KeyFunction->getBody(Definition) && !Definition->isInlined() &&
-          !Definition->isImplicit())
+      if (KeyFunction->getBody(Definition))
         MarkVTableUsed(Definition->getLocation(), DynamicClasses[I], true);
     }
   }

Modified: cfe/trunk/test/CodeGenCXX/key-function-vtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/key-function-vtable.cpp?rev=103763&r1=103762&r2=103763&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/key-function-vtable.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/key-function-vtable.cpp Thu May 13 23:08:48 2010
@@ -32,11 +32,20 @@
 }
 testg *testgvar = new testg;
 
+struct X0 { virtual ~X0(); };
+struct X1 : X0 {
+  virtual void f();
+};
+
+inline void X1::f() { }
+
+void use_X1(X1 *x1) { x1->f(); }
+
 // FIXME: The checks are extremely difficult to get right when the globals
 // aren't alphabetized
+// CHECK: @_ZTV2X1 = weak_odr constant
 // CHECK: @_ZTV5testa = constant [3 x i8*] [i8* null
 // CHECK: @_ZTV5testc = weak_odr constant [3 x i8*] [i8* null
 // CHECK: @_ZTVN12_GLOBAL__N_15testgE = internal constant [3 x i8*] [i8* null
 // CHECK: @_ZTV5teste = weak_odr constant [3 x i8*] [i8* null
 // CHECK: @_ZTV5testb = weak_odr constant [3 x i8*] [i8* null
-





More information about the cfe-commits mailing list