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 <[email protected]>
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
 

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to