forked from OSchip/llvm-project
Make -fdump-vtable-layouts also dump vtable indices for all virtual member functions in the class.
llvm-svn: 129250
This commit is contained in:
parent
9137ee85de
commit
68aad14dd3
|
@ -2254,9 +2254,51 @@ void VTableBuilder::dumpLayout(llvm::raw_ostream& Out) {
|
|||
}
|
||||
|
||||
Out << '\n';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the vtable indices for all the member functions.
|
||||
// Store them in a map keyed by the index so we'll get a sorted table.
|
||||
std::map<uint64_t, std::string> IndicesMap;
|
||||
|
||||
for (CXXRecordDecl::method_iterator i = MostDerivedClass->method_begin(),
|
||||
e = MostDerivedClass->method_end(); i != e; ++i) {
|
||||
const CXXMethodDecl *MD = *i;
|
||||
|
||||
// We only want virtual member functions.
|
||||
if (!MD->isVirtual())
|
||||
continue;
|
||||
|
||||
std::string MethodName =
|
||||
PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
|
||||
MD);
|
||||
|
||||
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
|
||||
IndicesMap[VTables.getMethodVTableIndex(GlobalDecl(DD, Dtor_Complete))] =
|
||||
MethodName + " [complete]";
|
||||
IndicesMap[VTables.getMethodVTableIndex(GlobalDecl(DD, Dtor_Deleting))] =
|
||||
MethodName + " [deleting]";
|
||||
} else {
|
||||
IndicesMap[VTables.getMethodVTableIndex(MD)] = MethodName;
|
||||
}
|
||||
}
|
||||
|
||||
// Print the vtable indices for all the member functions.
|
||||
if (!IndicesMap.empty()) {
|
||||
Out << "VTable indices for '";
|
||||
Out << MostDerivedClass->getQualifiedNameAsString();
|
||||
Out << "' (" << IndicesMap.size() << " entries).\n";
|
||||
|
||||
for (std::map<uint64_t, std::string>::const_iterator I = IndicesMap.begin(),
|
||||
E = IndicesMap.end(); I != E; ++I) {
|
||||
uint64_t VTableIndex = I->first;
|
||||
const std::string &MethodName = I->second;
|
||||
|
||||
Out << llvm::format(" %4u | ", VTableIndex) << MethodName << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
Out << '\n';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue