[all-commits] [llvm/llvm-project] f11279: [lldb] Deobfuscate python-swigsafecast.swig

Pavel Labath via All-commits all-commits at lists.llvm.org
Thu Nov 18 10:27:45 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f1127914d3dcbfbe3bbd943ab84bea3805164295
      https://github.com/llvm/llvm-project/commit/f1127914d3dcbfbe3bbd943ab84bea3805164295
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2021-11-18 (Thu, 18 Nov 2021)

  Changed paths:
    M lldb/bindings/python/python-swigsafecast.swig
    M lldb/bindings/python/python-wrapper.swig

  Log Message:
  -----------
  [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




More information about the All-commits mailing list