[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-04 Thread via lldb-commits

https://github.com/cmtice created 
https://github.com/llvm/llvm-project/pull/138487

When handling anonymous structs, GetIndexOfChildMemberWithName needs to add the 
number of non-empty base classes to the child index, to get the actual correct 
index. It was not doing so. This fixes that.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (cmtice)


Changes

When handling anonymous structs, GetIndexOfChildMemberWithName needs to add the 
number of non-empty base classes to the child index, to get the actual correct 
index. It was not doing so. This fixes that.

---
Full diff: https://github.com/llvm/llvm-project/pull/138487.diff


4 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+8-1) 
- (added) lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile (+3) 
- (added) 
lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py 
(+27) 
- (added) lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp (+33) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a2b3d4133e51..dd8d144510056 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6743,7 +6743,14 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
 std::vector save_indices = child_indexes;
-child_indexes.push_back(child_idx);
+if (field_type.IsAnonymousType())
+  // We have to add on the number of non-empty base classes to this
+  // index!
+  child_indexes.push_back(
+  child_idx +
+  TypeSystemClang::GetNumBaseClasses(cxx_record_decl, true));
+else
+  child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
new file mode 100644
index 0..2295ecfe81ff7
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
@@ -0,0 +1,27 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestTypeLookupAnonStruct(TestBase):
+def test_lookup_anon_struct(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, '// Set breakpoint here', lldb.SBFileSpec('main.cpp')
+)
+
+self.expect_var_path('unnamed_derived.y', value='2')
+self.expect_var_path('unnamed_derived.z', value='13')
+self.expect('frame variable "derb.x"', error=True,
+substrs=['"x" is not a member of "(DerivedB) derb"'])
+self.expect('frame variable "derb.y"', error=True,
+substrs=['"y" is not a member of "(DerivedB) derb"'])
+self.expect_var_path('derb.w', value='14')
+self.expect_var_path('derb.k', value='15')
+self.expect_var_path('derb.a.x', value='1')
+self.expect_var_path('derb.a.y', value='2')
diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
new file mode 100644
index 0..18dd997ea9563
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
@@ -0,0 +1,33 @@
+int main(int argc, char** argv) {
+  struct A {
+struct {
+  int x = 1;
+};
+int y = 2;
+  } a;
+
+   struct B {
+// Anonymous struct inherits another struct.
+struct : public A {
+  int z = 3;
+};
+int w = 4;
+A a;
+  } b;
+
+   struct : public A {
+ struct {
+   int z = 13;
+ };
+   } unnamed_derived;
+
+   struct DerivedB : public B {
+ struct {
+   // `w` in anonymous struct overrides `w` from `B`.
+   int w = 14;
+   int k = 15;
+ };
+   } derb;
+
+   return 0; // Set breakpoint here
+}

``




https://github.com/llvm/llvm-project/pull/138487
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-04 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
index 18dd997ea..0c218ad9f 100644
--- a/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
+++ b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
@@ -1,4 +1,4 @@
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
   struct A {
 struct {
   int x = 1;
@@ -6,7 +6,7 @@ int main(int argc, char** argv) {
 int y = 2;
   } a;
 
-   struct B {
+  struct B {
 // Anonymous struct inherits another struct.
 struct : public A {
   int z = 3;
@@ -15,19 +15,19 @@ int main(int argc, char** argv) {
 A a;
   } b;
 
-   struct : public A {
- struct {
-   int z = 13;
- };
-   } unnamed_derived;
+  struct : public A {
+struct {
+  int z = 13;
+};
+  } unnamed_derived;
 
-   struct DerivedB : public B {
- struct {
-   // `w` in anonymous struct overrides `w` from `B`.
-   int w = 14;
-   int k = 15;
- };
-   } derb;
+  struct DerivedB : public B {
+struct {
+  // `w` in anonymous struct overrides `w` from `B`.
+  int w = 14;
+  int k = 15;
+};
+  } derb;
 
-   return 0; // Set breakpoint here
+  return 0; // Set breakpoint here
 }

``




https://github.com/llvm/llvm-project/pull/138487
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-04 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
``





View the diff from darker here.


``diff
--- TestCppTypeLookupAnonStruct.py  2025-05-05 06:43:28.00 +
+++ TestCppTypeLookupAnonStruct.py  2025-05-05 06:48:40.843313 +
@@ -10,18 +10,24 @@
 
 class TestTypeLookupAnonStruct(TestBase):
 def test_lookup_anon_struct(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
-self, '// Set breakpoint here', lldb.SBFileSpec('main.cpp')
+self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp")
 )
 
-self.expect_var_path('unnamed_derived.y', value='2')
-self.expect_var_path('unnamed_derived.z', value='13')
-self.expect('frame variable "derb.x"', error=True,
-substrs=['"x" is not a member of "(DerivedB) derb"'])
-self.expect('frame variable "derb.y"', error=True,
-substrs=['"y" is not a member of "(DerivedB) derb"'])
-self.expect_var_path('derb.w', value='14')
-self.expect_var_path('derb.k', value='15')
-self.expect_var_path('derb.a.x', value='1')
-self.expect_var_path('derb.a.y', value='2')
+self.expect_var_path("unnamed_derived.y", value="2")
+self.expect_var_path("unnamed_derived.z", value="13")
+self.expect(
+'frame variable "derb.x"',
+error=True,
+substrs=['"x" is not a member of "(DerivedB) derb"'],
+)
+self.expect(
+'frame variable "derb.y"',
+error=True,
+substrs=['"y" is not a member of "(DerivedB) derb"'],
+)
+self.expect_var_path("derb.w", value="14")
+self.expect_var_path("derb.k", value="15")
+self.expect_var_path("derb.a.x", value="1")
+self.expect_var_path("derb.a.y", value="2")

``




https://github.com/llvm/llvm-project/pull/138487
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 61714c1 - [lldb] Remove unused local variables (NFC) (#138457)

2025-05-04 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-04T11:56:22-07:00
New Revision: 61714c16be4935d03f52ea7f11cee2f58a82d9fd

URL: 
https://github.com/llvm/llvm-project/commit/61714c16be4935d03f52ea7f11cee2f58a82d9fd
DIFF: 
https://github.com/llvm/llvm-project/commit/61714c16be4935d03f52ea7f11cee2f58a82d9fd.diff

LOG: [lldb] Remove unused local variables (NFC) (#138457)

Added: 


Modified: 
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Core/FormatEntity.cpp
lldb/source/DataFormatters/CXXFunctionPointer.cpp
lldb/source/Expression/DiagnosticManager.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
lldb/source/Target/Platform.cpp
lldb/source/Utility/ArchSpec.cpp
lldb/unittests/Utility/LogTest.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 9510cf4d14467..10dc273e39ab9 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1537,9 +1537,8 @@ class CommandObjectScriptingObjectParsed : public 
CommandObjectParsed {
   option_def.completion_type = (CommandArgumentType) completion_type;
 } else
   option_def.completion_type = eNoCompletion;
-
+
 // Usage Text:
-std::string usage_text;
 obj_sp = opt_dict->GetValueForKey("help");
 if (!obj_sp) {
   error = Status::FromErrorStringWithFormatv(

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 40e247a64b78c..f1c831b7ccc1e 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2471,7 +2471,6 @@ static void AddMatches(const Definition *def, const 
llvm::StringRef &prefix,
   const size_t n = def->num_children;
   if (n > 0) {
 for (size_t i = 0; i < n; ++i) {
-  std::string match = prefix.str();
   if (match_prefix.empty())
 matches.AppendString(MakeMatch(prefix, def->children[i].name));
   else if (strncmp(def->children[i].name, match_prefix.data(),

diff  --git a/lldb/source/DataFormatters/CXXFunctionPointer.cpp 
b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
index e17659ad0f2f0..d79fb1d678ebd 100644
--- a/lldb/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
@@ -23,7 +23,6 @@ using namespace lldb_private::formatters;
 
 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  std::string destination;
   StreamString sstr;
   AddressType func_ptr_address_type = eAddressTypeInvalid;
   addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);

diff  --git a/lldb/source/Expression/DiagnosticManager.cpp 
b/lldb/source/Expression/DiagnosticManager.cpp
index b1fa14bccc17b..4c0233d467c95 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -83,7 +83,6 @@ std::string DiagnosticManager::GetString(char separator) {
 stream << severity;
 
 llvm::StringRef message = diagnostic->GetMessage();
-std::string searchable_message = message.lower();
 auto severity_pos = message.find(severity);
 stream << message.take_front(severity_pos);
 

diff  --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 7008253e32bca..72dd546dd6523 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -338,14 +338,11 @@ void CommandObject::HandleArgumentCompletion(
 
 }
 
-
 bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
  bool search_short_help,
  bool search_long_help,
  bool search_syntax,
  bool search_options) {
-  std::string options_usage_help;
-
   bool found_word = false;
 
   llvm::StringRef short_help = GetHelp();

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index adedfa8ece917..d8c7e436f3f8b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -904,7 +904,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
   if (!debugserver_file_spec)
 return Status::FromErrorString("unable to locate " DEBUG

[Lldb-commits] [lldb] [lldb] Remove unused local variables (NFC) (PR #138457)

2025-05-04 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/138457
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove unused local variables (NFC) (PR #138457)

2025-05-04 Thread Matt Arsenault via lldb-commits

https://github.com/arsenm approved this pull request.


https://github.com/llvm/llvm-project/pull/138457
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove unused local variables (NFC) (PR #138457)

2025-05-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/138457.diff


13 Files Affected:

- (modified) lldb/source/Commands/CommandObjectCommands.cpp (+1-2) 
- (modified) lldb/source/Core/FormatEntity.cpp (-1) 
- (modified) lldb/source/DataFormatters/CXXFunctionPointer.cpp (-1) 
- (modified) lldb/source/Expression/DiagnosticManager.cpp (-1) 
- (modified) lldb/source/Interpreter/CommandObject.cpp (-3) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
(-1) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (-1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (-8) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp (-1) 
- (modified) lldb/source/Target/Platform.cpp (-1) 
- (modified) lldb/source/Utility/ArchSpec.cpp (-1) 
- (modified) lldb/unittests/Utility/LogTest.cpp (-4) 


``diff
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 9510cf4d14467..10dc273e39ab9 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1537,9 +1537,8 @@ class CommandObjectScriptingObjectParsed : public 
CommandObjectParsed {
   option_def.completion_type = (CommandArgumentType) completion_type;
 } else
   option_def.completion_type = eNoCompletion;
-
+
 // Usage Text:
-std::string usage_text;
 obj_sp = opt_dict->GetValueForKey("help");
 if (!obj_sp) {
   error = Status::FromErrorStringWithFormatv(
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 40e247a64b78c..f1c831b7ccc1e 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2471,7 +2471,6 @@ static void AddMatches(const Definition *def, const 
llvm::StringRef &prefix,
   const size_t n = def->num_children;
   if (n > 0) {
 for (size_t i = 0; i < n; ++i) {
-  std::string match = prefix.str();
   if (match_prefix.empty())
 matches.AppendString(MakeMatch(prefix, def->children[i].name));
   else if (strncmp(def->children[i].name, match_prefix.data(),
diff --git a/lldb/source/DataFormatters/CXXFunctionPointer.cpp 
b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
index e17659ad0f2f0..d79fb1d678ebd 100644
--- a/lldb/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
@@ -23,7 +23,6 @@ using namespace lldb_private::formatters;
 
 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  std::string destination;
   StreamString sstr;
   AddressType func_ptr_address_type = eAddressTypeInvalid;
   addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
diff --git a/lldb/source/Expression/DiagnosticManager.cpp 
b/lldb/source/Expression/DiagnosticManager.cpp
index b1fa14bccc17b..4c0233d467c95 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -83,7 +83,6 @@ std::string DiagnosticManager::GetString(char separator) {
 stream << severity;
 
 llvm::StringRef message = diagnostic->GetMessage();
-std::string searchable_message = message.lower();
 auto severity_pos = message.find(severity);
 stream << message.take_front(severity_pos);
 
diff --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 7008253e32bca..72dd546dd6523 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -338,14 +338,11 @@ void CommandObject::HandleArgumentCompletion(
 
 }
 
-
 bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
  bool search_short_help,
  bool search_long_help,
  bool search_syntax,
  bool search_options) {
-  std::string options_usage_help;
-
   bool found_word = false;
 
   llvm::StringRef short_help = GetHelp();
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index adedfa8ece917..d8c7e436f3f8b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -904,7 +904,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
   if (!debugserver_file_spec)
 return Status::FromErrorString("unable to locate " DEBUGSERVER_BASENAME);
 
-  std::string debugserver_path = debugserver_file_spec.GetPath();

[Lldb-commits] [lldb] [lldb] Remove unused local variables (NFC) (PR #138457)

2025-05-04 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/138457

None

>From 3f79743b6f2a71f764cd86201820c25efee33851 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 4 May 2025 09:28:01 -0700
Subject: [PATCH] [lldb] Remove unused local variables (NFC)

---
 lldb/source/Commands/CommandObjectCommands.cpp| 3 +--
 lldb/source/Core/FormatEntity.cpp | 1 -
 lldb/source/DataFormatters/CXXFunctionPointer.cpp | 1 -
 lldb/source/Expression/DiagnosticManager.cpp  | 1 -
 lldb/source/Interpreter/CommandObject.cpp | 3 ---
 .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 1 -
 .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp   | 1 -
 .../Plugins/Process/gdb-remote/ProcessGDBRemote.cpp   | 2 --
 .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp  | 8 
 .../Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp | 1 -
 lldb/source/Target/Platform.cpp   | 1 -
 lldb/source/Utility/ArchSpec.cpp  | 1 -
 lldb/unittests/Utility/LogTest.cpp| 4 
 13 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 9510cf4d14467..10dc273e39ab9 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1537,9 +1537,8 @@ class CommandObjectScriptingObjectParsed : public 
CommandObjectParsed {
   option_def.completion_type = (CommandArgumentType) completion_type;
 } else
   option_def.completion_type = eNoCompletion;
-
+
 // Usage Text:
-std::string usage_text;
 obj_sp = opt_dict->GetValueForKey("help");
 if (!obj_sp) {
   error = Status::FromErrorStringWithFormatv(
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 40e247a64b78c..f1c831b7ccc1e 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2471,7 +2471,6 @@ static void AddMatches(const Definition *def, const 
llvm::StringRef &prefix,
   const size_t n = def->num_children;
   if (n > 0) {
 for (size_t i = 0; i < n; ++i) {
-  std::string match = prefix.str();
   if (match_prefix.empty())
 matches.AppendString(MakeMatch(prefix, def->children[i].name));
   else if (strncmp(def->children[i].name, match_prefix.data(),
diff --git a/lldb/source/DataFormatters/CXXFunctionPointer.cpp 
b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
index e17659ad0f2f0..d79fb1d678ebd 100644
--- a/lldb/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
@@ -23,7 +23,6 @@ using namespace lldb_private::formatters;
 
 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  std::string destination;
   StreamString sstr;
   AddressType func_ptr_address_type = eAddressTypeInvalid;
   addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
diff --git a/lldb/source/Expression/DiagnosticManager.cpp 
b/lldb/source/Expression/DiagnosticManager.cpp
index b1fa14bccc17b..4c0233d467c95 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -83,7 +83,6 @@ std::string DiagnosticManager::GetString(char separator) {
 stream << severity;
 
 llvm::StringRef message = diagnostic->GetMessage();
-std::string searchable_message = message.lower();
 auto severity_pos = message.find(severity);
 stream << message.take_front(severity_pos);
 
diff --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 7008253e32bca..72dd546dd6523 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -338,14 +338,11 @@ void CommandObject::HandleArgumentCompletion(
 
 }
 
-
 bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
  bool search_short_help,
  bool search_long_help,
  bool search_syntax,
  bool search_options) {
-  std::string options_usage_help;
-
   bool found_word = false;
 
   llvm::StringRef short_help = GetHelp();
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index adedfa8ece917..d8c7e436f3f8b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -904,7 +904,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
   if (!debugserver_file_spec)
 return Status::FromErrorString("unable to loca