[lld] [lld] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (PR #163701)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 22:38:12 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/163701

This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]],
introduced as part of C++17.


>From 55f07c824eb9ceeca263f2349a341688993de192 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 15 Oct 2025 08:27:03 -0700
Subject: [PATCH] [lld] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]]
 (NFC)

This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]],
introduced as part of C++17.
---
 lld/ELF/Symbols.cpp  | 2 +-
 lld/MachO/Driver.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index de839795c50d7..220ec99c22e6f 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -35,7 +35,7 @@ template <typename T> struct AssertSymbol {
                 "SymbolUnion not aligned enough");
 };
 
-LLVM_ATTRIBUTE_UNUSED static inline void assertSymbols() {
+[[maybe_unused]] static inline void assertSymbols() {
   AssertSymbol<Defined>();
   AssertSymbol<CommonSymbol>();
   AssertSymbol<Undefined>();
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 94f441b7643a7..bfd35aef72b58 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -355,7 +355,7 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
     // Reference all file's mmap'd pages to load them into memory.
     for (const char *page = buff.data(), *end = page + buff.size(); page < end;
          page += pageSize) {
-      LLVM_ATTRIBUTE_UNUSED volatile char t = *page;
+      [[maybe_unused]] volatile char t = *page;
       (void)t;
     }
   };



More information about the llvm-commits mailing list