https://github.com/speednoisemovement updated 
https://github.com/llvm/llvm-project/pull/176065

>From 8e7034f2d1c30a71a151e91b50de95afd6b51f81 Mon Sep 17 00:00:00 2001
From: Leonard Grey <[email protected]>
Date: Wed, 14 Jan 2026 19:17:31 -0500
Subject: [PATCH 1/2] [LLDB][NativePDB] Add PdbAstBuilder null checks

---
 .../NativePDB/SymbolFileNativePDB.cpp         | 54 ++++++++-----------
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 01556133a3ad0..c8e059affe428 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -503,7 +503,8 @@ Block *SymbolFileNativePDB::CreateBlock(PdbCompilandSymId 
block_id) {
           block_id.modi, block_id.offset, block_base,
           block_base + block.CodeSize, func_base);
     }
-    ast_builder->EnsureBlock(block_id);
+    if (ast_builder)
+      ast_builder->EnsureBlock(block_id);
     m_blocks.insert({opaque_block_uid, child_block});
     break;
   }
@@ -516,7 +517,8 @@ Block *SymbolFileNativePDB::CreateBlock(PdbCompilandSymId 
block_id) {
     if (!parent_block)
       return nullptr;
     BlockSP child_block = parent_block->CreateChild(opaque_block_uid);
-    ast_builder->EnsureInlinedFunction(block_id);
+    if (ast_builder)
+      ast_builder->EnsureInlinedFunction(block_id);
     // Copy ranges from InlineSite to Block.
     for (size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
       auto *entry = inline_site->ranges.GetEntryAtIndex(i);
@@ -585,9 +587,8 @@ lldb::FunctionSP 
SymbolFileNativePDB::CreateFunction(PdbCompilandSymId func_id,
   if (auto err = ts_or_err.takeError())
     return func_sp;
   auto ts = *ts_or_err;
-  if (!ts)
-    return func_sp;
-  ts->GetNativePDBParser()->EnsureFunction(func_id);
+  if (ts && ts->GetNativePDBParser())
+    ts->GetNativePDBParser()->EnsureFunction(func_id);
 
   return func_sp;
 }
@@ -919,11 +920,9 @@ TypeSP 
SymbolFileNativePDB::CreateAndCacheType(PdbTypeSymId type_id) {
   if (auto err = ts_or_err.takeError())
     return nullptr;
   auto ts = *ts_or_err;
-  if (!ts)
+  if (!ts || !ts->GetNativePDBParser())
     return nullptr;
-
-  PdbAstBuilder* ast_builder = ts->GetNativePDBParser();
-  CompilerType ct = ast_builder->GetOrCreateType(best_decl_id);
+  CompilerType ct = ts->GetNativePDBParser()->GetOrCreateType(best_decl_id);
   if (!ct)
     return nullptr;
 
@@ -1020,10 +1019,8 @@ VariableSP 
SymbolFileNativePDB::CreateGlobalVariable(PdbGlobalSymId var_id) {
   if (auto err = ts_or_err.takeError())
     return nullptr;
   auto ts = *ts_or_err;
-  if (!ts)
-    return nullptr;
-
-  ts->GetNativePDBParser()->EnsureVariable(var_id);
+  if (ts && ts->GetNativePDBParser())
+    ts->GetNativePDBParser()->EnsureVariable(var_id);
 
   ModuleSP module_sp = GetObjectFile()->GetModule();
   DWARFExpressionList location(
@@ -1123,11 +1120,10 @@ Block 
*SymbolFileNativePDB::GetOrCreateBlock(PdbCompilandSymId block_id) {
 
 void SymbolFileNativePDB::ParseDeclsForContext(
     lldb_private::CompilerDeclContext decl_ctx) {
-  TypeSystem* ts_or_err = decl_ctx.GetTypeSystem();
-  if (!ts_or_err)
+  TypeSystem *ts = decl_ctx.GetTypeSystem();
+  if (!ts || !ts->GetNativePDBParser())
     return;
-  PdbAstBuilder* ast_builder = ts_or_err->GetNativePDBParser();
-  ast_builder->ParseDeclsForContext(decl_ctx);
+  ts->GetNativePDBParser()->ParseDeclsForContext(decl_ctx);
 }
 
 lldb::CompUnitSP SymbolFileNativePDB::ParseCompileUnitAtIndex(uint32_t index) {
@@ -1828,7 +1824,7 @@ void SymbolFileNativePDB::DumpClangAST(Stream &s, 
llvm::StringRef filter,
     return;
   auto ts = *ts_or_err;
   TypeSystemClang *clang = llvm::dyn_cast_or_null<TypeSystemClang>(ts.get());
-  if (!clang)
+  if (!clang || !clang->GetNativePDBParser())
     return;
   clang->GetNativePDBParser()->Dump(s, filter, show_color);
 }
@@ -2234,10 +2230,8 @@ VariableSP 
SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
     if (auto err = ts_or_err.takeError())
       return nullptr;
     auto ts = *ts_or_err;
-    if (!ts)
-      return nullptr;
-
-    ts->GetNativePDBParser()->EnsureVariable(scope_id, var_id);
+    if (ts && ts->GetNativePDBParser())
+      ts->GetNativePDBParser()->EnsureVariable(scope_id, var_id);
   }
   m_local_variables[toOpaqueUid(var_id)] = var_sp;
   return var_sp;
@@ -2264,7 +2258,7 @@ TypeSP SymbolFileNativePDB::CreateTypedef(PdbGlobalSymId 
id) {
   if (auto err = ts_or_err.takeError())
     return nullptr;
   auto ts = *ts_or_err;
-  if (!ts)
+  if (!ts || !ts->GetNativePDBParser())
     return nullptr;
 
   CompilerType ct = ts->GetNativePDBParser()->GetOrCreateTypedefType(id);
@@ -2423,7 +2417,7 @@ CompilerDecl 
SymbolFileNativePDB::GetDeclForUID(lldb::user_id_t uid) {
   if (auto err = ts_or_err.takeError())
     return CompilerDecl();
   auto ts = *ts_or_err;
-  if (!ts)
+  if (!ts || !ts->GetNativePDBParser())
     return {};
   return ts->GetNativePDBParser()->GetOrCreateDeclForUid(uid);
 }
@@ -2434,11 +2428,9 @@ 
SymbolFileNativePDB::GetDeclContextForUID(lldb::user_id_t uid) {
   if (auto err = ts_or_err.takeError())
     return {};
   auto ts = *ts_or_err;
-  if (!ts)
+  if (!ts || !ts->GetNativePDBParser())
     return {};
-
-  PdbAstBuilder *ast_builder = ts->GetNativePDBParser();
-  return ast_builder->GetOrCreateDeclContextForUid(PdbSymUid(uid));
+  return 
ts->GetNativePDBParser()->GetOrCreateDeclContextForUid(PdbSymUid(uid));
 }
 
 CompilerDeclContext
@@ -2447,11 +2439,9 @@ 
SymbolFileNativePDB::GetDeclContextContainingUID(lldb::user_id_t uid) {
   if (auto err = ts_or_err.takeError())
     return CompilerDeclContext();
   auto ts = *ts_or_err;
-  if (!ts)
+  if (!ts || !ts->GetNativePDBParser())
     return {};
-
-  PdbAstBuilder *ast_builder = ts->GetNativePDBParser();
-  return ast_builder->GetParentDeclContext(PdbSymUid(uid));
+  return ts->GetNativePDBParser()->GetParentDeclContext(PdbSymUid(uid));
 }
 
 Type *SymbolFileNativePDB::ResolveTypeUID(lldb::user_id_t type_uid) {

>From b1d472e28985f2c498a2d4bdf017212546f59892 Mon Sep 17 00:00:00 2001
From: Leonard Grey <[email protected]>
Date: Thu, 15 Jan 2026 11:21:32 -0500
Subject: [PATCH 2/2] Use temporaries

---
 .../SymbolFile/NativePDB/SymbolFileNativePDB.cpp    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index c8e059affe428..9d6fb4cb2cd06 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1019,8 +1019,10 @@ VariableSP 
SymbolFileNativePDB::CreateGlobalVariable(PdbGlobalSymId var_id) {
   if (auto err = ts_or_err.takeError())
     return nullptr;
   auto ts = *ts_or_err;
-  if (ts && ts->GetNativePDBParser())
-    ts->GetNativePDBParser()->EnsureVariable(var_id);
+  if (ts) {
+    if (PdbAstBuilder *ast_builder = ts->GetNativePDBParser())
+      ast_builder->EnsureVariable(var_id);
+  }
 
   ModuleSP module_sp = GetObjectFile()->GetModule();
   DWARFExpressionList location(
@@ -1121,9 +1123,12 @@ Block 
*SymbolFileNativePDB::GetOrCreateBlock(PdbCompilandSymId block_id) {
 void SymbolFileNativePDB::ParseDeclsForContext(
     lldb_private::CompilerDeclContext decl_ctx) {
   TypeSystem *ts = decl_ctx.GetTypeSystem();
-  if (!ts || !ts->GetNativePDBParser())
+  if (!ts)
+    return;
+  PdbAstBuilder *ast_builder = ts->GetNativePDBParser();
+  if (!ast_builder)
     return;
-  ts->GetNativePDBParser()->ParseDeclsForContext(decl_ctx);
+  ast_builder->ParseDeclsForContext(decl_ctx);
 }
 
 lldb::CompUnitSP SymbolFileNativePDB::ParseCompileUnitAtIndex(uint32_t index) {

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to