Skip to content

Commit a34ab3c

Browse files
committed
SymbolFile: ensure that we have a value before invoking getBitWidth
Ensure that the variant returned by `member->getValue()` has a value and is not `Empty`. Failure to do so will trigger an assertion failure in `llvm::pdb::Variant::getBitWidth()`. This can occur when the `static` member is a forward declaration. Differential Revision: https://reviews.llvm.org/D146536 Reviewed By: sgraenitz (cherry picked from commit 16b7cf2)
1 parent 7c96e2b commit a34ab3c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,15 @@ void PDBASTParser::AddRecordMembers(
12991299
// Query the symbol's value as the variable initializer if valid.
13001300
if (member_comp_type.IsConst()) {
13011301
auto value = member->getValue();
1302+
if (value.Type == llvm::pdb::Empty) {
1303+
LLDB_LOG(GetLog(LLDBLog::AST),
1304+
"Class '{0}' has member '{1}' of type '{2}' with an unknown "
1305+
"constant size.",
1306+
record_type.GetTypeName(), member_name,
1307+
member_comp_type.GetTypeName());
1308+
continue;
1309+
}
1310+
13021311
clang::QualType qual_type = decl->getType();
13031312
unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
13041313
unsigned constant_width = value.getBitWidth();

0 commit comments

Comments
 (0)