Skip to content

Commit cd9bd41

Browse files
bcardosolopeslanza
authored andcommitted
[CIR] One more batch of fixing unused vars warnings (and others while here)
1 parent 5d21325 commit cd9bd41

File tree

11 files changed

+31
-26
lines changed

11 files changed

+31
-26
lines changed

clang/lib/CIR/CodeGen/CIRAsm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ static void collectClobbers(const CIRGenFunction &cgf, const AsmStmt &S,
122122

123123
// Clobbers
124124
for (unsigned i = 0, e = S.getNumClobbers(); i != e; i++) {
125-
StringRef clobber = S.getClobber(i);
125+
std::string clobberStr = S.getClobber(i);
126+
StringRef clobber{clobberStr};
126127
if (clobber == "memory")
127128
readOnly = readNone = false;
128129
else if (clobber == "unwind") {

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
26122612
// can move this up to the beginning of the function.
26132613
// checkTargetFeatures(E, FD);
26142614

2615-
if (unsigned VectorWidth =
2615+
if ([[maybe_unused]] unsigned VectorWidth =
26162616
getContext().BuiltinInfo.getRequiredVectorWidth(BuiltinID))
26172617
llvm_unreachable("NYI");
26182618

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,8 @@ static cir::VectorType GetNeonType(CIRGenFunction *CGF, NeonTypeFlags TypeFlags,
18661866
return cir::VectorType::get(TypeFlags.isUnsigned() ? CGF->UInt8Ty
18671867
: CGF->SInt8Ty,
18681868
V1Ty ? 1 : (8 << IsQuad));
1869+
case NeonTypeFlags::MFloat8:
1870+
llvm_unreachable("NeonTypeFlags::MFloat8 NYI");
18691871
case NeonTypeFlags::Int16:
18701872
case NeonTypeFlags::Poly16:
18711873
return cir::VectorType::get(TypeFlags.isUnsigned() ? CGF->UInt16Ty

clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace cir;
3232

3333
mlir::Value CIRGenFunction::emitNVPTXBuiltinExpr(unsigned builtinId,
3434
const CallExpr *expr) {
35-
auto getIntrinsic = [&](const char *name) {
35+
[[maybe_unused]] auto getIntrinsic = [&](const char *name) {
3636
mlir::Type intTy = cir::IntType::get(&getMLIRContext(), 32, false);
3737
return builder
3838
.create<cir::LLVMIntrinsicCallOp>(getLoc(expr->getExprLoc()),

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void CIRGenFunction::emitAggregateStore(mlir::Value Val, Address Dest,
308308

309309
static Address emitAddressAtOffset(CIRGenFunction &CGF, Address addr,
310310
const cir::ABIArgInfo &info) {
311-
if (unsigned offset = info.getDirectOffset()) {
311+
if ([[maybe_unused]] unsigned offset = info.getDirectOffset()) {
312312
llvm_unreachable("NYI");
313313
}
314314
return addr;
@@ -1380,8 +1380,7 @@ bool CIRGenModule::MayDropFunctionReturn(const ASTContext &astContext,
13801380
QualType ReturnType) {
13811381
// We can't just disard the return value for a record type with a complex
13821382
// destructor or a non-trivially copyable type.
1383-
if (const RecordType *RT =
1384-
ReturnType.getCanonicalType()->getAs<RecordType>()) {
1383+
if (ReturnType.getCanonicalType()->getAs<RecordType>()) {
13851384
llvm_unreachable("NYI");
13861385
}
13871386

clang/lib/CIR/CodeGen/CIRGenClass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class AssignmentMemcpyizer : public FieldMemcpyizer {
439439
return Field;
440440
}
441441
return nullptr;
442-
} else if (CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(S)) {
442+
} else if (isa<CXXMemberCallExpr>(S)) {
443443
// We want to represent all calls explicitly for analysis purposes.
444444
return nullptr;
445445
} else if (CallExpr *CE = dyn_cast<CallExpr>(S)) {

clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ CIRGenFunction::emitCoroutineBody(const CoroutineBodyStmt &S) {
287287
.getResult();
288288

289289
// Handle allocation failure if 'ReturnStmtOnAllocFailure' was provided.
290-
if (auto *RetOnAllocFailure = S.getReturnStmtOnAllocFailure())
290+
if (S.getReturnStmtOnAllocFailure())
291291
llvm_unreachable("NYI");
292292

293293
{

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void CIRGenFunction::emitAutoVarCleanups(const AutoVarEmission &emission) {
377377
assert(0 && "not implemented");
378378

379379
// Handle the cleanup attribute.
380-
if (const CleanupAttr *CA = D.getAttr<CleanupAttr>())
380+
if (D.getAttr<CleanupAttr>())
381381
assert(0 && "not implemented");
382382

383383
// TODO: handle block variable
@@ -436,9 +436,9 @@ static std::string getStaticDeclName(CIRGenModule &CGM, const VarDecl &D) {
436436
DC = cast<DeclContext>(CD->getNonClosureContext());
437437
if (const auto *FD = dyn_cast<FunctionDecl>(DC))
438438
ContextName = std::string(CGM.getMangledName(FD));
439-
else if (const auto *BD = dyn_cast<BlockDecl>(DC))
439+
else if (isa<BlockDecl>(DC))
440440
llvm_unreachable("block decl context for static var is NYI");
441-
else if (const auto *OMD = dyn_cast<ObjCMethodDecl>(DC))
441+
else if (isa<ObjCMethodDecl>(DC))
442442
llvm_unreachable("ObjC decl context for static var is NYI");
443443
else
444444
llvm_unreachable("Unknown context for static var decl");
@@ -520,9 +520,9 @@ CIRGenModule::getOrCreateStaticVarDecl(const VarDecl &D,
520520
}
521521

522522
GlobalDecl GD;
523-
if (const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
523+
if (isa<CXXConstructorDecl>(DC))
524524
llvm_unreachable("C++ constructors static var context is NYI");
525-
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
525+
else if (isa<CXXDestructorDecl>(DC))
526526
llvm_unreachable("C++ destructors static var context is NYI");
527527
else if (const auto *FD = dyn_cast<FunctionDecl>(DC))
528528
GD = GlobalDecl(FD);
@@ -652,16 +652,16 @@ void CIRGenFunction::emitStaticVarDecl(const VarDecl &D,
652652
if (D.hasAttr<AnnotateAttr>())
653653
llvm_unreachable("Global annotations are NYI");
654654

655-
if (auto *SA = D.getAttr<PragmaClangBSSSectionAttr>())
655+
if (D.getAttr<PragmaClangBSSSectionAttr>())
656656
llvm_unreachable("CIR global BSS section attribute is NYI");
657-
if (auto *SA = D.getAttr<PragmaClangDataSectionAttr>())
657+
if (D.getAttr<PragmaClangDataSectionAttr>())
658658
llvm_unreachable("CIR global Data section attribute is NYI");
659-
if (auto *SA = D.getAttr<PragmaClangRodataSectionAttr>())
659+
if (D.getAttr<PragmaClangRodataSectionAttr>())
660660
llvm_unreachable("CIR global Rodata section attribute is NYI");
661-
if (auto *SA = D.getAttr<PragmaClangRelroSectionAttr>())
661+
if (D.getAttr<PragmaClangRelroSectionAttr>())
662662
llvm_unreachable("CIR global Relro section attribute is NYI");
663663

664-
if (const SectionAttr *SA = D.getAttr<SectionAttr>())
664+
if (D.getAttr<SectionAttr>())
665665
llvm_unreachable("CIR global object file section attribute is NYI");
666666

667667
if (D.hasAttr<RetainAttr>())
@@ -754,7 +754,7 @@ void CIRGenFunction::emitExprAsInit(const Expr *init, const ValueDecl *D,
754754
AggValueSlot::Overlap_t Overlap = AggValueSlot::MayOverlap;
755755
if (isa<VarDecl>(D))
756756
Overlap = AggValueSlot::DoesNotOverlap;
757-
else if (auto *FD = dyn_cast<FieldDecl>(D))
757+
else if (isa<FieldDecl>(D))
758758
assert(false && "Field decl NYI");
759759
else
760760
assert(false && "Only VarDecl implemented so far");
@@ -773,6 +773,8 @@ void CIRGenFunction::emitDecl(const Decl &D) {
773773
case Decl::ImplicitConceptSpecialization:
774774
case Decl::HLSLBuffer:
775775
case Decl::TopLevelStmt:
776+
case Decl::OpenACCDeclare:
777+
case Decl::OpenACCRoutine:
776778
llvm_unreachable("NYI");
777779
case Decl::BuiltinTemplate:
778780
case Decl::TranslationUnit:
@@ -831,11 +833,11 @@ void CIRGenFunction::emitDecl(const Decl &D) {
831833
llvm_unreachable("Declaration should not be in declstmts!");
832834
case Decl::Record: // struct/union/class X;
833835
case Decl::CXXRecord: // struct/union/class X; [C++]
834-
if (auto *DI = getDebugInfo())
836+
if (getDebugInfo())
835837
llvm_unreachable("NYI");
836838
return;
837839
case Decl::Enum: // enum X;
838-
if (auto *DI = getDebugInfo())
840+
if (getDebugInfo())
839841
llvm_unreachable("NYI");
840842
return;
841843
case Decl::Function: // void X();
@@ -886,7 +888,7 @@ void CIRGenFunction::emitDecl(const Decl &D) {
886888
case Decl::Typedef: // typedef int X;
887889
case Decl::TypeAlias: { // using X = int; [C++0x]
888890
QualType Ty = cast<TypedefNameDecl>(D).getUnderlyingType();
889-
if (auto *DI = getDebugInfo())
891+
if (getDebugInfo())
890892
assert(!cir::MissingFeatures::generateDebugInfo());
891893
if (Ty->isVariablyModifiedType())
892894
emitVariablyModifiedType(Ty);

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace {
3535

3636
mlir::Value buildAddressAtOffset(LowerFunction &LF, mlir::Value addr,
3737
const ABIArgInfo &info) {
38-
if (unsigned offset = info.getDirectOffset()) {
38+
if ([[maybe_unused]] unsigned offset = info.getDirectOffset()) {
3939
cir_cconv_unreachable("NYI");
4040
}
4141
return addr;
@@ -359,7 +359,7 @@ mlir::Value createCoercedValue(mlir::Value Src, mlir::Type Ty,
359359

360360
mlir::Value emitAddressAtOffset(LowerFunction &LF, mlir::Value addr,
361361
const ABIArgInfo &info) {
362-
if (unsigned offset = info.getDirectOffset()) {
362+
if ([[maybe_unused]] unsigned offset = info.getDirectOffset()) {
363363
cir_cconv_unreachable("NYI");
364364
}
365365
return addr;

clang/lib/CIR/Dialect/Transforms/TargetLowering/RecordLayoutBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void ItaniumRecordLayoutBuilder::initializeLayout(const mlir::Type Ty) {
258258
cir_cconv_assert(!cir::MissingFeatures::recordDeclIsPacked());
259259

260260
// Honor the default struct packing maximum alignment flag.
261-
if (unsigned DefaultMaxFieldAlignment = Context.getLangOpts().PackStruct) {
261+
if ([[maybe_unused]] unsigned DefaultMaxFieldAlignment =
262+
Context.getLangOpts().PackStruct) {
262263
cir_cconv_unreachable("NYI");
263264
}
264265

0 commit comments

Comments
 (0)