From ef0cd1dae3a182fd721d18809ef38736cfd363c9 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 19 Nov 2025 16:12:17 -0800 Subject: [PATCH] [CIR][NFC] Fix warnings in release builds (#168791) This fixes several warnings that occur in CIR release builds. --- clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenException.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp | 3 ++- clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp b/clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp index bb55991d9366..03ae967af21d 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp @@ -292,7 +292,7 @@ emitSuspendExpression(CIRGenFunction &cgf, CGCoroData &coro, AggValueSlot aggSlot, bool ignoreResult, mlir::Block *scopeParentBlock, mlir::Value &tmpResumeRValAddr, bool forLValue) { - mlir::LogicalResult awaitBuild = mlir::success(); + [[maybe_unused]] mlir::LogicalResult awaitBuild = mlir::success(); LValueOrRValue awaitRes; CIRGenFunction::OpaqueValueMapping binder = diff --git a/clang/lib/CIR/CodeGen/CIRGenException.cpp b/clang/lib/CIR/CodeGen/CIRGenException.cpp index 765f593fe018..375828421eb1 100644 --- a/clang/lib/CIR/CodeGen/CIRGenException.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenException.cpp @@ -425,7 +425,7 @@ void CIRGenFunction::exitCXXTryStmt(const CXXTryStmt &s, bool isFnTryBlock) { assert(!cir::MissingFeatures::incrementProfileCounter()); // Perform the body of the catch. - mlir::LogicalResult emitResult = + [[maybe_unused]] mlir::LogicalResult emitResult = emitStmt(catchStmt->getHandlerBlock(), /*useCurrentScope=*/true); assert(emitResult.succeeded() && "failed to emit catch handler block"); diff --git a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp index c3580dcfff17..28a42121052e 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp @@ -426,7 +426,7 @@ static mlir::Value emitCXXNewAllocSize(CIRGenFunction &cgf, const CXXNewExpr *e, const llvm::APInt &count = mlir::cast(constNumElements).getValue(); - unsigned numElementsWidth = count.getBitWidth(); + [[maybe_unused]] unsigned numElementsWidth = count.getBitWidth(); bool hasAnyOverflow = false; // The equivalent code in CodeGen/CGExprCXX.cpp handles these cases as diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp index f603f5ec4383..c98edad1303e 100644 --- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp @@ -459,7 +459,8 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &cgvt, "emitVTableDefinitions: __fundamental_type_info"); } - auto vtableAsGlobalValue = dyn_cast(*vtable); + [[maybe_unused]] auto vtableAsGlobalValue = + dyn_cast(*vtable); assert(vtableAsGlobalValue && "VTable must support CIRGlobalValueInterface"); // Always emit type metadata on non-available_externally definitions, and on // available_externally definitions if we are performing whole program diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp index 96a03ec3b8e9..1461db8e320d 100644 --- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp @@ -462,7 +462,7 @@ static mlir::Type higherPrecisionElementTypeForComplexArithmetic( return info.getFloat128Format(); } - assert(false && "Unsupported float type semantics"); + llvm_unreachable("Unsupported float type semantics"); }; const mlir::Type higherElementType = getHigherPrecisionFPType(elementType);