From 1b1a70f1725804fc1cd9cc490576791e01b01223 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Mon, 10 Apr 2017 06:14:09 +0000 Subject: [PATCH] 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() method to PDBSymbol that can shorten some usage patterns. llvm-svn: 299831 --- llvm/include/llvm/DebugInfo/PDB/IPDBSession.h | 7 ++++ llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h | 42 ++++++++++++++++++++++ llvm/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolCompiland.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h | 2 +- llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h | 8 ++--- llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h | 10 +++--- .../llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h | 2 +- llvm/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h | 2 +- llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h | 6 ++-- .../llvm/DebugInfo/PDB/PDBSymbolTypeArray.h | 8 ++--- .../llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h | 8 ++--- .../llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h | 2 +- .../include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h | 12 +++---- .../llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h | 4 +-- .../llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h | 6 ++-- .../llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h | 10 +++--- .../llvm/DebugInfo/PDB/PDBSymbolTypePointer.h | 6 ++-- .../llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h | 8 ++--- llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h | 8 ++--- .../llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h | 6 ++-- .../llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h | 2 +- llvm/lib/DebugInfo/PDB/PDBSymbol.cpp | 27 +++++++++++++- llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp | 4 ++- .../DebugInfo/PDB/PDBSymbolCompilandDetails.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp | 6 ++-- llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp | 10 ++---- llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp | 6 ++-- llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp | 11 ++---- llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp | 4 ++- .../lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp | 4 ++- .../lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp | 13 ++----- llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp | 6 ++-- llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp | 4 ++- .../lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp | 4 ++- llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp | 4 ++- .../llvm-pdbdump/PrettyClassDefinitionDumper.cpp | 10 +++--- llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp | 10 ++---- llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp | 2 -- llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp | 7 ++-- llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp | 11 +++--- 62 files changed, 229 insertions(+), 157 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h b/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h index 929c70a..64b7665 100644 --- a/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h +++ b/llvm/include/llvm/DebugInfo/PDB/IPDBSession.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_PDB_IPDBSESSION_H #define LLVM_DEBUGINFO_PDB_IPDBSESSION_H +#include "PDBSymbol.h" #include "PDBTypes.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" @@ -44,6 +45,12 @@ public: return std::unique_ptr(ConcreteSymbol); } + template <> + std::unique_ptr + getConcreteSymbolById(uint32_t SymbolId) const { + return getSymbolById(SymbolId); + } + virtual std::unique_ptr findSymbolByAddress(uint64_t Address, PDB_SymType Type) const = 0; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h index bf51188..e85d228 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -22,6 +22,23 @@ return RawSymbol->MethodName(); \ } +#define FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(ConcreteType, PrivateName, \ + PublicName) \ + auto PublicName##Id() const->decltype(RawSymbol->PrivateName##Id()) { \ + return RawSymbol->PrivateName##Id(); \ + } \ + std::unique_ptr PublicName() const { \ + uint32_t Id = PublicName##Id(); \ + return getConcreteSymbolByIdHelper(Id); \ + } + +#define FORWARD_SYMBOL_ID_METHOD_WITH_NAME(PrivateName, PublicName) \ + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbol, PrivateName, \ + PublicName) + +#define FORWARD_SYMBOL_ID_METHOD(MethodName) \ + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(MethodName, MethodName) + namespace llvm { class StringRef; @@ -29,6 +46,7 @@ class raw_ostream; namespace pdb { class IPDBRawSymbol; +class IPDBSession; #define DECLARE_PDB_SYMBOL_CONCRETE_TYPE(TagValue) \ static const PDB_SymType Tag = TagValue; \ @@ -57,6 +75,8 @@ public: /// override the behavior to only dump known fields. virtual void dump(PDBSymDumper &Dumper) const = 0; void defaultDump(raw_ostream &OS, int Indent) const; + void dumpProperties() const; + void dumpChildStats() const; PDB_SymType getSymTag() const; uint32_t getSymIndexId() const; @@ -66,6 +86,14 @@ public: return Enumerator->getNext(); } + template T *cast() { return llvm::dyn_cast(this); } + + template const T *cast() const { + return llvm::dyn_cast(this); + } + + std::unique_ptr clone() const; + template std::unique_ptr> findAllChildren() const { auto BaseIter = RawSymbol->findChildren(T::Tag); @@ -91,6 +119,20 @@ public: std::unique_ptr getChildStats(TagStats &Stats) const; protected: + std::unique_ptr getSymbolByIdHelper(uint32_t Id) const; + + template + std::unique_ptr getConcreteSymbolByIdHelper(uint32_t Id) const { + auto Sym = getSymbolByIdHelper(Id); + if (!Sym) + return nullptr; + ConcreteType *Result = Sym->cast(); + if (!Result) + return nullptr; + Sym.release(); + return std::unique_ptr(Result); + } + const IPDBSession &Session; const std::unique_ptr RawSymbol; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h index d0ff62c..d81da1e 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h @@ -30,7 +30,7 @@ public: FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h index f1983b3..26788017 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h @@ -29,7 +29,7 @@ public: void dump(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLibraryName) FORWARD_SYMBOL_METHOD(getName) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h index bb4a78f..dba50c4 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h @@ -46,7 +46,7 @@ public: FORWARD_SYMBOL_METHOD(isLTCG) FORWARD_SYMBOL_METHOD(isMSILNetmodule) FORWARD_SYMBOL_METHOD(getLanguage) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getPlatform) FORWARD_SYMBOL_METHOD(getSourceFileName) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h index a71a0ba..7868f04 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h @@ -26,7 +26,7 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) std::string getValue() const; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h index 36f32ab..ad4285d 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h @@ -26,8 +26,6 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Data) - std::unique_ptr getType() const; - void dump(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(getAccess) @@ -35,14 +33,14 @@ public: FORWARD_SYMBOL_METHOD(getAddressSection) FORWARD_SYMBOL_METHOD(getAddressTaken) FORWARD_SYMBOL_METHOD(getBitPosition) - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(isCompilerGenerated) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getDataKind) FORWARD_SYMBOL_METHOD(isAggregated) FORWARD_SYMBOL_METHOD(isSplitted) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(getOffset) @@ -50,7 +48,7 @@ public: FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) FORWARD_SYMBOL_METHOD(getSlot) FORWARD_SYMBOL_METHOD(getToken) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(getValue) FORWARD_SYMBOL_METHOD(getVirtualAddress) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h index 7170bcb..5686f87 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h @@ -11,6 +11,7 @@ #define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H #include "PDBSymbol.h" +#include "PDBSymbolTypeFunctionSig.h" #include "PDBTypes.h" namespace llvm { @@ -26,8 +27,6 @@ public: void dump(PDBSymDumper &Dumper) const override; - std::unique_ptr getSignature() const; - std::unique_ptr getClassParent() const; std::unique_ptr> getArguments() const; DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Function) @@ -35,7 +34,7 @@ public: FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(isCompilerGenerated) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) @@ -54,7 +53,7 @@ public: FORWARD_SYMBOL_METHOD(isNaked) FORWARD_SYMBOL_METHOD(isStatic) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocalBasePointerRegisterId) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(getName) @@ -67,7 +66,8 @@ public: FORWARD_SYMBOL_METHOD(isPureVirtual) FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) FORWARD_SYMBOL_METHOD(getToken) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType, + getSignature) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(getUndecoratedName) FORWARD_SYMBOL_METHOD(isVirtual) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h index 4643895..3341bd9 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h @@ -34,7 +34,7 @@ public: FORWARD_SYMBOL_METHOD(hasFarReturn) FORWARD_SYMBOL_METHOD(hasInterruptReturn) FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h index c2e3dd3..6729838 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h @@ -33,7 +33,7 @@ public: FORWARD_SYMBOL_METHOD(hasFarReturn) FORWARD_SYMBOL_METHOD(hasInterruptReturn) FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h index 3aeae10..c2b1c28 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h @@ -32,7 +32,7 @@ public: FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) FORWARD_SYMBOL_METHOD(hasFarReturn) FORWARD_SYMBOL_METHOD(hasInterruptReturn) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h index be07344..c9e6ee6 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h @@ -32,7 +32,7 @@ public: FORWARD_SYMBOL_METHOD(isCode) FORWARD_SYMBOL_METHOD(isFunction) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(isManagedCode) FORWARD_SYMBOL_METHOD(isMSILCode) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h index 63f7a09f..614fad8 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h @@ -30,12 +30,12 @@ public: FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(isIntroVirtualFunction) FORWARD_SYMBOL_METHOD(isStatic) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(isPureVirtual) FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) @@ -44,7 +44,7 @@ public: FORWARD_SYMBOL_METHOD(getTargetVirtualAddress) FORWARD_SYMBOL_METHOD(getTargetSection) FORWARD_SYMBOL_METHOD(getThunkOrdinal) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVirtual) FORWARD_SYMBOL_METHOD(getVirtualAddress) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h index 57db036..b70d0e8 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h @@ -25,17 +25,15 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType) - std::unique_ptr getElementType() const; - void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getArrayIndexTypeId) + FORWARD_SYMBOL_ID_METHOD(getArrayIndexType) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getCount) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getRank) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getElementType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h index aaa3ab7..0924efb 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h @@ -28,7 +28,7 @@ public: void dump(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(getAccess) - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(hasConstructor) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(hasAssignmentOperator) @@ -36,14 +36,14 @@ public: FORWARD_SYMBOL_METHOD(hasNestedTypes) FORWARD_SYMBOL_METHOD(isIndirectVirtualBaseClass) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(isNested) FORWARD_SYMBOL_METHOD(getOffset) FORWARD_SYMBOL_METHOD(hasOverloadedOperator) FORWARD_SYMBOL_METHOD(isPacked) FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getType) FORWARD_SYMBOL_METHOD(getUdtKind) FORWARD_SYMBOL_METHOD(isUnalignedType) @@ -51,7 +51,7 @@ public: FORWARD_SYMBOL_METHOD(getVirtualBaseDispIndex) FORWARD_SYMBOL_METHOD(getVirtualBasePointerOffset) // FORWARD_SYMBOL_METHOD(getVirtualBaseTableType) - FORWARD_SYMBOL_METHOD(getVirtualTableShapeId) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h index c8f59f1..5b1863c 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h @@ -30,7 +30,7 @@ public: FORWARD_SYMBOL_METHOD(getBuiltinType) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h index ade2887..c5ae3c5 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h @@ -11,6 +11,7 @@ #define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H #include "PDBSymbol.h" +#include "PDBSymbolTypeBuiltin.h" #include "PDBTypes.h" namespace llvm { @@ -27,25 +28,22 @@ public: void dump(PDBSymDumper &Dumper) const override; - std::unique_ptr getClassParent() const; - std::unique_ptr getUnderlyingType() const; - FORWARD_SYMBOL_METHOD(getBuiltinType) - FORWARD_SYMBOL_METHOD(getClassParentId) - FORWARD_SYMBOL_METHOD(getUnmodifiedTypeId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(hasConstructor) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(hasAssignmentOperator) FORWARD_SYMBOL_METHOD(hasCastOperator) FORWARD_SYMBOL_METHOD(hasNestedTypes) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(isNested) FORWARD_SYMBOL_METHOD(hasOverloadedOperator) FORWARD_SYMBOL_METHOD(isPacked) FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeBuiltin, getType, + getUnderlyingType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h index 196d149..24c1312 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h @@ -27,9 +27,9 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getType) }; } // namespace llvm diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h index 5561341..3855999 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h @@ -27,9 +27,9 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getClassParentId) - FORWARD_SYMBOL_METHOD(getLexicalParentId) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_ID_METHOD(getType) }; } // namespace llvm diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h index 516011f..a716cd3 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h @@ -25,22 +25,20 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionSig) - std::unique_ptr getReturnType() const; std::unique_ptr getArguments() const; - std::unique_ptr getClassParent() const; void dump(PDBSymDumper &Dumper) const override; void dumpArgList(raw_ostream &OS) const; FORWARD_SYMBOL_METHOD(getCallingConvention) - FORWARD_SYMBOL_METHOD(getClassParentId) - FORWARD_SYMBOL_METHOD(getUnmodifiedTypeId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getCount) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) // FORWARD_SYMBOL_METHOD(getObjectPointerType) FORWARD_SYMBOL_METHOD(getThisAdjust) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getReturnType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h index 7a57272..47cfc8a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h @@ -25,15 +25,13 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType) - std::unique_ptr getPointeeType() const; - void dump(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(isReference) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getPointeeType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h index 5ed4f8d..16c1d1b 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h @@ -28,24 +28,24 @@ public: void dump(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(getBuiltinType) - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(hasConstructor) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(hasAssignmentOperator) FORWARD_SYMBOL_METHOD(hasCastOperator) FORWARD_SYMBOL_METHOD(hasNestedTypes) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(isNested) FORWARD_SYMBOL_METHOD(hasOverloadedOperator) FORWARD_SYMBOL_METHOD(isPacked) FORWARD_SYMBOL_METHOD(isReference) FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getType) FORWARD_SYMBOL_METHOD(getUdtKind) FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(getVirtualTableShapeId) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h index 1874dfe..47a4525 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h @@ -27,15 +27,15 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getClassParentId) - FORWARD_SYMBOL_METHOD(getUnmodifiedTypeId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) FORWARD_SYMBOL_METHOD(hasConstructor) FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(hasAssignmentOperator) FORWARD_SYMBOL_METHOD(hasCastOperator) FORWARD_SYMBOL_METHOD(hasNestedTypes) FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(isNested) FORWARD_SYMBOL_METHOD(hasOverloadedOperator) @@ -43,7 +43,7 @@ public: FORWARD_SYMBOL_METHOD(isScoped) FORWARD_SYMBOL_METHOD(getUdtKind) FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(getVirtualTableShapeId) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) FORWARD_SYMBOL_METHOD(isVolatileType) }; } diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h index baf7ab7..17612ff 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h @@ -27,10 +27,10 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getClassParentId) + FORWARD_SYMBOL_ID_METHOD(getClassParent) FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getLexicalParentId) - FORWARD_SYMBOL_METHOD(getTypeId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_ID_METHOD(getType) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h index 431fc1a..8acaabe 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h @@ -29,7 +29,7 @@ public: FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getCount) - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(isUnalignedType) FORWARD_SYMBOL_METHOD(isVolatileType) }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h index a273fe1..70fbd5b 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h @@ -27,7 +27,7 @@ public: void dump(PDBSymDumper &Dumper) const override; - FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) FORWARD_SYMBOL_METHOD(getName) }; diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp index 633e11a..2c8438f 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" @@ -100,7 +101,7 @@ PDBSymbol::create(const IPDBSession &PDBSession, } #define TRY_DUMP_TYPE(Type) \ - if (const Type *DerivedThis = dyn_cast(this)) \ + if (const Type *DerivedThis = this->cast()) \ Dumper.dump(OS, Indent, *DerivedThis); #define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper) @@ -109,6 +110,26 @@ void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const { RawSymbol->dump(OS, Indent); } +void PDBSymbol::dumpProperties() const { + outs() << "\n"; + defaultDump(outs(), 0); + outs().flush(); +} + +void PDBSymbol::dumpChildStats() const { + TagStats Stats; + getChildStats(Stats); + outs() << "\n"; + for (auto &Stat : Stats) { + outs() << Stat.first << ": " << Stat.second << "\n"; + } + outs().flush(); +} + +std::unique_ptr PDBSymbol::clone() const { + return Session.getSymbolById(getSymIndexId()); +} + PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); } uint32_t PDBSymbol::getSymIndexId() const { return RawSymbol->getSymIndexId(); } @@ -148,3 +169,7 @@ PDBSymbol::getChildStats(TagStats &Stats) const { Result->reset(); return Result; } + +std::unique_ptr PDBSymbol::getSymbolByIdHelper(uint32_t Id) const { + return Session.getSymbolById(Id); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp index cdb167b..3648272 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp @@ -18,7 +18,9 @@ using namespace llvm::pdb; PDBSymbolAnnotation::PDBSymbolAnnotation(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Annotation); +} void PDBSymbolAnnotation::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp index fd5dc942..7385d3b 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp @@ -19,6 +19,8 @@ using namespace llvm::pdb; PDBSymbolBlock::PDBSymbolBlock(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Block); +} void PDBSymbolBlock::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp index ebff088..854cf42 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Compiland); +} void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp index 6dbd522..e08450e 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolCompilandDetails::PDBSymbolCompilandDetails( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::CompilandDetails); +} void PDBSymbolCompilandDetails::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp index 9c7f0b1..2f1c436 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp @@ -20,7 +20,9 @@ using namespace llvm::pdb; PDBSymbolCompilandEnv::PDBSymbolCompilandEnv( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::CompilandEnv); +} std::string PDBSymbolCompilandEnv::getValue() const { Variant Value = RawSymbol->getValue(); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp index 0ea387a..9ec20bb 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp @@ -20,7 +20,9 @@ using namespace llvm::pdb; PDBSymbolCustom::PDBSymbolCustom(const IPDBSession &PDBSession, std::unique_ptr CustomSymbol) - : PDBSymbol(PDBSession, std::move(CustomSymbol)) {} + : PDBSymbol(PDBSession, std::move(CustomSymbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Custom); +} void PDBSymbolCustom::getDataBytes(llvm::SmallVector &bytes) { RawSymbol->getDataBytes(bytes); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp index 62bb6f3..6002668 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp @@ -19,10 +19,8 @@ using namespace llvm::pdb; PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession, std::unique_ptr DataSymbol) - : PDBSymbol(PDBSession, std::move(DataSymbol)) {} - -std::unique_ptr PDBSymbolData::getType() const { - return Session.getSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(DataSymbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Data); } void PDBSymbolData::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp index 60101c1..b9fcac7 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp @@ -18,6 +18,8 @@ using namespace llvm::pdb; PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Exe); +} void PDBSymbolExe::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp index 35251c0..3c0bd25 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp @@ -85,10 +85,8 @@ private: PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} - -std::unique_ptr PDBSymbolFunc::getSignature() const { - return Session.getConcreteSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Function); } std::unique_ptr> @@ -96,8 +94,4 @@ PDBSymbolFunc::getArguments() const { return llvm::make_unique(Session, *this); } -std::unique_ptr PDBSymbolFunc::getClassParent() const { - return Session.getConcreteSymbolById(getClassParentId()); -} - void PDBSymbolFunc::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp index 77e996f..482c95e 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolFuncDebugEnd::PDBSymbolFuncDebugEnd( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::FuncDebugEnd); +} void PDBSymbolFuncDebugEnd::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp index 9c65387..ae23c76 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolFuncDebugStart::PDBSymbolFuncDebugStart( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::FuncDebugStart); +} void PDBSymbolFuncDebugStart::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp index d2cfd11..a67a20d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp @@ -18,6 +18,8 @@ using namespace llvm::pdb; PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Label); +} void PDBSymbolLabel::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp index 97d6687..87bb404 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolPublicSymbol::PDBSymbolPublicSymbol( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::PublicSymbol); +} void PDBSymbolPublicSymbol::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp index ef8897d..b264819 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp @@ -18,6 +18,8 @@ using namespace llvm::pdb; PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Thunk); +} void PDBSymbolThunk::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp index c010cc5..cf9b6fe 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp @@ -19,10 +19,8 @@ using namespace llvm::pdb; PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} - -std::unique_ptr PDBSymbolTypeArray::getElementType() const { - return Session.getSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::ArrayType); } void PDBSymbolTypeArray::dump(PDBSymDumper &Dumper) const { diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp index 382c397b..0ee18d4 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolTypeBaseClass::PDBSymbolTypeBaseClass( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::BaseClass); +} void PDBSymbolTypeBaseClass::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp index e5d65bf..0bf563a 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp @@ -18,7 +18,9 @@ using namespace llvm::pdb; PDBSymbolTypeBuiltin::PDBSymbolTypeBuiltin( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::BuiltinType); +} void PDBSymbolTypeBuiltin::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp index 1d80c97..f617d8d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolTypeCustom::PDBSymbolTypeCustom(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::CustomType); +} void PDBSymbolTypeCustom::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp index 535d97d..68ba87c 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp @@ -20,7 +20,9 @@ using namespace llvm::pdb; PDBSymbolTypeDimension::PDBSymbolTypeDimension( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Dimension); +} void PDBSymbolTypeDimension::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp index 788f2b7..2addea0 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp @@ -21,15 +21,8 @@ using namespace llvm::pdb; PDBSymbolTypeEnum::PDBSymbolTypeEnum(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} - -std::unique_ptr PDBSymbolTypeEnum::getClassParent() const { - return Session.getConcreteSymbolById(getClassParentId()); -} - -std::unique_ptr -PDBSymbolTypeEnum::getUnderlyingType() const { - return Session.getConcreteSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Enum); } void PDBSymbolTypeEnum::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp index 5831bae..ec27985 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolTypeFriend::PDBSymbolTypeFriend(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Friend); +} void PDBSymbolTypeFriend::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp index c6f586d..4d5cd63 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp @@ -18,7 +18,9 @@ using namespace llvm::pdb; PDBSymbolTypeFunctionArg::PDBSymbolTypeFunctionArg( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::FunctionArg); +} void PDBSymbolTypeFunctionArg::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp index 057ae26..1d53c7d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp @@ -68,10 +68,8 @@ private: PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} - -std::unique_ptr PDBSymbolTypeFunctionSig::getReturnType() const { - return Session.getSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::FunctionSig); } std::unique_ptr @@ -79,13 +77,6 @@ PDBSymbolTypeFunctionSig::getArguments() const { return llvm::make_unique(Session, *this); } -std::unique_ptr PDBSymbolTypeFunctionSig::getClassParent() const { - uint32_t ClassId = getClassParentId(); - if (ClassId == 0) - return nullptr; - return Session.getSymbolById(ClassId); -} - void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp index 072d2cf..86e0ec4 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolTypeManaged::PDBSymbolTypeManaged( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::ManagedType); +} void PDBSymbolTypeManaged::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp index 6997714..f93b12d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp @@ -19,10 +19,8 @@ using namespace llvm::pdb; PDBSymbolTypePointer::PDBSymbolTypePointer( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} - -std::unique_ptr PDBSymbolTypePointer::getPointeeType() const { - return Session.getSymbolById(getTypeId()); + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::PointerType); } void PDBSymbolTypePointer::dump(PDBSymDumper &Dumper) const { diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp index 0f283b9..102b540 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp @@ -18,7 +18,9 @@ using namespace llvm::pdb; PDBSymbolTypeTypedef::PDBSymbolTypeTypedef( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::Typedef); +} void PDBSymbolTypeTypedef::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp index c71838c..4a9a9ed 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp @@ -18,6 +18,8 @@ using namespace llvm::pdb; PDBSymbolTypeUDT::PDBSymbolTypeUDT(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::UDT); +} void PDBSymbolTypeUDT::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp index 6b76db5..9a21855 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp @@ -18,7 +18,9 @@ using namespace llvm::pdb; PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::VTable); +} void PDBSymbolTypeVTable::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp index ef509d6..a516a4d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolTypeVTableShape::PDBSymbolTypeVTableShape( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::VTableShape); +} void PDBSymbolTypeVTableShape::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp index 6a62d55..020aec9 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp @@ -19,7 +19,9 @@ using namespace llvm::pdb; PDBSymbolUsingNamespace::PDBSymbolUsingNamespace( const IPDBSession &PDBSession, std::unique_ptr Symbol) - : PDBSymbol(PDBSession, std::move(Symbol)) {} + : PDBSymbol(PDBSession, std::move(Symbol)) { + assert(RawSymbol->getSymTag() == PDB_SymType::UsingNamespace); +} void PDBSymbolUsingNamespace::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); diff --git a/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp index 333313e..07e1662 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(Child.get())) { + if (auto Data = Child->cast()) { 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(Child.get())) { + if (auto Func = Child->cast()) { if (Func->isCompilerGenerated() && opts::pretty::ExcludeCompilerGenerated) continue; diff --git a/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp index 2f6ca89..0e0da02 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(PointeeType.get())) { + if (auto FuncSig = PointeeType->cast()) { 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 88148fb..023806c 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 c458755..861f7e2 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(PointeeType.get())) { + auto PointeeType = Symbol.getPointeeType(); + if (auto FuncSig = PointeeType->cast()) { 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 e1469186..c565fcf 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(PointeeType.get())) { + if (auto Func = PointeeType->cast()) { 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(&Type)) { + if (auto *ArrayType = Type.cast()) { std::string IndexSpec; raw_string_ostream IndexStream(IndexSpec); std::unique_ptr ElementType = ArrayType->getElementType(); - while (auto NestedArray = dyn_cast(ElementType.get())) { + while (auto NestedArray = ElementType->cast()) { 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(&Type)) { + if (auto *PointerType = Type.cast()) { auto PointeeType = PointerType->getPointeeType(); - if (auto *FunctionSig = - dyn_cast(PointeeType.get())) { + if (auto *FunctionSig = PointeeType->cast()) { FunctionDumper Dumper(Printer); FunctionDumper::PointerType PT = FunctionDumper::PointerType::Pointer; if (PointerType->isReference()) -- 2.7.4