[Lldb-commits] [PATCH] D150078: [lldb] Prevent mutation of CommandAlias::GetOptionArguments

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 8 09:45:45 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG765237779ce4: [lldb] Prevent mutation of CommandAlias::GetOptionArguments (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150078

Files:
  lldb/source/Interpreter/CommandAlias.cpp
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py


Index: lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
===================================================================
--- lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
+++ lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
@@ -101,3 +101,7 @@
         self.expect('command alias two expr -- 2')
         self.expect('command alias add_two two +')
         self.expect('add_two 3', patterns=[' = 5$'])
+        # Check that aliases to aliases to raw input commands work the second
+        # and subsequent times.
+        self.expect('add_two 3', patterns=[' = 5$'])
+        self.expect('add_two 3', patterns=[' = 5$'])
Index: lldb/source/Interpreter/CommandAlias.cpp
===================================================================
--- lldb/source/Interpreter/CommandAlias.cpp
+++ lldb/source/Interpreter/CommandAlias.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Interpreter/CommandAlias.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ErrorHandling.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -211,9 +212,9 @@
     // FIXME: This doesn't work if the original alias fills a slot in the
     // underlying alias, since this just appends the two lists.
     auto desugared = ((CommandAlias *)underlying.get())->Desugar();
-    auto options = GetOptionArguments();
-    options->insert(options->begin(), desugared.second->begin(),
-                    desugared.second->end());
+    OptionArgVectorSP options = std::make_shared<OptionArgVector>();
+    llvm::append_range(*options, *desugared.second);
+    llvm::append_range(*options, *GetOptionArguments());
     return {desugared.first, options};
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150078.520421.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230508/da66b72b/attachment.bin>


More information about the lldb-commits mailing list