summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-09-14 21:03:57 +0000
committerZachary Turner <zturner@google.com>2018-09-14 21:03:57 +0000
commit4d68951e6d2c1062b97fa002fbe36db13e7f9888 (patch)
treedf8f4e2a2a017910afcac1fe27c6ae906f84bc52 /llvm/lib/DebugInfo/PDB/Native
parent6a14325dffb7a0607e5b3c75d93a837cadad54b4 (diff)
downloadbcm5719-llvm-4d68951e6d2c1062b97fa002fbe36db13e7f9888.tar.gz
bcm5719-llvm-4d68951e6d2c1062b97fa002fbe36db13e7f9888.zip
[PDB] Refactor a little of the Symbol creation code.
Eventually we need to be able to support nested types, which don't have an associated CVType record. To handle this, remove the CVType from all of the record classes, and instead store the deserialized record. Then move the deserialization up to the thing that creates the type. This actually makes error handling better anyway as we can return an invalid symbol instead of asserting false. llvm-svn: 342284
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp9
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp15
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp20
3 files changed, 16 insertions, 28 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
index 6c1d4ccd09f..e83cbfc803a 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
@@ -24,12 +24,9 @@ using namespace llvm::codeview;
using namespace llvm::pdb;
NativeTypeEnum::NativeTypeEnum(NativeSession &Session, SymIndexId Id,
- const codeview::CVType &CVT)
- : NativeRawSymbol(Session, PDB_SymType::Enum, Id), CV(CVT),
- Record(codeview::TypeRecordKind::Enum) {
- assert(CV.kind() == codeview::TypeLeafKind::LF_ENUM);
- cantFail(visitTypeRecord(CV, *this));
-}
+ TypeIndex Index, EnumRecord Record)
+ : NativeRawSymbol(Session, PDB_SymType::Enum, Id), Index(Index),
+ Record(std::move(Record)) {}
NativeTypeEnum::~NativeTypeEnum() {}
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp
index 3e5140c4bd6..81fe004b3fd 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp
@@ -18,17 +18,10 @@ using namespace llvm::codeview;
using namespace llvm::pdb;
NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
- codeview::CVType CVT)
- : NativeRawSymbol(Session, PDB_SymType::PointerType, Id),
- Record(TypeRecordKind::Pointer) {
- assert(CVT.kind() == TypeLeafKind::LF_POINTER);
- cantFail(TypeDeserializer::deserializeAs<PointerRecord>(CVT, Record));
-}
-
-NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
- PointerRecord PR)
- : NativeRawSymbol(Session, PDB_SymType::PointerType, Id),
- Record(std::move(PR)) {}
+ codeview::TypeIndex TI,
+ codeview::PointerRecord Record)
+ : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI),
+ Record(std::move(Record)) {}
NativeTypePointer::~NativeTypePointer() {}
diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
index 71f8fdd34b8..c3fabd71ee5 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -1,5 +1,6 @@
#include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
+#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
#include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
@@ -15,6 +16,7 @@
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
using namespace llvm;
+using namespace llvm::codeview;
using namespace llvm::pdb;
// Maps codeview::SimpleTypeKind of a built-in type to the parameters necessary
@@ -46,12 +48,6 @@ SymbolCache::SymbolCache(NativeSession &Session, DbiStream *Dbi)
Compilands.resize(Dbi->modules().getModuleCount());
}
-std::unique_ptr<PDBSymbolTypeEnum>
-SymbolCache::createEnumSymbol(codeview::TypeIndex Index) {
- const auto Id = findSymbolByTypeIndex(Index);
- return PDBSymbol::createAs<PDBSymbolTypeEnum>(Session, *Cache[Id]);
-}
-
std::unique_ptr<IPDBEnumSymbols>
SymbolCache::createTypeEnumerator(codeview::TypeLeafKind Kind) {
auto Tpi = Session.getPDBFile().getPDBTpiStream();
@@ -98,21 +94,23 @@ SymIndexId SymbolCache::findSymbolByTypeIndex(codeview::TypeIndex Index) {
return 0;
}
codeview::LazyRandomTypeCollection &Types = Tpi->typeCollection();
- const codeview::CVType &CVT = Types.getType(Index);
- // TODO(amccarth): Make this handle all types, not just LF_ENUMs.
+ codeview::CVType CVT = Types.getType(Index);
+ // TODO(amccarth): Make this handle all types.
SymIndexId Id = 0;
switch (CVT.kind()) {
case codeview::LF_ENUM:
- Id = createSymbol<NativeTypeEnum>(CVT);
+ Id = createSymbolForType<NativeTypeEnum, EnumRecord>(Index, std::move(CVT));
break;
case codeview::LF_POINTER:
- Id = createSymbol<NativeTypePointer>(CVT);
+ Id = createSymbolForType<NativeTypePointer, PointerRecord>(Index,
+ std::move(CVT));
break;
default:
Id = createSymbolPlaceholder();
break;
}
- TypeIndexToSymbolId[Index] = Id;
+ if (Id != 0)
+ TypeIndexToSymbolId[Index] = Id;
return Id;
}
OpenPOWER on IntegriCloud