Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1719,19 +1719,23 @@ void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id,
}

// Get the inlined function name.
CVType inlinee_cvt = m_index->ipi().getType(inline_site.Inlinee);
std::string inlinee_name;
if (inlinee_cvt.kind() == LF_MFUNC_ID) {
llvm::Expected<CVType> inlinee_cvt =
m_index->ipi().typeCollection().getTypeOrError(inline_site.Inlinee);
if (!inlinee_cvt) {
inlinee_name = "[error reading function name: " +
llvm::toString(inlinee_cvt.takeError()) + "]";
} else if (inlinee_cvt->kind() == LF_MFUNC_ID) {
MemberFuncIdRecord mfr;
cantFail(
TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
TypeDeserializer::deserializeAs<MemberFuncIdRecord>(*inlinee_cvt, mfr));
LazyRandomTypeCollection &types = m_index->tpi().typeCollection();
inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
inlinee_name.append("::");
inlinee_name.append(mfr.getName().str());
} else if (inlinee_cvt.kind() == LF_FUNC_ID) {
} else if (inlinee_cvt->kind() == LF_FUNC_ID) {
FuncIdRecord fir;
cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(*inlinee_cvt, fir));
TypeIndex parent_idx = fir.getParentScope();
if (!parent_idx.isNoneType()) {
LazyRandomTypeCollection &ids = m_index->ipi().typeCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LLVM_ABI LazyRandomTypeCollection : public TypeCollection {
uint32_t getOffsetOfType(TypeIndex Index);

std::optional<CVType> tryGetType(TypeIndex Index);

llvm::Expected<CVType> getTypeOrError(TypeIndex Index);
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
bool contains(TypeIndex Index) override;
Expand Down
15 changes: 10 additions & 5 deletions llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,25 @@ CVType LazyRandomTypeCollection::getType(TypeIndex Index) {
return Records[Index.toArrayIndex()].Type;
}

std::optional<CVType> LazyRandomTypeCollection::tryGetType(TypeIndex Index) {
llvm::Expected<CVType>
LazyRandomTypeCollection::getTypeOrError(TypeIndex Index) {
if (Index.isSimple())
return std::nullopt;
return llvm::createStringError("Type index too low (%d)", Index.getIndex());

if (auto EC = ensureTypeExists(Index)) {
consumeError(std::move(EC));
return std::nullopt;
return EC;
}

if (!contains(Index))
return std::nullopt;
return llvm::createStringError("Type index too high (%d)",
Index.getIndex());
return Records[Index.toArrayIndex()].Type;
}

std::optional<CVType> LazyRandomTypeCollection::tryGetType(TypeIndex Index) {
return llvm::expectedToOptional(getTypeOrError(Index));
}

StringRef LazyRandomTypeCollection::getTypeName(TypeIndex Index) {
if (Index.isNoneType() || Index.isSimple())
return TypeIndex::simpleTypeName(Index);
Expand Down