Skip to content

[CIR][NFC] Fix an unused variable warning #145922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

AmrDeveloper
Copy link
Member

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

@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Jun 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 26, 2025

@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Amr Hesham (AmrDeveloper)

Changes

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

Copy link
Contributor

@andykaylor andykaylor left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. For some reason my compiler (clang 14) doesn't warn about these situations.

@AmrDeveloper
Copy link
Member Author

Thanks for the fix. For some reason my compiler (clang 14) doesn't warn about these situations.

I got them when i build the project, I am using Clang 20 ^_^

@AmrDeveloper AmrDeveloper merged commit 720d7e0 into llvm:main Jun 26, 2025
8 of 10 checks passed
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't
referenced again.
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't
referenced again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants