[llvm] [llvm] Mark IOSandbox::ScopedSetting nodiscard and maybe_unused (PR #194602)
Balázs Benics via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 05:06:09 PDT 2026
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/194602
The goal is to have the same attributes on ScopedSetting regardless if this cmake setting is enabled or not.
Both of these should have nodiscard and maybe_unused attributes.
>From c1927ebdb1985a11b1f8daf6dcaaaeae2f0996da Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Tue, 28 Apr 2026 12:57:31 +0100
Subject: [PATCH] [llvm] Mark IOSandbox::ScopedSetting nodiscard and
maybe_unused
The goal is to have the same attributes on ScopedSetting regardless if
this cmake setting is enabled or not.
Both of these should have nodiscard and maybe_unused attributes.
---
llvm/include/llvm/Support/IOSandbox.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Support/IOSandbox.h b/llvm/include/llvm/Support/IOSandbox.h
index 3a68f67ec20eb..38fa7c5aff887 100644
--- a/llvm/include/llvm/Support/IOSandbox.h
+++ b/llvm/include/llvm/Support/IOSandbox.h
@@ -17,7 +17,7 @@
namespace llvm::sys::sandbox {
inline LLVM_THREAD_LOCAL bool Enabled = false;
-struct ScopedSetting {
+struct [[nodiscard, maybe_unused]] ScopedSetting {
SaveAndRestore<bool> Impl;
};
inline ScopedSetting scopedEnable() { return {{Enabled, true}}; }
@@ -31,7 +31,7 @@ inline void violationIfEnabled() {
#else
namespace llvm::sys::sandbox {
-struct [[maybe_unused]] ScopedSetting {};
+struct [[nodiscard, maybe_unused]] ScopedSetting {};
inline ScopedSetting scopedEnable() { return {}; }
inline ScopedSetting scopedDisable() { return {}; }
inline void violationIfEnabled() {}
More information about the llvm-commits
mailing list