Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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

This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]],
introduced as part of C++17.
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2025

@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-macho

Author: Kazu Hirata (kazutakahirata)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/163701.diff

2 Files Affected:

  • (modified) lld/ELF/Symbols.cpp (+1-1)
  • (modified) lld/MachO/Driver.cpp (+1-1)
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;
     }
   };

@kazutakahirata kazutakahirata merged commit ffca377 into llvm:main Oct 16, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251015_maybe_unused_lld branch October 16, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants