[lldb] Deobfuscate python-swigsafecast.swig
authorPavel Labath <pavel@labath.sk>
Thu, 18 Nov 2021 10:12:19 +0000 (11:12 +0100)
committerPavel Labath <pavel@labath.sk>
Thu, 18 Nov 2021 18:27:09 +0000 (19:27 +0100)
commitf1127914d3dcbfbe3bbd943ab84bea3805164295
tree47d85086b552f6e8dfedabd9e7a4ba41b7c9dccb
parentea12c2cb9c4221095abfb2af7148140783040734
[lldb] Deobfuscate python-swigsafecast.swig

This file was way more complicated than it needed to be.

This patch removes the automagic reference-to-pointer delegation and
replaces the template specializations with regular free functions
(taking reference arguments).

The reason I chose references is twofold:
- there are more arguments being passed by reference than by pointer
- the reference arguments make it more obvious that there is a lot of
  leaking going on in there.

Currently, the code was assuming that the pointer arguments have some
kind of a special meaning and that pointer functions take ownership of
their arguments, which isn't true (it's possible it was true at some
point in the past, I haven't done the archeology).

This makes it easier to implement proper lifetime management in
follow-up patches.

Differential Revision: https://reviews.llvm.org/D114150
lldb/bindings/python/python-swigsafecast.swig
lldb/bindings/python/python-wrapper.swig