Skip to content

Commit 6f25614

Browse files
authored
[CIR] Clean up warnings (llvm#129604)
Previous CIR commits have introduced a few warnings. This change fixes those. There are still warnings present when building with GCC because GCC warns about virtual functions being hidden in the mlir::OpConversion classes. A separate discussion will be required to decide what should be done about those.
1 parent 9295b03 commit 6f25614

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void CIRGenFunction::emitAutoVarInit(const clang::VarDecl &d) {
6262

6363
void CIRGenFunction::emitAutoVarCleanups(const clang::VarDecl &d) {
6464
// Check the type for a cleanup.
65-
if (QualType::DestructionKind dtorKind = d.needsDestruction(getContext()))
65+
if (d.needsDestruction(getContext()))
6666
cgm.errorNYI(d.getSourceRange(), "emitAutoVarCleanups: type cleanup");
6767

6868
assert(!cir::MissingFeatures::opAllocaPreciseLifetime());

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
107107

108108
cgf.getCIRGenModule().errorNYI(loc,
109109
"emitScalarConversion for unequal types");
110+
return {};
110111
}
111112
};
112113

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "CIRGenFunction.h"
1414

1515
#include "CIRGenCall.h"
16+
#include "CIRGenValue.h"
1617
#include "mlir/IR/Location.h"
1718
#include "clang/AST/GlobalDecl.h"
1819
#include "clang/CIR/MissingFeatures.h"
@@ -134,10 +135,9 @@ mlir::Location CIRGenFunction::getLoc(mlir::Location lhs, mlir::Location rhs) {
134135
return mlir::FusedLoc::get(locs, metadata, &getMLIRContext());
135136
}
136137

137-
mlir::LogicalResult CIRGenFunction::declare(mlir::Value addrVal,
138-
const Decl *var, QualType ty,
139-
mlir::Location loc,
140-
CharUnits alignment, bool isParam) {
138+
void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
139+
mlir::Location loc, CharUnits alignment,
140+
bool isParam) {
141141
const auto *namedVar = dyn_cast_or_null<NamedDecl>(var);
142142
assert(namedVar && "Needs a named decl");
143143
assert(!cir::MissingFeatures::cgfSymbolTable());
@@ -147,8 +147,6 @@ mlir::LogicalResult CIRGenFunction::declare(mlir::Value addrVal,
147147
allocaOp.setInitAttr(mlir::UnitAttr::get(&getMLIRContext()));
148148
if (ty->isReferenceType() || ty.isConstQualified())
149149
allocaOp.setConstantAttr(mlir::UnitAttr::get(&getMLIRContext()));
150-
151-
return mlir::success();
152150
}
153151

154152
void CIRGenFunction::startFunction(GlobalDecl gd, QualType returnType,
@@ -306,7 +304,7 @@ LValue CIRGenFunction::emitLValue(const Expr *e) {
306304
getCIRGenModule().errorNYI(e->getSourceRange(),
307305
std::string("l-value not implemented for '") +
308306
e->getStmtClassName() + "'");
309-
break;
307+
return LValue();
310308
case Expr::DeclRefExprClass:
311309
return emitDeclRefLValue(cast<DeclRefExpr>(e));
312310
}

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class CIRGenFunction : public CIRGenTypeCache {
9797
private:
9898
/// Declare a variable in the current scope, return success if the variable
9999
/// wasn't declared yet.
100-
mlir::LogicalResult declare(mlir::Value addrVal, const clang::Decl *var,
101-
clang::QualType ty, mlir::Location loc,
102-
clang::CharUnits alignment, bool isParam = false);
100+
void declare(mlir::Value addrVal, const clang::Decl *var, clang::QualType ty,
101+
mlir::Location loc, clang::CharUnits alignment,
102+
bool isParam = false);
103103

104104
public:
105105
mlir::Value emitAlloca(llvm::StringRef name, mlir::Type ty,

0 commit comments

Comments
 (0)