diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 14bd35cf05c6..5ef83130016a 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -101,6 +101,9 @@ public: SBTypeList& operator = (const SBTypeList& rhs); + bool + IsValid() const; + void Append (const SBType& type); diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i index 48f20f1f2d62..3086338d800e 100644 --- a/lldb/scripts/Python/interface/SBType.i +++ b/lldb/scripts/Python/interface/SBType.i @@ -156,6 +156,9 @@ class SBTypeList public: SBTypeList(); + bool + IsValid() const; + void Append(const SBType& type); diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 64c64acb97d0..582eceec1e32 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -323,6 +323,12 @@ SBTypeList::SBTypeList(const SBTypeList& rhs) : Append(rhs.GetTypeAtIndex(i)); } +bool +SBTypeList::IsValid () const +{ + return (m_opaque_ap.get() != NULL); +} + SBTypeList& SBTypeList::operator = (const SBTypeList& rhs) { diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py index 69a455061103..c41fc16cbf24 100644 --- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py +++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py @@ -313,13 +313,11 @@ class APIDefaultConstructorTestCase(TestBase): @python_api_test def test_SBTypeList(self): + """SBTypeList object is valid after default construction.""" obj = lldb.SBTypeList() if self.TraceOn(): print obj - # SBTypeList does not have IsValid() method defined. It's always valid - # in a sense. So the Python's truth value testing in turn delegates to - # __len__() method, which is defined for SBTypeList, and returns 0. - self.assertFalse(obj) + self.assertTrue(obj) @python_api_test def test_SBValue(self):