[Lldb-commits] [lldb] r263517 - This was printing arguments twice in dash-dash aliases; don't do that

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 14 18:17:32 PDT 2016


Author: enrico
Date: Mon Mar 14 20:17:32 2016
New Revision: 263517

URL: http://llvm.org/viewvc/llvm-project?rev=263517&view=rev
Log:
This was printing arguments twice in dash-dash aliases; don't do that

Modified:
    lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=263517&r1=263516&r2=263517&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Mon Mar 14 20:17:32 2016
@@ -511,22 +511,22 @@ Options::GenerateOptionUsage
     
     uint32_t i;
     
-    for (uint32_t opt_set = 0; opt_set < num_option_sets; ++opt_set)
+    if (!only_print_args)
     {
-        uint32_t opt_set_mask;
-        
-        opt_set_mask = 1 << opt_set;
-        if (opt_set > 0)
-            strm.Printf ("\n");
-        strm.Indent (name);
-
-        // Different option sets may require different args.
-        StreamString args_str;
-        if (cmd)
-            cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
-
-        if (!only_print_args)
+        for (uint32_t opt_set = 0; opt_set < num_option_sets; ++opt_set)
         {
+            uint32_t opt_set_mask;
+            
+            opt_set_mask = 1 << opt_set;
+            if (opt_set > 0)
+                strm.Printf ("\n");
+            strm.Indent (name);
+
+            // Different option sets may require different args.
+            StreamString args_str;
+            if (cmd)
+                cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
+
             // First go through and print all options that take no arguments as
             // a single string. If a command has "-a" "-b" and "-c", this will show
             // up as [-abc]
@@ -619,24 +619,24 @@ Options::GenerateOptionUsage
                         PrintOption (opt_defs[i], eDisplayBestOption, " ", nullptr, true, strm);
                 }
             }
-        }
-        
-        if (args_str.GetSize() > 0)
-        {
-            if (cmd->WantsRawCommandString() && !only_print_args)
-                strm.Printf(" --");
             
-            strm.Printf (" %s", args_str.GetData());
-            if (only_print_args)
-                break;
+            if (args_str.GetSize() > 0)
+            {
+                if (cmd->WantsRawCommandString() && !only_print_args)
+                    strm.Printf(" --");
+                
+                strm.Printf (" %s", args_str.GetData());
+                if (only_print_args)
+                    break;
+            }
         }
     }
     
     if (cmd &&
-        cmd->WantsRawCommandString() &&
+        (only_print_args || cmd->WantsRawCommandString()) &&
         arguments_str.GetSize() > 0)
     {        
-        strm.PutChar('\n');
+        if (!only_print_args) strm.PutChar('\n');
         strm.Indent(name);
         strm.Printf(" %s", arguments_str.GetData());
     }




More information about the lldb-commits mailing list