Skip to content

Conversation

@ingomueller-net
Copy link
Contributor

@ingomueller-net ingomueller-net commented Nov 27, 2025

This PR avoids 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).

This PR suppresses a compiler warning, which turns into an error with
`-Werror`, for a variable introduced in llvm#169276 and only used in an
assertion (which is, thus, unused if compiled without assertions).

Signed-off-by: Ingo Müller <ingomueller@google.com>
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 27, 2025
@ingomueller-net ingomueller-net changed the title [clang:ast] Suppress warning for unused var without assertions. [clang:ast] Suppress warning for unused var without assertions. (NFC) Nov 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-clang

Author: Ingo Müller (ingomueller-net)

Changes

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).


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

1 Files Affected:

  • (modified) clang/lib/AST/ExprConstant.cpp (+1)
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();


QualType SourceTy = Call->getArg(0)->getType();
QualType CountTy = Call->getArg(1)->getType();
assert(SourceTy->isVectorType() && CountTy->isVectorType());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(SourceTy->isVectorType() && CountTy->isVectorType());
assert(SourceTy->isVectorType() && Call->getArg(1)->getType()->isVectorType());

Signed-off-by: Ingo Müller <ingomueller@google.com>
@ingomueller-net ingomueller-net changed the title [clang:ast] Suppress warning for unused var without assertions. (NFC) [clang:ast] Avoid warning for unused var without assertions. (NFC) Nov 27, 2025
@RKSimon RKSimon enabled auto-merge (squash) November 27, 2025 18:40
@RKSimon RKSimon disabled auto-merge November 27, 2025 18:40
@RKSimon RKSimon enabled auto-merge (squash) November 27, 2025 18:40
@ingomueller-net ingomueller-net merged commit 03c8624 into llvm:main Nov 27, 2025
5 of 9 checks passed
@ingomueller-net ingomueller-net deleted the fix-unused-var-clang-ast branch November 27, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants