[cfe-commits] r91411 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/virt-call-offsets.cpp
Eli Friedman
eli.friedman at gmail.com
Mon Dec 14 19:31:17 PST 2009
Author: efriedma
Date: Mon Dec 14 21:31:17 2009
New Revision: 91411
URL: http://llvm.org/viewvc/llvm-project?rev=91411&view=rev
Log:
Fix a small bug in ComputeMethodVtableIndices.
Added:
cfe/trunk/test/CodeGenCXX/virt-call-offsets.cpp
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=91411&r1=91410&r2=91411&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Mon Dec 14 21:31:17 2009
@@ -952,7 +952,15 @@
// we need to start counting at the end of the primary base's vtable.
CurrentIndex = getNumVirtualFunctionPointers(PrimaryBase);
}
-
+
+ // Collect all the primary bases, so we can check whether methods override
+ // a method from the base.
+ llvm::SmallPtrSet<const CXXRecordDecl *, 5> PrimaryBases;
+ for (ASTRecordLayout::primary_base_info_iterator
+ I = Layout.primary_base_begin(), E = Layout.primary_base_end();
+ I != E; ++I)
+ PrimaryBases.insert((*I).getBase());
+
const CXXDestructorDecl *ImplicitVirtualDtor = 0;
for (CXXRecordDecl::method_iterator i = RD->method_begin(),
@@ -973,7 +981,7 @@
assert(OverriddenMD->isCanonicalDecl() &&
"Should have the canonical decl of the overridden RD!");
- if (OverriddenRD == PrimaryBase) {
+ if (PrimaryBases.count(OverriddenRD)) {
// Check if converting from the return type of the method to the
// return type of the overridden method requires conversion.
QualType ReturnType =
Added: cfe/trunk/test/CodeGenCXX/virt-call-offsets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt-call-offsets.cpp?rev=91411&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt-call-offsets.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/virt-call-offsets.cpp Mon Dec 14 21:31:17 2009
@@ -0,0 +1,8 @@
+// RUN: clang -cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A { virtual void a(); };
+struct B : A {};
+struct C : B { virtual void a(); };
+void (C::*x)() = &C::a;
+
+// CHECK: @x = global %0 { i{{[0-9]+}} 1, i{{[0-9]+}} 0 }
More information about the cfe-commits
mailing list