[all-commits] [llvm/llvm-project] 9a14ad: [lldb] Remove 'extern "C"' from the lldb-swig-pyth...

Pavel Labath via All-commits all-commits at lists.llvm.org
Tue Nov 30 02:06:25 PST 2021


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

  Changed paths:
    M lldb/bindings/python/python-wrapper.swig
    M lldb/bindings/python/python.swig
    M lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
    M lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

  Log Message:
  -----------
  [lldb] Remove 'extern "C"' from the lldb-swig-python interface

The LLDBSWIGPython functions had (at least) two problems:
- There wasn't a single source of truth (a header file) for the
  prototypes of these functions. This meant that subtle differences
  in copies of function declarations could go by undetected. And
  not-so-subtle differences would result in strange runtime failures.
- All of the declarations had to have an extern "C" interface, because
  the function definitions were being placed inside and extert "C" block
  generated by swig.

This patch fixes both problems by moving the function definitions to the
%header block of the swig files. This block is not surrounded by extern
"C", and seems more appropriate anyway, as swig docs say it is meant for
"user-defined support code" (whereas the previous %wrapper code was for
automatically-generated wrappers).

It also puts the declarations into the SWIGPythonBridge header file
(which seems to have been created for this purpose), and ensures it is
included by all code wishing to define or use these functions. This
means that any differences in the declaration become a compiler error
instead of a runtime failure.

Differential Revision: https://reviews.llvm.org/D114369




More information about the All-commits mailing list