[Lldb-commits] [lldb] [lldb] Don't assume non-erased DenseMap entries remain valid after erase. NFC (PR #199499)
Fangrui Song via lldb-commits
lldb-commits at lists.llvm.org
Mon May 25 01:41:42 PDT 2026
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/199499
Similar to #198982
>From 1fac4db4dc728e7a894a7b3806e365f67b5617e7 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Mon, 25 May 2026 01:39:54 -0700
Subject: [PATCH] [lldb] Don't assume non-erased DenseMap entries remain valid
after erase. NFC
Similar to #198982
---
.../Plugins/ExpressionParser/Clang/ClangASTImporter.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index f13d8678f22b9..e081ae27ba4a1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -399,13 +399,8 @@ class ClangASTImporter {
/// Useful when an ASTContext is about to be deleted and all the dangling
/// pointers to it need to be removed.
void removeOriginsWithContext(clang::ASTContext *ctx) {
- for (OriginMap::iterator iter = m_origins.begin();
- iter != m_origins.end();) {
- if (iter->second.ctx == ctx)
- m_origins.erase(iter++);
- else
- ++iter;
- }
+ m_origins.remove_if(
+ [ctx](const auto &origin) { return origin.second.ctx == ctx; });
}
/// Returns the DeclOrigin for the given Decl or an invalid DeclOrigin
More information about the lldb-commits
mailing list