Skip to content

Commit 9c57aaa

Browse files
bcardosolopeslanza
authored andcommitted
[CIR][NFC] Fix more compiler warnings
1 parent a2a31c1 commit 9c57aaa

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static Address emitPointerWithAlignment(const Expr *expr,
170170

171171
if (cgf.SanOpts.has(SanitizerKind::CFIUnrelatedCast) &&
172172
CE->getCastKind() == CK_BitCast) {
173-
if (auto PT = expr->getType()->getAs<clang::PointerType>())
173+
if (expr->getType()->getAs<clang::PointerType>())
174174
llvm_unreachable("NYI");
175175
}
176176

@@ -476,7 +476,8 @@ LValue CIRGenFunction::emitCompoundLiteralLValue(const CompoundLiteralExpr *E) {
476476
// Block-scope compound literals are destroyed at the end of the enclosing
477477
// scope in C.
478478
if (!getLangOpts().CPlusPlus)
479-
if (QualType::DestructionKind DtorKind = E->getType().isDestructedType())
479+
if ([[maybe_unused]] QualType::DestructionKind DtorKind =
480+
E->getType().isDestructedType())
480481
llvm_unreachable("NYI");
481482

482483
return Result;
@@ -857,7 +858,8 @@ void CIRGenFunction::emitStoreThroughLValue(RValue Src, LValue Dst,
857858
assert(Dst.isSimple() && "only implemented simple");
858859

859860
// There's special magic for assigning into an ARC-qualified l-value.
860-
if (Qualifiers::ObjCLifetime Lifetime = Dst.getQuals().getObjCLifetime()) {
861+
if ([[maybe_unused]] Qualifiers::ObjCLifetime Lifetime =
862+
Dst.getQuals().getObjCLifetime()) {
861863
llvm_unreachable("NYI");
862864
}
863865

clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ static bool castPreservesZero(const CastExpr *CE) {
609609
switch (CE->getCastKind()) {
610610
case CK_HLSLVectorTruncation:
611611
case CK_HLSLArrayRValue:
612+
case CK_HLSLElementwiseCast:
613+
case CK_HLSLAggregateSplatCast:
612614
llvm_unreachable("NYI");
613615
// No-ops.
614616
case CK_NoOp:
@@ -840,7 +842,8 @@ void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
840842
CGF.emitAggExpr(E->getInitializer(), Slot);
841843

842844
if (Destruct)
843-
if (QualType::DestructionKind DtorKind = E->getType().isDestructedType())
845+
if ([[maybe_unused]] QualType::DestructionKind DtorKind =
846+
E->getType().isDestructedType())
844847
llvm_unreachable("NYI");
845848
}
846849

@@ -902,7 +905,7 @@ void AggExprEmitter::VisitLambdaExpr(LambdaExpr *E) {
902905
emitInitializationToLValue(captureInit, LV);
903906

904907
// Push a destructor if necessary.
905-
if (QualType::DestructionKind DtorKind =
908+
if ([[maybe_unused]] QualType::DestructionKind DtorKind =
906909
CurField->getType().isDestructedType()) {
907910
llvm_unreachable("NYI");
908911
}
@@ -1688,8 +1691,7 @@ void CIRGenFunction::emitAggregateCopy(LValue Dest, LValue Src, QualType Ty,
16881691
mlir::Attribute SizeVal = nullptr;
16891692
if (TypeInfo.Width.isZero()) {
16901693
// But note that getTypeInfo returns 0 for a VLA.
1691-
if (auto *VAT = dyn_cast_or_null<VariableArrayType>(
1692-
getContext().getAsArrayType(Ty))) {
1694+
if (isa_and_nonnull<VariableArrayType>(getContext().getAsArrayType(Ty))) {
16931695
llvm_unreachable("VLA is NYI");
16941696
}
16951697
}

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ mlir::Value ComplexExprEmitter::emitCast(CastKind CK, Expr *Op,
484484
case CK_MatrixCast:
485485
case CK_HLSLVectorTruncation:
486486
case CK_HLSLArrayRValue:
487+
case CK_HLSLElementwiseCast:
488+
case CK_HLSLAggregateSplatCast:
487489
llvm_unreachable("invalid cast kind for complex value");
488490

489491
case CK_FloatingRealToComplex:

clang/lib/CIR/CodeGen/CIRGenExprConst.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,8 @@ class ConstExprEmitter
976976
switch (E->getCastKind()) {
977977
case CK_HLSLArrayRValue:
978978
case CK_HLSLVectorTruncation:
979+
case CK_HLSLElementwiseCast:
980+
case CK_HLSLAggregateSplatCast:
979981
case CK_ToUnion:
980982
llvm_unreachable("not implemented");
981983

@@ -1992,7 +1994,7 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value,
19921994
const ValueDecl *memberDecl = Value.getMemberPointerDecl();
19931995
assert(!Value.isMemberPointerToDerivedMember() && "NYI");
19941996

1995-
if (const auto *memberFuncDecl = dyn_cast<CXXMethodDecl>(memberDecl))
1997+
if (isa<CXXMethodDecl>(memberDecl))
19961998
assert(0 && "not implemented");
19971999

19982000
auto cirTy = mlir::cast<cir::DataMemberType>(CGM.convertType(DestType));
@@ -2022,12 +2024,11 @@ mlir::Value CIRGenModule::emitNullConstant(QualType T, mlir::Location loc) {
20222024
if (getTypes().isZeroInitializable(T))
20232025
return builder.getNullValue(getTypes().convertTypeForMem(T), loc);
20242026

2025-
if (const ConstantArrayType *CAT =
2026-
getASTContext().getAsConstantArrayType(T)) {
2027+
if (getASTContext().getAsConstantArrayType(T)) {
20272028
llvm_unreachable("NYI");
20282029
}
20292030

2030-
if (const clang::RecordType *RT = T->getAs<clang::RecordType>())
2031+
if (T->getAs<clang::RecordType>())
20312032
llvm_unreachable("NYI");
20322033

20332034
assert(T->isMemberDataPointerType() &&

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
401401
mlir::Value value{};
402402
mlir::Value input{};
403403

404-
if (const AtomicType *atomicTy = type->getAs<AtomicType>()) {
404+
if (type->getAs<AtomicType>()) {
405405
llvm_unreachable("no atomics inc/dec yet");
406406
} else {
407407
value = emitLoadOfLValue(LV, E->getExprLoc());
@@ -469,8 +469,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
469469
// Next most common: pointer increment.
470470
} else if (const PointerType *ptr = type->getAs<PointerType>()) {
471471
QualType type = ptr->getPointeeType();
472-
if (const VariableArrayType *vla =
473-
CGF.getContext().getAsVariableArrayType(type)) {
472+
if (CGF.getContext().getAsVariableArrayType(type)) {
474473
// VLA types don't have constant size.
475474
llvm_unreachable("NYI");
476475
} else if (type->isFunctionType()) {
@@ -856,11 +855,11 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
856855
// TODO(cir): Candidate to be in a common AST helper between CIR and LLVM
857856
// codegen.
858857
QualType getPromotionType(QualType Ty) {
859-
if (auto *CT = Ty->getAs<ComplexType>()) {
858+
if (Ty->getAs<ComplexType>()) {
860859
llvm_unreachable("NYI");
861860
}
862861
if (Ty.UseExcessPrecision(CGF.getContext())) {
863-
if (auto *VT = Ty->getAs<VectorType>())
862+
if (Ty->getAs<VectorType>())
864863
llvm_unreachable("NYI");
865864
return CGF.getContext().FloatTy;
866865
}
@@ -917,7 +916,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
917916
}
918917
};
919918

920-
if (const MemberPointerType *MPT = LHSTy->getAs<MemberPointerType>()) {
919+
if (LHSTy->getAs<MemberPointerType>()) {
921920
assert(E->getOpcode() == BO_EQ || E->getOpcode() == BO_NE);
922921
mlir::Value lhs = CGF.emitScalarExpr(E->getLHS());
923922
mlir::Value rhs = CGF.emitScalarExpr(E->getRHS());
@@ -992,7 +991,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
992991
if (SrcType->isRealFloatingType())
993992
return emitFloatToBoolConversion(Src, loc);
994993

995-
if (auto *MPT = llvm::dyn_cast<MemberPointerType>(SrcType))
994+
if (llvm::isa<MemberPointerType>(SrcType))
996995
assert(0 && "not implemented");
997996

998997
if (SrcType->isIntegerType())
@@ -2235,7 +2234,7 @@ LValue ScalarExprEmitter::emitCompoundAssignLValue(
22352234
// Load/convert the LHS
22362235
LValue LHSLV = CGF.emitLValue(E->getLHS());
22372236

2238-
if (const AtomicType *atomicTy = LHSTy->getAs<AtomicType>()) {
2237+
if (LHSTy->getAs<AtomicType>()) {
22392238
assert(0 && "not implemented");
22402239
}
22412240

clang/lib/CIR/CodeGen/TargetInfo.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
using namespace clang;
1313
using namespace clang::CIRGen;
1414

15-
static bool testIfIsVoidTy(QualType Ty) {
16-
const auto *BT = Ty->getAs<BuiltinType>();
17-
if (!BT)
18-
return false;
19-
20-
BuiltinType::Kind k = BT->getKind();
21-
return k == BuiltinType::Void;
22-
}
23-
2415
static bool isAggregateTypeForABI(QualType T) {
2516
return !CIRGenFunction::hasScalarEvaluationKind(T) ||
2617
T->isMemberFunctionPointerType();

0 commit comments

Comments
 (0)