-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR][NFC] Fix an unused variable warning #140783
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
Conversation
|
@llvm/pr-subscribers-clangir Author: Amr Hesham (AmrDeveloper) ChangesThis fixes a warning where a variable assigned in 'if' statement wasn't referenced again, and where else is used when 'if' has returns statement in the if-else statement Full diff: https://github.com/llvm/llvm-project/pull/140783.diff 1 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
index 906c212f0fa8a..aad08a59624d2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
@@ -113,7 +113,7 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
thisPtr = emitLValue(base);
}
- if (const CXXConstructorDecl *ctor = dyn_cast<CXXConstructorDecl>(md)) {
+ if (isa<CXXConstructorDecl>(md)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: constructor call");
return RValue::get(nullptr);
@@ -127,29 +127,29 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: trivial assignment");
return RValue::get(nullptr);
- } else {
- assert(md->getParent()->mayInsertExtraPadding() &&
- "unknown trivial member function");
}
+
+ assert(md->getParent()->mayInsertExtraPadding() &&
+ "unknown trivial member function");
}
// Compute the function type we're calling
const CXXMethodDecl *calleeDecl = md;
const CIRGenFunctionInfo *fInfo = nullptr;
- if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
+ if (isa<CXXDestructorDecl>(calleeDecl)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
return RValue::get(nullptr);
- } else {
- fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
}
+ fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
+
mlir::Type ty = cgm.getTypes().getFunctionType(*fInfo);
assert(!cir::MissingFeatures::sanitizers());
assert(!cir::MissingFeatures::emitTypeCheck());
- if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
+ if (isa<CXXDestructorDecl>(calleeDecl)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
return RValue::get(nullptr);
|
|
@llvm/pr-subscribers-clang Author: Amr Hesham (AmrDeveloper) ChangesThis fixes a warning where a variable assigned in 'if' statement wasn't referenced again, and where else is used when 'if' has returns statement in the if-else statement Full diff: https://github.com/llvm/llvm-project/pull/140783.diff 1 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
index 906c212f0fa8a..aad08a59624d2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXExpr.cpp
@@ -113,7 +113,7 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
thisPtr = emitLValue(base);
}
- if (const CXXConstructorDecl *ctor = dyn_cast<CXXConstructorDecl>(md)) {
+ if (isa<CXXConstructorDecl>(md)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: constructor call");
return RValue::get(nullptr);
@@ -127,29 +127,29 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: trivial assignment");
return RValue::get(nullptr);
- } else {
- assert(md->getParent()->mayInsertExtraPadding() &&
- "unknown trivial member function");
}
+
+ assert(md->getParent()->mayInsertExtraPadding() &&
+ "unknown trivial member function");
}
// Compute the function type we're calling
const CXXMethodDecl *calleeDecl = md;
const CIRGenFunctionInfo *fInfo = nullptr;
- if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
+ if (isa<CXXDestructorDecl>(calleeDecl)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
return RValue::get(nullptr);
- } else {
- fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
}
+ fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
+
mlir::Type ty = cgm.getTypes().getFunctionType(*fInfo);
assert(!cir::MissingFeatures::sanitizers());
assert(!cir::MissingFeatures::emitTypeCheck());
- if (const auto *dtor = dyn_cast<CXXDestructorDecl>(calleeDecl)) {
+ if (isa<CXXDestructorDecl>(calleeDecl)) {
cgm.errorNYI(ce->getSourceRange(),
"emitCXXMemberOrOperatorMemberCallExpr: destructor call");
return RValue::get(nullptr);
|
xlauko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
andykaylor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes!
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again, and where else is used when 'if' has returns statement in the if-else statement