Skip to content

Commit c679f66

Browse files
bcardosolopeslanza
authored andcommitted
[CIR] Start silencing unused var warnings
1 parent beff42d commit c679f66

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

clang/lib/CIR/CodeGen/CIRGenCleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class EHScope {
124124
// Traditional LLVM codegen also checks for `!block->use_empty()`, but
125125
// in CIRGen the block content is not important, just used as a way to
126126
// signal `hasEHBranches`.
127-
if (mlir::Block *block = getCachedEHDispatchBlock())
127+
if ([[maybe_unused]] mlir::Block *block = getCachedEHDispatchBlock())
128128
return true;
129129
return false;
130130
}

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static bool endsWithReturn(const Decl *f) {
251251
const Stmt *body = nullptr;
252252
if (auto *fd = dyn_cast_or_null<FunctionDecl>(f))
253253
body = fd->getBody();
254-
else if (auto *omd = dyn_cast_or_null<ObjCMethodDecl>(f))
254+
else if (isa_and_nonnull<ObjCMethodDecl>(f))
255255
llvm_unreachable("NYI");
256256

257257
if (auto *cs = dyn_cast_or_null<CompoundStmt>(body)) {
@@ -554,7 +554,7 @@ void CIRGenFunction::finishFunction(SourceLocation endLoc) {
554554
// If there are multiple branches to the return block, the branch
555555
// instructions will get the location of the return statements and
556556
// all will be fine.
557-
if (auto *di = getDebugInfo())
557+
if (getDebugInfo())
558558
assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
559559

560560
// Pop any cleanups that might have been associated with the
@@ -581,7 +581,7 @@ void CIRGenFunction::finishFunction(SourceLocation endLoc) {
581581
}
582582

583583
// Emit debug descriptor for function end.
584-
if (auto *di = getDebugInfo())
584+
if (getDebugInfo())
585585
assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
586586

587587
// Reset the debug location to that of the simple 'return' expression, if any
@@ -1090,9 +1090,7 @@ void CIRGenFunction::StartFunction(GlobalDecl gd, QualType retTy,
10901090
llvm_unreachable("NYI");
10911091

10921092
// Apply xray attributes to the function (as a string, for now)
1093-
if (const auto *xRayAttr = d ? d->getAttr<XRayInstrumentAttr>() : nullptr) {
1094-
assert(!cir::MissingFeatures::xray());
1095-
} else {
1093+
if (d->getAttr<XRayInstrumentAttr>()) {
10961094
assert(!cir::MissingFeatures::xray());
10971095
}
10981096

@@ -1522,8 +1520,7 @@ void CIRGenFunction::emitNullInitialization(mlir::Location loc, Address destPtr,
15221520
// Don't bother emitting a zero-byte memset.
15231521
if (size.isZero()) {
15241522
// But note that getTypeInfo returns 0 for a VLA.
1525-
if (const VariableArrayType *vlaType = dyn_cast_or_null<VariableArrayType>(
1526-
getContext().getAsArrayType(ty))) {
1523+
if (isa_and_nonnull<VariableArrayType>(getContext().getAsArrayType(ty))) {
15271524
llvm_unreachable("NYI");
15281525
} else {
15291526
return;

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -887,20 +887,20 @@ void CIRGenModule::setNonAliasAttributes(GlobalDecl gd, mlir::Operation *go) {
887887
if (gv) {
888888
if (d->hasAttr<RetainAttr>())
889889
assert(!cir::MissingFeatures::addUsedGlobal());
890-
if (auto *sa = d->getAttr<PragmaClangBSSSectionAttr>())
890+
if (d->getAttr<PragmaClangBSSSectionAttr>())
891891
assert(!cir::MissingFeatures::addSectionAttributes());
892-
if (auto *sa = d->getAttr<PragmaClangDataSectionAttr>())
892+
if (d->getAttr<PragmaClangDataSectionAttr>())
893893
assert(!cir::MissingFeatures::addSectionAttributes());
894-
if (auto *sa = d->getAttr<PragmaClangRodataSectionAttr>())
894+
if (d->getAttr<PragmaClangRodataSectionAttr>())
895895
assert(!cir::MissingFeatures::addSectionAttributes());
896-
if (auto *sa = d->getAttr<PragmaClangRelroSectionAttr>())
896+
if (d->getAttr<PragmaClangRelroSectionAttr>())
897897
assert(!cir::MissingFeatures::addSectionAttributes());
898898
}
899899
auto f = llvm::dyn_cast_or_null<cir::FuncOp>(go);
900900
if (f) {
901901
if (d->hasAttr<RetainAttr>())
902902
assert(!cir::MissingFeatures::addUsedGlobal());
903-
if (auto *sa = d->getAttr<PragmaClangTextSectionAttr>())
903+
if (d->getAttr<PragmaClangTextSectionAttr>())
904904
if (!d->getAttr<SectionAttr>())
905905
assert(!cir::MissingFeatures::setSectionForFuncOp());
906906

@@ -1066,7 +1066,7 @@ void CIRGenModule::setTLSMode(mlir::Operation *op, const VarDecl &d) const {
10661066
auto tlm = GetDefaultCIRTLSModel();
10671067

10681068
// Override the TLS model if it is explicitly specified.
1069-
if (const TLSModelAttr *attr = d.getAttr<TLSModelAttr>()) {
1069+
if (d.getAttr<TLSModelAttr>()) {
10701070
llvm_unreachable("NYI");
10711071
}
10721072

@@ -1852,7 +1852,7 @@ void CIRGenModule::emitDeclContext(const DeclContext *dc) {
18521852
// ObjCImplDecl does not recursively visit them. We need to do that in
18531853
// case they're nested inside another construct (LinkageSpecDecl /
18541854
// ExportDecl) that does stop them from being considered "top-level".
1855-
if (auto *oid = dyn_cast<ObjCImplDecl>(i))
1855+
if (isa<ObjCImplDecl>(i))
18561856
llvm_unreachable("NYI");
18571857

18581858
emitTopLevelDecl(i);
@@ -2599,7 +2599,7 @@ StringRef CIRGenModule::getMangledName(GlobalDecl gd) {
25992599

26002600
// Some ABIs don't have constructor variants. Make sure that base and complete
26012601
// constructors get mangled the same.
2602-
if (const auto *cd = dyn_cast<CXXConstructorDecl>(canonicalGd.getDecl())) {
2602+
if (isa<CXXConstructorDecl>(canonicalGd.getDecl())) {
26032603
if (!getTarget().getCXXABI().hasConstructorVariants()) {
26042604
assert(false && "NYI");
26052605
}

clang/lib/CIR/CodeGen/CIRGenStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Address CIRGenFunction::emitCompoundStmtWithoutScope(const CompoundStmt &S,
3636
for (auto *CurStmt : S.body()) {
3737
if (getLast && ExprResult == CurStmt) {
3838
while (!isa<Expr>(ExprResult)) {
39-
if (const auto *LS = dyn_cast<LabelStmt>(ExprResult))
39+
if (isa<LabelStmt>(ExprResult))
4040
llvm_unreachable("labels are NYI");
41-
else if (const auto *AS = dyn_cast<AttributedStmt>(ExprResult))
41+
else if (isa<AttributedStmt>(ExprResult))
4242
llvm_unreachable("statement attributes are NYI");
4343
else
4444
llvm_unreachable("Unknown value statement");

clang/lib/CIR/CodeGen/CIRGenVTables.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ mlir::Type CIRGenVTables::getVTableComponentType() {
5555

5656
mlir::Type CIRGenVTables::getVTableType(const VTableLayout &layout) {
5757
SmallVector<mlir::Type, 4> tys;
58-
mlir::MLIRContext *mlirContext = CGM.getBuilder().getContext();
5958
auto componentType = getVTableComponentType();
6059
for (unsigned i = 0, e = layout.getNumVTables(); i != e; ++i)
6160
tys.push_back(cir::ArrayType::get(componentType, layout.getVTableSize(i)));

clang/lib/CIR/CodeGen/TargetInfo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class DefaultABIInfo : public ABIInfo {
5353
llvm_unreachable("NYI");
5454

5555
// Treat an enum type as its underlying type.
56-
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
56+
if (RetTy->getAs<EnumType>())
5757
llvm_unreachable("NYI");
5858

59-
if (const auto *EIT = RetTy->getAs<BitIntType>())
59+
if (RetTy->getAs<BitIntType>())
6060
llvm_unreachable("NYI");
6161

6262
return (isPromotableIntegerTypeForABI(RetTy)
@@ -72,10 +72,10 @@ class DefaultABIInfo : public ABIInfo {
7272
}
7373

7474
// Treat an enum type as its underlying type.
75-
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
75+
if (Ty->getAs<EnumType>())
7676
llvm_unreachable("NYI");
7777

78-
if (const auto *EIT = Ty->getAs<BitIntType>())
78+
if (Ty->getAs<BitIntType>())
7979
llvm_unreachable("NYI");
8080

8181
return (isPromotableIntegerTypeForABI(Ty) ? cir::ABIArgInfo::getExtend(Ty)
@@ -357,7 +357,7 @@ class NVPTXTargetCIRGenInfo : public TargetCIRGenInfo {
357357
}
358358
void setTargetAttributes(const clang::Decl *decl, mlir::Operation *global,
359359
CIRGenModule &cgm) const override {
360-
if (const auto *vd = clang::dyn_cast_or_null<clang::VarDecl>(decl)) {
360+
if (clang::isa_and_nonnull<clang::VarDecl>(decl)) {
361361
assert(!cir::MissingFeatures::emitNVVMMetadata());
362362
return;
363363
}

0 commit comments

Comments
 (0)