[Lldb-commits] [lldb] [LLDB][NativePDB] Add PdbAstBuilder null checks (PR #176065)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 14 21:41:26 PST 2026
================
@@ -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);
----------------
JDevlieghere wrote:
I'm assuming the call to `GetNativePDBParser` is cheap and even if it's not, that the compiler can optimize away the duplication, but for maintainability and consistency I think it's better to have a temporary:
```suggestion
TypeSystem *ts = decl_ctx.GetTypeSystem();
if (!ts || !ts->GetNativePDBParser())
return;
PdbAstBuilder* ast_builder = ts->GetNativePDBParser();
if (!ast_builder)
return;
ast_builder->ParseDeclsForContext(decl_ctx);
```
https://github.com/llvm/llvm-project/pull/176065
More information about the lldb-commits
mailing list