================
@@ -453,13 +456,20 @@ class SymbolContextList {
   ///     The zero based index into the symbol context list.
   ///
   /// \return
-  ///     A const reference to the symbol context to fill in.
-  SymbolContext &operator[](size_t idx) { return m_symbol_contexts[idx]; }
-
+  ///     A const reference to the symbol context.
   const SymbolContext &operator[](size_t idx) const {
     return m_symbol_contexts[idx];
   }
 
+  /// Replace the symbol in the symbol context at index \a idx.
+  ///
+  /// The symbol field is excluded from the hash and equality used by the
+  /// internal set, so this is the only mutation that is safe to perform on
+  /// an element that is already in the list.
+  void SetSymbolAtIndex(size_t idx, Symbol *symbol) {
+    const_cast<SymbolContext &>(m_symbol_contexts[idx]).symbol = symbol;
----------------
Michael137 wrote:

Why do we need this `const_cast`? Hmmm looks like `SetVector` not expose a 
mutable accessor. I think the idea is that you re-insert into the vector, and 
let the de-duplication mechanism do the right thing.

So i think you want to replace this with a call to `insert`

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

Reply via email to