[clang] [clang:ast] Avoid warning for unused var without assertions. (NFC) (PR #169822)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 27 10:40:12 PST 2025
Ingo =?utf-8?q?Müller?= <ingomueller at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/169822 at github.com>
https://github.com/RKSimon updated https://github.com/llvm/llvm-project/pull/169822
>From b386d2eb54b392ff399a4f4022132cf5dd4a15fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Thu, 27 Nov 2025 15:37:07 +0000
Subject: [PATCH 1/2] [clang:ast] Suppress warning for unused var without
assertions.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This PR suppresses a compiler warning, which turns into an error with
`-Werror`, for a variable introduced in #169276 and only used in an
assertion (which is, thus, unused if compiled without assertions).
Signed-off-by: Ingo Müller <ingomueller at google.com>
---
clang/lib/AST/ExprConstant.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7b9380de6834d..431b58f4627bb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12181,6 +12181,7 @@ static bool evalShiftWithCount(
QualType SourceTy = Call->getArg(0)->getType();
QualType CountTy = Call->getArg(1)->getType();
assert(SourceTy->isVectorType() && CountTy->isVectorType());
+ (void)CountTy;
QualType DestEltTy = SourceTy->castAs<VectorType>()->getElementType();
unsigned DestEltWidth = Source.getVectorElt(0).getInt().getBitWidth();
>From f294c8c6d3d7d0c4110f7c2800fdd9e0b2e1f31e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Thu, 27 Nov 2025 15:52:38 +0000
Subject: [PATCH 2/2] Replace variable instead of suppressing warning.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Ingo Müller <ingomueller at google.com>
---
clang/lib/AST/ExprConstant.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 431b58f4627bb..cab17ecdc7b29 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12179,9 +12179,8 @@ static bool evalShiftWithCount(
assert(Call->getNumArgs() == 2);
QualType SourceTy = Call->getArg(0)->getType();
- QualType CountTy = Call->getArg(1)->getType();
- assert(SourceTy->isVectorType() && CountTy->isVectorType());
- (void)CountTy;
+ assert(SourceTy->isVectorType() &&
+ Call->getArg(1)->getType()->isVectorType());
QualType DestEltTy = SourceTy->castAs<VectorType>()->getElementType();
unsigned DestEltWidth = Source.getVectorElt(0).getInt().getBitWidth();
More information about the cfe-commits
mailing list