llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Raphael Isemann (Teemperor) <details> <summary>Changes</summary> We modify the IR module here while iterating over it. Use the usual list trick to delay modification until after the loop. This was uncovered by bccd1b9cb744e5dd96ee59baa4bf4583457feea3 --- Full diff: https://github.com/llvm/llvm-project/pull/203035.diff 1 Files Affected: - (modified) lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (+13-7) ``````````diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 532c1f129dab3..fa2222185669b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -544,6 +544,9 @@ bool IRForTarget::RewriteObjCConstStrings() { ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable(); + std::vector<std::pair<GlobalVariable *, GlobalVariable *>> + nsstring_to_cstr_list; + for (StringMapEntry<llvm::Value *> &value_symbol : value_symbol_table) { llvm::StringRef value_name = value_symbol.first(); @@ -684,14 +687,17 @@ bool IRForTarget::RewriteObjCConstStrings() { if (!cstr_array) cstr_global = nullptr; - if (!RewriteObjCConstString(nsstring_global, cstr_global)) { - LLDB_LOG(log, "Error rewriting the constant string"); - - // We don't print an error message here because RewriteObjCConstString - // has done so for us. + // Queue up replacing the string as we are currently iterating + // over the module. + nsstring_to_cstr_list.emplace_back(nsstring_global, cstr_global); + } + } - return false; - } + for (const auto &nsstring_and_cstr : nsstring_to_cstr_list) { + auto [nsstring_global, cstr_global] = nsstring_and_cstr; + if (!RewriteObjCConstString(nsstring_global, cstr_global)) { + LLDB_LOG(log, "Error rewriting the constant string"); + return false; } } `````````` </details> https://github.com/llvm/llvm-project/pull/203035 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
