Skip to content

Commit 0652c11

Browse files
committed
fix: reset members first and set at the end of update()
1 parent 9f71938 commit 0652c11

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,40 +221,45 @@ lldb_private::formatters::MsvcStlVectorBoolSyntheticFrontEnd::GetChildAtIndex(
221221

222222
lldb::ChildCacheState
223223
lldb_private::formatters::MsvcStlVectorBoolSyntheticFrontEnd::Update() {
224+
m_exe_ctx_ref.Clear();
225+
m_count = 0;
226+
m_element_bit_size = 0;
227+
m_base_data_address = 0;
224228
m_children.clear();
229+
225230
ValueObjectSP valobj_sp = m_backend.GetSP();
226231
if (!valobj_sp)
227232
return lldb::ChildCacheState::eRefetch;
228-
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
233+
auto exe_ctx_ref = valobj_sp->GetExecutionContextRef();
229234

230235
ValueObjectSP size_sp = valobj_sp->GetChildMemberWithName("_Mysize");
231236
if (!size_sp)
232237
return lldb::ChildCacheState::eRefetch;
233-
m_count = size_sp->GetValueAsUnsigned(0);
234-
if (!m_count)
238+
uint64_t count = size_sp->GetValueAsUnsigned(0);
239+
if (count == 0)
235240
return lldb::ChildCacheState::eReuse;
236241

237242
ValueObjectSP begin_sp(valobj_sp->GetChildAtNamePath(
238243
{"_Myvec", "_Mypair", "_Myval2", "_Myfirst"}));
239-
if (!begin_sp) {
240-
m_count = 0;
244+
if (!begin_sp)
241245
return lldb::ChildCacheState::eRefetch;
242-
}
243246

244247
// FIXME: the STL exposes _EEN_VBITS as a constant - it should be used instead
245248
CompilerType begin_ty = begin_sp->GetCompilerType().GetPointeeType();
246249
if (!begin_ty.IsValid())
247250
return lldb::ChildCacheState::eRefetch;
248-
llvm::Expected<uint64_t> bit_size = begin_ty.GetBitSize(nullptr);
249-
if (!bit_size)
251+
llvm::Expected<uint64_t> element_bit_size = begin_ty.GetBitSize(nullptr);
252+
if (!element_bit_size)
250253
return lldb::ChildCacheState::eRefetch;
251-
m_element_bit_size = *bit_size;
252254

253-
m_base_data_address = begin_sp->GetValueAsUnsigned(0);
254-
if (!m_base_data_address) {
255-
m_count = 0;
255+
uint64_t base_data_address = begin_sp->GetValueAsUnsigned(0);
256+
if (!base_data_address)
256257
return lldb::ChildCacheState::eRefetch;
257-
}
258+
259+
m_exe_ctx_ref = exe_ctx_ref;
260+
m_count = count;
261+
m_element_bit_size = *element_bit_size;
262+
m_base_data_address = base_data_address;
258263
return lldb::ChildCacheState::eRefetch;
259264
}
260265

0 commit comments

Comments
 (0)