Skip to content

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

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
Apr 28, 2025

Conversation

AmrDeveloper
Copy link
Member

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

@AmrDeveloper AmrDeveloper marked this pull request as ready for review April 26, 2025 17:00
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Apr 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 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/137466.diff

2 Files Affected:

  • (modified) clang/lib/CIR/CodeGen/CIRGenExpr.cpp (+3-3)
  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+1-1)
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 0a518c0fd935d..ff14798b9d34c 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -311,7 +311,7 @@ LValue CIRGenFunction::emitLValueForField(LValue base, const FieldDecl *field) {
   assert(!cir::MissingFeatures::opTBAA());
 
   Address addr = base.getAddress();
-  if (auto *classDef = dyn_cast<CXXRecordDecl>(rec)) {
+  if (isa<CXXRecordDecl>(rec)) {
     cgm.errorNYI(field->getSourceRange(), "emitLValueForField: C++ class");
     return LValue();
   }
@@ -701,7 +701,7 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
 }
 
 LValue CIRGenFunction::emitMemberExpr(const MemberExpr *e) {
-  if (auto *vd = dyn_cast<VarDecl>(e->getMemberDecl())) {
+  if (isa<VarDecl>(e->getMemberDecl())) {
     cgm.errorNYI(e->getSourceRange(), "emitMemberExpr: VarDecl");
     return LValue();
   }
@@ -734,7 +734,7 @@ LValue CIRGenFunction::emitMemberExpr(const MemberExpr *e) {
     return lv;
   }
 
-  if (const auto *fd = dyn_cast<FunctionDecl>(nd)) {
+  if (isa<FunctionDecl>(nd)) {
     cgm.errorNYI(e->getSourceRange(), "emitMemberExpr: FunctionDecl");
     return LValue();
   }
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 8aa57d1dbf9b3..b9cc2da583009 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -366,7 +366,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
                                            bool isTentative) {
   const QualType astTy = vd->getType();
   const mlir::Type type = convertType(vd->getType());
-  if (clang::IdentifierInfo *identifier = vd->getIdentifier()) {
+  if (vd->getIdentifier()) {
     StringRef name = getMangledName(GlobalDecl(vd));
     auto varOp =
         builder.create<cir::GlobalOp>(getLoc(vd->getSourceRange()), name, type);

Copy link
Contributor

@xlauko xlauko left a comment

Choose a reason for hiding this comment

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

lgtm

@AmrDeveloper AmrDeveloper merged commit e44f776 into llvm:main Apr 28, 2025
16 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 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.

4 participants