[Lldb-commits] [PATCH] D99989: [lldb-vscode] Distinguish shadowed variables in the scopes request

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 22 04:58:37 PDT 2021


teemperor reopened this revision.
teemperor added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.


================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:2924
+    // We first find out which variable names are duplicated
+    std::unordered_map<std::string, int> variable_name_repeats;
+    for (auto i = start_idx; i < end_idx; ++i) {
----------------
clayborg wrote:
> This variable name can be improved to accurately describe what it is doing. "variable_name_counts" would be my suggestion since that is what it is really doing.
> 
> You can also just make the key of this map "const char *" since the variable names come from ConstString values inside LLDB the pointers will be unique
Let's not. The last time someone did this whole "This `const char *` is actually coming from a ConstString so assume ConstString semantics" it just caused us a bunch of pain (see D88490 and the related revisions).

Either add an assert that the strings are coming from a ConstString (assuming we really care about the performance benefit here) or use some StringMap/std::string-key approach.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99989/new/

https://reviews.llvm.org/D99989



More information about the lldb-commits mailing list