Fix an issue with nested aliases where the help system wouldn't correctly track the...
authorEnrico Granata <egranata@apple.com>
Fri, 25 Mar 2016 21:59:06 +0000 (21:59 +0000)
committerEnrico Granata <egranata@apple.com>
Fri, 25 Mar 2016 21:59:06 +0000 (21:59 +0000)
(and I hope I typed the word 'alias' enough times in this commit message :-)

llvm-svn: 264468

lldb/include/lldb/Interpreter/CommandAlias.h
lldb/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py
lldb/source/Interpreter/CommandAlias.cpp

index f14ac52..d48719f 100644 (file)
@@ -106,6 +106,10 @@ public:
     std::pair<lldb::CommandObjectSP, OptionArgVectorSP>
     Desugar ();
     
+protected:
+    bool
+    IsNestedAlias ();
+    
 private:
     lldb::CommandObjectSP m_underlying_command_sp;
     std::string m_option_string;
index fb3a18e..16ee2e5 100644 (file)
@@ -46,6 +46,8 @@ class NestedAliasTestCase(TestBase):
         def cleanup():
             self.runCmd('command unalias read', check=False)
             self.runCmd('command unalias rd', check=False)
+            self.runCmd('command unalias fo', check=False)
+            self.runCmd('command unalias foself', check=False)
 
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
@@ -58,3 +60,9 @@ class NestedAliasTestCase(TestBase):
 
         self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadfeed'], matching=False)
         self.expect('rd `&my_ptr[0]`', substrs=['deadfeed'], matching=False)
+
+        self.runCmd('command alias fo frame variable -O --')
+        self.runCmd('command alias foself fo self')
+        
+        self.expect('help foself', substrs=['--show-all-children', '--raw-output'], matching=False)
+        self.expect('help foself', substrs=['Show frame variables.'], matching=True)
index f7d8e8e..a915d63 100644 (file)
@@ -236,11 +236,22 @@ CommandAlias::IsDashDashCommand ()
                     break;
                 }
             }
+            // if this is a nested alias, it may be adding arguments on top of an already dash-dash alias
+            if ((m_is_dashdash_alias == eLazyBoolNo) && IsNestedAlias())
+                m_is_dashdash_alias = (GetUnderlyingCommand()->IsDashDashCommand() ? eLazyBoolYes : eLazyBoolNo);
         }
     }
     return (m_is_dashdash_alias == eLazyBoolYes);
 }
 
+bool
+CommandAlias::IsNestedAlias ()
+{
+    if (GetUnderlyingCommand())
+        return GetUnderlyingCommand()->IsAlias();
+    return false;
+}
+
 std::pair<lldb::CommandObjectSP, OptionArgVectorSP>
 CommandAlias::Desugar ()
 {