[llvm] [libsycl][NFC] Suppress shadow warnings from LLVM headers (PR #225089)

Sergey Semenov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 06:55:19 PDT 2026


https://github.com/sergey-semenov created https://github.com/llvm/llvm-project/pull/225089

The warning for a local variable shadowing a class member is enabled for libsycl, but not LLVM as a whole. Suppress those for included LLVM headers.

>From a86336d4a8cbf4629eea279a05e8880cb9145354 Mon Sep 17 00:00:00 2001
From: Sergey Semenov <sergey.semenov at intel.com>
Date: Mon, 21 Sep 2026 06:13:39 -0700
Subject: [PATCH] [libsycl][NFC] Suppress shadow warnings from LLVM headers

The warning for a local variable shadowing a class member is enabled
for libsycl, but not LLVM as a whole. Suppress those for included LLVM
headers.
---
 libsycl/src/detail/device_image_wrapper.hpp | 4 ++++
 libsycl/src/detail/program_manager.cpp      | 4 ++++
 libsycl/src/detail/program_manager.hpp      | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/libsycl/src/detail/device_image_wrapper.hpp b/libsycl/src/detail/device_image_wrapper.hpp
index 5d639a2fe2970..510f075649150 100644
--- a/libsycl/src/detail/device_image_wrapper.hpp
+++ b/libsycl/src/detail/device_image_wrapper.hpp
@@ -17,9 +17,13 @@
 
 #include <sycl/__impl/detail/config.hpp>
 
+// Suppress some additional warnings enabled in libsycl for LLVM headers.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <llvm/Object/OffloadBinary.h>
 
 #include <OffloadAPI.h>
+#pragma GCC diagnostic pop
 
 #include <memory>
 #include <string_view>
diff --git a/libsycl/src/detail/program_manager.cpp b/libsycl/src/detail/program_manager.cpp
index c594f8fe6542e..78e79c310fb99 100644
--- a/libsycl/src/detail/program_manager.cpp
+++ b/libsycl/src/detail/program_manager.cpp
@@ -15,7 +15,11 @@
 #include <detail/device_impl.hpp>
 #include <detail/offload/offload_utils.hpp>
 
+// Suppress some additional warnings enabled in libsycl for LLVM headers.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <llvm/Frontend/Offloading/Utility.h>
+#pragma GCC diagnostic pop
 
 _LIBSYCL_BEGIN_NAMESPACE_SYCL
 namespace detail {
diff --git a/libsycl/src/detail/program_manager.hpp b/libsycl/src/detail/program_manager.hpp
index 64df1834fc8cc..0e94ed1d69b98 100644
--- a/libsycl/src/detail/program_manager.hpp
+++ b/libsycl/src/detail/program_manager.hpp
@@ -21,9 +21,13 @@
 #include <detail/device_image_wrapper.hpp>
 #include <detail/device_kernel_info.hpp>
 
+// Suppress some additional warnings enabled in libsycl for LLVM headers.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <llvm/Object/OffloadBinary.h>
 
 #include <OffloadAPI.h>
+#pragma GCC diagnostic pop
 
 #include <memory>
 #include <mutex>



More information about the llvm-commits mailing list