[Lldb-commits] [PATCH] D115074: [lldb/lua] Suppress warnings about C-linkage in generated wrapper

Dimitry Andric via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 3 12:46:39 PST 2021


dim created this revision.
dim added reviewers: tammela, siger-young, emaste.
dim requested review of this revision.
Herald added a project: LLDB.

When lldb Lua bindings are enabled, the generated `LLDBWrapLua.cpp` file
generates a compiler warning about C-linkage:

  lldb/LLDBWrapLua.cpp:71170:1: warning: 'LLDBSwigLuaBreakpointCallbackFunction' has C-linkage specified, but returns incomplete type 'llvm::Expected<bool>' which could be incompatible with C

In `lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp` these warnings
are suppressed using a few pragmas. Also Add these to `lua-wrapper.swig`
so they end up in `LLDBWrapLua.cpp`, making the warnings disappear.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115074

Files:
  lldb/bindings/lua/lua-wrapper.swig


Index: lldb/bindings/lua/lua-wrapper.swig
===================================================================
--- lldb/bindings/lua/lua-wrapper.swig
+++ lldb/bindings/lua/lua-wrapper.swig
@@ -21,6 +21,17 @@
 
 %wrapper %{
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
+
+// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has
+// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is
+// incompatible with C
+#if _MSC_VER
+#pragma warning (push)
+#pragma warning (disable : 4190)
+#endif
+
 // This function is called from Lua::CallBreakpointCallback
 SWIGEXPORT llvm::Expected<bool>
 LLDBSwigLuaBreakpointCallbackFunction
@@ -101,6 +112,12 @@
    return stop;
 }
 
+#if _MSC_VER
+#pragma warning (pop)
+#endif
+
+#pragma clang diagnostic pop
+
 SWIGEXPORT void
 LLDBSwigLuaCallLuaLogOutputCallback(const char *str, void *baton) {
    lua_State *L = (lua_State *)baton;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115074.391714.patch
Type: text/x-patch
Size: 950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211203/5a01b2da/attachment.bin>


More information about the lldb-commits mailing list