[Lldb-commits] [lldb] [lldb][Windows] Fix unused function GetModulePath warning with certain Python options (PR #221173)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 4 02:16:01 PDT 2026


https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/221173

If LLDB_PYTHON_DLL_RELATIVE_PATH is OFF, or it is ON and LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is OFF, then GetModulePath is unused.

<...>/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp(32,13): warning: unused function 'GetModulePath' [-Wunused-function]
   32 | std::string GetModulePath(HMODULE module) {
      |             ^~~~~~~~~~~~~
1 warning generated.

Rearrange the macros to define GetModulePath only if both options are enabled.

>From a4fd94b32012836fb7df0d4c5d41cebc365b573c Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at arm.com>
Date: Fri, 4 Sep 2026 09:10:41 +0000
Subject: [PATCH] [lldb][Windows] Fix unused function with certain Python
 options

If LLDB_PYTHON_DLL_RELATIVE_PATH is OFF, or it is ON and
LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME is OFF, then GetModulePath
is unused.

<...>/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp(32,13): warning: unused function 'GetModulePath' [-Wunused-function]
   32 | std::string GetModulePath(HMODULE module) {
      |             ^~~~~~~~~~~~~
1 warning generated.

Rearrange the macros to define GetModulePath only if
both options are enabled.
---
 lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp b/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp
index 360a90ea81599..3f994daa92a0a 100644
--- a/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp
+++ b/lldb/source/Host/windows/PythonRuntimeLoaderWindows.cpp
@@ -28,6 +28,8 @@ namespace lldb_private {
 
 namespace {
 
+#ifdef LLDB_PYTHON_DLL_RELATIVE_PATH
+#ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
 /// Absolute path of \p module, or the running executable when null.
 std::string GetModulePath(HMODULE module) {
   std::vector<WCHAR> buffer(MAX_PATH);
@@ -46,8 +48,8 @@ std::string GetModulePath(HMODULE module) {
   }
   return "";
 }
+#endif // ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
 
-#ifdef LLDB_PYTHON_DLL_RELATIVE_PATH
 std::string ExeRelativeCandidate() {
 #ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
   std::string exe = GetModulePath(nullptr);
@@ -61,9 +63,9 @@ std::string ExeRelativeCandidate() {
   return std::string(path);
 #else
   return "";
-#endif
+#endif // ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
 }
-#endif
+#endif // ifdef LLDB_PYTHON_DLL_RELATIVE_PATH
 
 } // namespace
 



More information about the lldb-commits mailing list