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

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 26 09:27:29 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Amr Hesham (AmrDeveloper)

<details>
<summary>Changes</summary>

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

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


1 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+3-3) 


``````````diff
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);

``````````

</details>


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


More information about the cfe-commits mailing list