https://github.com/flash1729 created 
https://github.com/llvm/llvm-project/pull/202980

Two frontend templates trip `-Wunused-template`.

In `ASTUnit.cpp`, `moveOnNoError` is an unused duplicate (the live copy lives 
in `PrecompiledPreamble.cpp`), so it's removed.

In `CompilerInvocation.cpp`, `mergeMaskValue` and `extractMaskValue` are the 
option-marshalling helpers that `OptParser.td` names for bitfield options. No 
option currently uses that kind, so they never instantiate. They're kept and 
marked `[[maybe_unused]]`, since deleting them would break any future bitfield 
option.

NFC.

Part of #202945.

>From 3a659d731b49940bbedc2369244aceaf7e91bf43 Mon Sep 17 00:00:00 2001
From: flash1729 <[email protected]>
Date: Wed, 10 Jun 2026 19:27:33 +0530
Subject: [PATCH] [clang] Fix -Wunused-template in frontend helpers (NFC)

Two frontend templates trip `-Wunused-template`.

In `ASTUnit.cpp`, `moveOnNoError` is an unused duplicate (the live copy lives in
`PrecompiledPreamble.cpp`), so it's removed.

In `CompilerInvocation.cpp`, `mergeMaskValue` and `extractMaskValue` are the
option-marshalling helpers that `OptParser.td` names for bitfield options. No
option currently uses that kind, so they never instantiate. They're kept and
marked `[[maybe_unused]]`, since deleting them would break any future bitfield
option.

NFC.

Part of #202945.
---
 clang/lib/Frontend/ASTUnit.cpp            | 8 --------
 clang/lib/Frontend/CompilerInvocation.cpp | 5 +++--
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 898405b4e5809..2974cf2660184 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -142,14 +142,6 @@ static std::unique_ptr<T> 
valueOrNull(llvm::ErrorOr<std::unique_ptr<T>> Val) {
   return std::move(*Val);
 }
 
-template <class T>
-static bool moveOnNoError(llvm::ErrorOr<T> Val, T &Output) {
-  if (!Val)
-    return false;
-  Output = std::move(*Val);
-  return true;
-}
-
 /// Get a source buffer for \p MainFilePath, handling all file-to-file
 /// and file-to-buffer remappings inside \p Invocation.
 static std::unique_ptr<llvm::MemoryBuffer>
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 1df45a3572df0..47cdcad377d06 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -515,7 +515,8 @@ static T mergeForwardValue(T KeyPath, U Value) {
   return static_cast<T>(Value);
 }
 
-template <typename T, typename U> static T mergeMaskValue(T KeyPath, U Value) {
+template <typename T, typename U>
+[[maybe_unused]] static T mergeMaskValue(T KeyPath, U Value) {
   return KeyPath | Value;
 }
 
@@ -524,7 +525,7 @@ template <typename T> static T extractForwardValue(T 
KeyPath) {
 }
 
 template <typename T, typename U, U Value>
-static T extractMaskValue(T KeyPath) {
+[[maybe_unused]] static T extractMaskValue(T KeyPath) {
   return ((KeyPath & Value) == Value) ? static_cast<T>(Value) : T();
 }
 

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

Reply via email to