diff options
author | Zachary Turner <zturner@google.com> | 2017-04-10 06:14:09 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-04-10 06:14:09 +0000 |
commit | 1b1a70f1725804fc1cd9cc490576791e01b01223 (patch) | |
tree | b72cb3cb9d87ff84658ff8c7b4d6561776923ef0 /llvm/tools | |
parent | 34888c08bc72813f959ce8f3bee85d313bebcf69 (diff) | |
download | bcm5719-llvm-1b1a70f1725804fc1cd9cc490576791e01b01223.tar.gz bcm5719-llvm-1b1a70f1725804fc1cd9cc490576791e01b01223.zip |
General usability improvements to generic PDB library.
1. Added some asserts to make sure concrete symbol types don't
get constructed with RawSymbols that have an incompatible
SymTag enum value.
2. Added new forwarding macros that auto-define an Id/Sym method
pair whenever there is a method that returns a SymIndexId.
Previously we would just provide one method that returned only
the SymIndexId and it was up to the caller to use the Session
object to get a pointer to the symbol. Now we automatically
get both the method that returns the Id, as well as a method
that returns the pointer directly with just one macro.
3. Added some methods for dumping straight to stdout that can
be used from inside the debugger for diagnostics during a
debug session.
4. Added a clone() method and a cast<T>() method to PDBSymbol
that can shorten some usage patterns.
llvm-svn: 299831
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp | 7 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp | 11 |
5 files changed, 14 insertions, 26 deletions
diff --git a/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp index 333313ee7ef..07e1662c47b 100644 --- a/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp @@ -70,26 +70,24 @@ void ClassDefinitionDumper::start(const PDBSymbolTypeUDT &Class) { if (opts::pretty::ClassFormat == opts::pretty::ClassDefinitionFormat::LayoutOnly) { - if (auto Data = dyn_cast<PDBSymbolData>(Child.get())) { + if (auto Data = Child->cast<PDBSymbolData>()) { switch (Data->getLocationType()) { case PDB_LocType::ThisRel: case PDB_LocType::BitField: break; default: // All other types of data field do not occupy any storage (e.g. are - // const), - // so in layout mode we skip them. + // const), so in layout mode we skip them. continue; } } else { // Only data symbols affect record layout, so skip any non-data symbols - // if - // we're in record layout mode. + // if we're in record layout mode. continue; } } - if (auto Func = dyn_cast<PDBSymbolFunc>(Child.get())) { + if (auto Func = Child->cast<PDBSymbolFunc>()) { if (Func->isCompilerGenerated() && opts::pretty::ExcludeCompilerGenerated) continue; diff --git a/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp index 2f6ca894fad..0e0da026e56 100644 --- a/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp @@ -195,10 +195,7 @@ void FunctionDumper::start(const PDBSymbolFunc &Symbol, PointerType Pointer) { } void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol) { - uint32_t ElementTypeId = Symbol.getTypeId(); - auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId); - if (!ElementType) - return; + auto ElementType = Symbol.getElementType(); ElementType->dump(*this); Printer << "["; @@ -232,12 +229,11 @@ void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol) { } void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol) { - uint32_t PointeeId = Symbol.getTypeId(); - auto PointeeType = Symbol.getSession().getSymbolById(PointeeId); + auto PointeeType = Symbol.getPointeeType(); if (!PointeeType) return; - if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) { + if (auto FuncSig = PointeeType->cast<PDBSymbolTypeFunctionSig>()) { FunctionDumper NestedDumper(Printer); PointerType Pointer = Symbol.isReference() ? PointerType::Reference : PointerType::Pointer; diff --git a/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp index 88148fb2074..023806c7cb1 100644 --- a/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp @@ -66,8 +66,6 @@ void TypeDumper::start(const PDBSymbolExe &Exe) { void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) { assert(opts::pretty::Enums); - if (Symbol.getUnmodifiedTypeId() != 0) - return; if (Printer.IsTypeExcluded(Symbol.getName())) return; // Dump member enums when dumping their class definition. diff --git a/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp index c458755cb78..861f7e28b38 100644 --- a/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp @@ -53,11 +53,8 @@ void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) { WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; if (Symbol.isVolatileType()) WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; - uint32_t PointeeId = Symbol.getTypeId(); - auto PointeeType = Symbol.getSession().getSymbolById(PointeeId); - if (!PointeeType) - return; - if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) { + auto PointeeType = Symbol.getPointeeType(); + if (auto FuncSig = PointeeType->cast<PDBSymbolTypeFunctionSig>()) { FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer; if (Symbol.isReference()) Pointer = FunctionDumper::PointerType::Reference; diff --git a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp index e1469186ad8..c565fcf0dd8 100644 --- a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp @@ -101,7 +101,7 @@ void VariableDumper::dump(const PDBSymbolTypePointer &Symbol) { if (!PointeeType) return; - if (auto Func = dyn_cast<PDBSymbolFunc>(PointeeType.get())) { + if (auto Func = PointeeType->cast<PDBSymbolFunc>()) { FunctionDumper NestedDumper(Printer); FunctionDumper::PointerType Pointer = Symbol.isReference() ? FunctionDumper::PointerType::Reference @@ -128,11 +128,11 @@ void VariableDumper::dump(const PDBSymbolTypeUDT &Symbol) { void VariableDumper::dumpSymbolTypeAndName(const PDBSymbol &Type, StringRef Name) { - if (auto *ArrayType = dyn_cast<PDBSymbolTypeArray>(&Type)) { + if (auto *ArrayType = Type.cast<PDBSymbolTypeArray>()) { std::string IndexSpec; raw_string_ostream IndexStream(IndexSpec); std::unique_ptr<PDBSymbol> ElementType = ArrayType->getElementType(); - while (auto NestedArray = dyn_cast<PDBSymbolTypeArray>(ElementType.get())) { + while (auto NestedArray = ElementType->cast<PDBSymbolTypeArray>()) { IndexStream << "["; IndexStream << NestedArray->getCount(); IndexStream << "]"; @@ -154,10 +154,9 @@ bool VariableDumper::tryDumpFunctionPointer(const PDBSymbol &Type, StringRef Name) { // Function pointers come across as pointers to function signatures. But the // signature carries no name, so we have to handle this case separately. - if (auto *PointerType = dyn_cast<PDBSymbolTypePointer>(&Type)) { + if (auto *PointerType = Type.cast<PDBSymbolTypePointer>()) { auto PointeeType = PointerType->getPointeeType(); - if (auto *FunctionSig = - dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) { + if (auto *FunctionSig = PointeeType->cast<PDBSymbolTypeFunctionSig>()) { FunctionDumper Dumper(Printer); FunctionDumper::PointerType PT = FunctionDumper::PointerType::Pointer; if (PointerType->isReference()) |