summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-03-13 13:45:14 +0000
committerPavel Labath <pavel@labath.sk>2019-03-13 13:45:14 +0000
commit01b595c0cb78764384be769236af2e23cc11ab52 (patch)
tree85cda697198a12092b43444020baa61c73cc16c1
parent867c2a7d369c6a067cadead7cd94ad5b391f14b4 (diff)
downloadbcm5719-llvm-01b595c0cb78764384be769236af2e23cc11ab52.tar.gz
bcm5719-llvm-01b595c0cb78764384be769236af2e23cc11ab52.zip
Fix/unify SBType comparison
Summary: In my next step at cleaning up modify-python-lldb.py, I started focusing on equality comparison. To my surprise, I found out that both python and c++ versions of the SBType class implement equality comparison, but each one does it differently. While the python version was implemented in terms of type name equality, the C++ one used a deep comparison on the underlying objects. Removing the python version caused one test to fail (TestTypeList). This happened because the c++ version of operator== boiled down to TypePair::operator==, which contains two items: the compiler_type and type_sp. In this case, the compiler_type was identical, but one of the objects had the type_sp field unset. I tried fixing the code so that both objects keep their type_sp member, but it wasn't easy, because there are so many operations which just work with the CompilerType types, and so any operation on the SBType (the test in question was doing GetPointeeType on the type of one variable and expecting it to match the type of another variable), cause that second member to be lost. So instead, here I relax the equality comparison on the TypePair class. Now, this class ignores the type_sp for the purposes of comparison, and uses the CompilerType only. This seems reasonable, as each TypeSP is able to convert itself to a CompilerType. Reviewers: clayborg, aprantl, serge-sans-paille Subscribers: jdoerfert, lldb-commits Differential Revision: https://reviews.llvm.org/D59217 llvm-svn: 356048
-rw-r--r--lldb/include/lldb/Symbol/Type.h8
-rw-r--r--lldb/scripts/Python/modify-python-lldb.py1
-rw-r--r--lldb/scripts/interface/SBType.i4
3 files changed, 6 insertions, 7 deletions
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index f4638ffd333..5bb3a09de85 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -256,14 +256,10 @@ public:
explicit operator bool() const { return IsValid(); }
bool operator==(const TypePair &rhs) const {
- return compiler_type == rhs.compiler_type &&
- type_sp.get() == rhs.type_sp.get();
+ return compiler_type == rhs.compiler_type;
}
- bool operator!=(const TypePair &rhs) const {
- return compiler_type != rhs.compiler_type ||
- type_sp.get() != rhs.type_sp.get();
- }
+ bool operator!=(const TypePair &rhs) const { return !(*this == rhs); }
void Clear() {
compiler_type.Clear();
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py
index 8852ad4166f..7a2c58ded4b 100644
--- a/lldb/scripts/Python/modify-python-lldb.py
+++ b/lldb/scripts/Python/modify-python-lldb.py
@@ -143,7 +143,6 @@ e = {'SBAddress': ['GetFileAddress', 'GetModule'],
'SBWatchpoint': ['GetID'],
'SBFileSpec': ['GetFilename', 'GetDirectory'],
'SBModule': ['GetFileSpec', 'GetUUIDString'],
- 'SBType': ['GetByteSize', 'GetName']
}
diff --git a/lldb/scripts/interface/SBType.i b/lldb/scripts/interface/SBType.i
index 79df1a56034..983465e6f8f 100644
--- a/lldb/scripts/interface/SBType.i
+++ b/lldb/scripts/interface/SBType.i
@@ -322,6 +322,10 @@ public:
uint32_t
GetTypeFlags ();
+ bool operator==(lldb::SBType &rhs);
+
+ bool operator!=(lldb::SBType &rhs);
+
%pythoncode %{
def template_arg_array(self):
num_args = self.num_template_args
OpenPOWER on IntegriCloud