[Lldb-commits] [PATCH] D59819: Make operator==s consistent between c++ and python APIs

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 26 07:29:35 PDT 2019


labath created this revision.
labath added reviewers: jingham, clayborg, zturner.
Herald added a subscriber: jdoerfert.

modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.

This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.

The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.

This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).


https://reviews.llvm.org/D59819

Files:
  include/lldb/API/SBAddress.h
  include/lldb/API/SBFileSpec.h
  include/lldb/API/SBWatchpoint.h
  scripts/Python/modify-python-lldb.py
  scripts/interface/SBAddress.i
  scripts/interface/SBBreakpoint.i
  scripts/interface/SBFileSpec.i
  scripts/interface/SBModule.i
  scripts/interface/SBWatchpoint.i
  scripts/lldb.swig
  source/API/SBAddress.cpp
  source/API/SBFileSpec.cpp
  source/API/SBWatchpoint.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59819.192271.patch
Type: text/x-patch
Size: 11349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190326/3dbea296/attachment-0001.bin>


More information about the lldb-commits mailing list