Add a way to get the index of a method. Assert that we have the same index for now.

llvm-svn: 90533
This commit is contained in:
Anders Carlsson 2009-12-04 03:41:37 +00:00
parent b07567c315
commit e609636e0d
1 changed files with 10 additions and 5 deletions

View File

@ -90,13 +90,17 @@ private:
// Replace the old decl with the new decl. // Replace the old decl with the new decl.
Methods[Index] = GD; Methods[Index] = GD;
// Now remove the old decl from the method to index map.
MethodToIndexMap.erase(i);
// And add the new. // And add the new.
MethodToIndexMap[GD] = Index; MethodToIndexMap[GD] = Index;
} }
/// getIndex - Returns the index of the given method.
uint64_t getIndex(GlobalDecl GD) const {
assert(MethodToIndexMap.count(GD) && "Did not find method!");
return MethodToIndexMap.lookup(GD);
}
MethodsVectorTy::size_type size() const { MethodsVectorTy::size_type size() const {
return Methods.size(); return Methods.size();
} }
@ -106,7 +110,7 @@ private:
Methods.clear(); Methods.clear();
} }
GlobalDecl operator[](unsigned Index) const { GlobalDecl operator[](uint64_t Index) const {
return Methods[Index]; return Methods[Index];
} }
}; };
@ -751,9 +755,10 @@ bool VtableBuilder::OverrideMethod(GlobalDecl GD, llvm::Constant *m,
for (Index_t i = 0, e = submethods.size(); for (Index_t i = 0, e = submethods.size();
i != e; ++i) { i != e; ++i) {
// FIXME: begin_overridden_methods might be too lax, covariance */
if (submethods[i] != om) if (submethods[i] != om)
continue; continue;
assert(i == Methods.getIndex(OGD));
QualType ReturnType = QualType ReturnType =
MD->getType()->getAs<FunctionType>()->getResultType(); MD->getType()->getAs<FunctionType>()->getResultType();