Add concrete type overloads to PDBSymbol::findChildren().

Frequently you only want to iterate over children of a specific
type (e.g. functions).  Previously you would get back a generic
interface that allowed iteration over the base symbol type,
which you would have to dyn_cast<> each one of.  With this patch,
we allow the user to specify the concrete type as a template
parameter, and it will return an iterator which returns instances
of the concrete type directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228960 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2015-02-12 21:09:24 +00:00
parent 36068aae42
commit 13a819cbad
39 changed files with 167 additions and 161 deletions

View File

@@ -27,35 +27,21 @@ void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
if (Level == PDB_DumpLevel::Compact) {
uint32_t FuncStart = getRelativeVirtualAddress();
uint32_t FuncEnd = FuncStart + getLength();
auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd);
OS << stream_indent(Indent);
OS << "[" << format_hex(FuncStart, 8);
if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) {
if (auto StartSym = DebugStartEnum->getNext()) {
auto DebugStart = dyn_cast<PDBSymbolFuncDebugStart>(StartSym.get());
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
}
}
if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
OS << " - " << format_hex(FuncEnd, 8);
if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) {
if (auto DebugEndSym = DebugEndEnum->getNext()) {
auto DebugEnd = dyn_cast<PDBSymbolFuncDebugEnd>(DebugEndSym.get());
if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
}
}
OS << "] ";
PDB_RegisterId Reg = getLocalBasePointerRegisterId();
if (Reg == PDB_RegisterId::VFrame)
OS << "(VFrame)";
else if (hasFramePointer()) {
if (Reg == PDB_RegisterId::EBP)
OS << "(EBP)";
else
OS << "(" << (int)Reg << ")";
} else {
else if (hasFramePointer())
OS << "(" << Reg << ")";
else
OS << "(FPO)";
}
OS << " " << getName() << "\n";
}
OS.flush();
}