[clang] [CIR][NFC] Fix an unused variable warning (PR #145922)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 26 09:26:36 PDT 2025


https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/145922

This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.

>From 333265ec9f6b3cbcb726ff96aebe97c922fa02aa Mon Sep 17 00:00:00 2001
From: AmrDeveloper <amr96 at programmer.net>
Date: Thu, 26 Jun 2025 18:25:38 +0200
Subject: [PATCH] [CIR][NFC] Fix an unused variable warning

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index f24bee44f26a7..44ec99b6a085a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -427,9 +427,9 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
   setNonAliasAttributes(gd, funcOp);
   assert(!cir::MissingFeatures::opFuncAttributesForDefinition());
 
-  if (const ConstructorAttr *ca = funcDecl->getAttr<ConstructorAttr>())
+  if (funcDecl->getAttr<ConstructorAttr>())
     errorNYI(funcDecl->getSourceRange(), "constructor attribute");
-  if (const DestructorAttr *da = funcDecl->getAttr<DestructorAttr>())
+  if (funcDecl->getAttr<DestructorAttr>())
     errorNYI(funcDecl->getSourceRange(), "destructor attribute");
 
   if (funcDecl->getAttr<AnnotateAttr>())
@@ -1055,7 +1055,7 @@ cir::GlobalLinkageKind CIRGenModule::getFunctionLinkage(GlobalDecl gd) {
 
   GVALinkage linkage = astContext.GetGVALinkageForFunction(fd);
 
-  if (const auto *dtor = dyn_cast<CXXDestructorDecl>(fd))
+  if (isa<CXXDestructorDecl>(fd))
     errorNYI(fd->getSourceRange(), "getFunctionLinkage: CXXDestructorDecl");
 
   return getCIRLinkageForDeclarator(fd, linkage, /*IsConstantVariable=*/false);



More information about the cfe-commits mailing list