[clang] 79341d1 - [Clang] Fix -Wunused-variable in #211482 (#215134)

via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 9 13:38:00 PDT 2026


Author: Aiden Grossman
Date: 2026-08-09T13:37:55-07:00
New Revision: 79341d1983b4b89f96987e9fcce8bd29df335a06

URL: https://github.com/llvm/llvm-project/commit/79341d1983b4b89f96987e9fcce8bd29df335a06
DIFF: https://github.com/llvm/llvm-project/commit/79341d1983b4b89f96987e9fcce8bd29df335a06.diff

LOG: [Clang] Fix -Wunused-variable in #211482 (#215134)

This is only used in asserts, so fails in a release build without
asserts with -Werror -Wunused-variable with the latest clang.

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprCXX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 6cc80c8254a78..a76146a8d914f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2965,12 +2965,12 @@ ImplicitAllocationArguments::ImplicitAllocationArguments(
       PassAlignment(alignedAllocationModeFromBool(AlignArg)),
       IsMSVCCompatibilityFallback(IsMSVCCompatibilityFallback),
       ArgumentCount(0) {
-  ASTContext &Ctx = SemaRef.getASTContext();
   if (TypeIdentityArg) {
     assert(SemaRef.isStdTypeIdentity(TypeIdentityArg->getType(), nullptr));
     ImplicitArguments[ArgumentCount++] = TypeIdentityArg;
   }
   assert(SizeArg);
+  [[maybe_unused]] ASTContext &Ctx = SemaRef.getASTContext();
   assert(Ctx.hasSameType(SizeArg->getType(), Ctx.getSizeType()));
   ImplicitArguments[ArgumentCount++] = SizeArg;
   if (AlignArg) {


        


More information about the cfe-commits mailing list