summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-09-18 16:35:05 +0000
committerZachary Turner <zturner@google.com>2018-09-18 16:35:05 +0000
commitc41ce8355f88ce522dabde2b435bfe83d550a379 (patch)
treee3606b39394096113cd7d0e3c4b1c8ecd644b650 /llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
parentc1e2f39b3503869bd471a867c177f6486da5fee0 (diff)
downloadbcm5719-llvm-c41ce8355f88ce522dabde2b435bfe83d550a379.tar.gz
bcm5719-llvm-c41ce8355f88ce522dabde2b435bfe83d550a379.zip
[PDB] Better support for enumerating pointer types.
There were several issues with the previous implementation. 1) There were no tests. 2) We didn't support creating PDBSymbolTypePointer records for builtin types since those aren't described by LF_POINTER records. 3) We didn't support a wide enough variety of builtin types even ignoring pointers. This patch fixes all of these issues. In order to add tests, it's helpful to be able to ignore the symbol index id hierarchy because it makes the golden output from the DIA version not match our output, so I've extended the dumper to disable dumping of id fields. llvm-svn: 342493
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
index a4b1ecfb770..a661227f9b6 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -65,18 +65,20 @@ SymbolCache::createTypeEnumerator(codeview::TypeLeafKind Kind) {
SymIndexId SymbolCache::createSimpleType(TypeIndex Index,
ModifierOptions Mods) {
- // FIXME: We will eventually need to handle pointers to other simple types,
- // which are still simple types in the world of CodeView TypeIndexes.
- if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct)
- return 0;
+ if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct) {
+ SymIndexId Id = Cache.size();
+ Cache.emplace_back(
+ llvm::make_unique<NativeTypePointer>(Session, Id, Index));
+ return Id;
+ }
+ SymIndexId Id = Cache.size();
const auto Kind = Index.getSimpleKind();
const auto It = std::find_if(
std::begin(BuiltinTypes), std::end(BuiltinTypes),
[Kind](const BuiltinTypeEntry &Builtin) { return Builtin.Kind == Kind; });
if (It == std::end(BuiltinTypes))
return 0;
- SymIndexId Id = Cache.size();
Cache.emplace_back(llvm::make_unique<NativeTypeBuiltin>(Session, Id, Mods,
It->Type, It->Size));
TypeIndexToSymbolId[Index] = Id;
@@ -175,12 +177,16 @@ SymbolCache::getSymbolById(SymIndexId SymbolId) const {
assert(SymbolId < Cache.size());
// Id 0 is reserved.
- if (SymbolId == 0)
+ if (SymbolId == 0 || SymbolId >= Cache.size())
+ return nullptr;
+
+ // Make sure to handle the case where we've inserted a placeholder symbol
+ // for types we don't yet suppport.
+ NativeRawSymbol *NRS = Cache[SymbolId].get();
+ if (!NRS)
return nullptr;
- // If the caller has a SymbolId, it'd better be in our SymbolCache.
- return SymbolId < Cache.size() ? PDBSymbol::create(Session, *Cache[SymbolId])
- : nullptr;
+ return PDBSymbol::create(Session, *NRS);
}
NativeRawSymbol &SymbolCache::getNativeSymbolById(SymIndexId SymbolId) const {
OpenPOWER on IntegriCloud