compnerd created this revision.
compnerd added reviewers: rnk, sgraenitz.
Herald added a project: All.
compnerd requested review of this revision.
Herald added a project: LLDB.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146536

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


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1301,7 +1301,10 @@
         auto value = member->getValue();
         clang::QualType qual_type = decl->getType();
         unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
-        unsigned constant_width = value.getBitWidth();
+        // If we have an incomplete type, the value may be empty, which will
+        // trigger an assertion failure on `getBitWidth`.
+        unsigned constant_width =
+            value.Type == llvm::pdb::Empty ? - 1 : value.getBitWidth();
 
         if (qual_type->isIntegralOrEnumerationType()) {
           if (type_width >= constant_width) {


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1301,7 +1301,10 @@
         auto value = member->getValue();
         clang::QualType qual_type = decl->getType();
         unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
-        unsigned constant_width = value.getBitWidth();
+        // If we have an incomplete type, the value may be empty, which will
+        // trigger an assertion failure on `getBitWidth`.
+        unsigned constant_width =
+            value.Type == llvm::pdb::Empty ? - 1 : value.getBitWidth();
 
         if (qual_type->isIntegralOrEnumerationType()) {
           if (type_width >= constant_width) {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to