[Lldb-commits] [lldb] 40b0fa7 - [LLDB][formatters] ArgInfo::count -> ArgInfo::max_positional_args

Lawrence D'Anna via lldb-commits lldb-commits at lists.llvm.org
Sun Oct 27 16:02:32 PDT 2019


Author: Lawrence D'Anna
Date: 2019-10-27T16:01:46-07:00
New Revision: 40b0fa7ef2123866b2252ef6990040c2707cabe4

URL: https://github.com/llvm/llvm-project/commit/40b0fa7ef2123866b2252ef6990040c2707cabe4
DIFF: https://github.com/llvm/llvm-project/commit/40b0fa7ef2123866b2252ef6990040c2707cabe4.diff

LOG: [LLDB][formatters] ArgInfo::count -> ArgInfo::max_positional_args

Summary:
Move breakpoints from the old, bad ArgInfo::count to the new, better
ArgInfo::max_positional_args.   Soon ArgInfo::count will be no more.

This functionality is tested in `TestFormatters.py`, `TestDataFormatterSynthVal.py`,
`TestDataFormatterSynthType.py`.

You may notice that the old code was passing 0 arguments when count was 1, and passing
1 argument when count is 2.

This is no longer necessary because max_positional_args counts the self pointer
correctly.

Reviewers: labath, jingham, JDevlieghere

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69469

Added: 
    

Modified: 
    lldb/scripts/Python/python-wrapper.swig

Removed: 
    


################################################################################
diff  --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index b7af34221934..5e9a2ba1367c 100644
--- a/lldb/scripts/Python/python-wrapper.swig
+++ b/lldb/scripts/Python/python-wrapper.swig
@@ -495,11 +495,17 @@ LLDBSwigPython_CalculateNumChildren
     if (!pfunc.IsAllocated())
         return 0;
 
+    auto arg_info = pfunc.GetArgInfo();
+    if (!arg_info) {
+        llvm::consumeError(arg_info.takeError());
+        return 0;
+    }
+
     PythonObject result;
-    auto argc = pfunc.GetNumArguments();
-    if (argc.count == 1)
+
+    if (arg_info.get().max_positional_args < 1)
         result = pfunc();
-    else if (argc.count == 2)
+    else
         result = pfunc(PythonInteger(max));
 
     if (!result.IsAllocated())
@@ -511,13 +517,13 @@ LLDBSwigPython_CalculateNumChildren
 
     size_t ret_val = int_result.GetInteger();
 
-    if (PyErr_Occurred())
+    if (PyErr_Occurred()) //FIXME use Expected to catch python exceptions
     {
         PyErr_Print();
         PyErr_Clear();
     }
 
-    if (argc.count == 1)
+    if (arg_info.get().max_positional_args < 1)
         ret_val = std::min(ret_val, static_cast<size_t>(max));
 
     return ret_val;


        


More information about the lldb-commits mailing list