[clang] d1c7fa8 - [CIR][NFC] Fix a build warning in CIRGenCall.cpp (#137366)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 25 12:31:07 PDT 2025
Author: Andy Kaylor
Date: 2025-04-25T12:31:04-07:00
New Revision: d1c7fa85525355add4bf5cef9a229cf24599f1da
URL: https://github.com/llvm/llvm-project/commit/d1c7fa85525355add4bf5cef9a229cf24599f1da
DIFF: https://github.com/llvm/llvm-project/commit/d1c7fa85525355add4bf5cef9a229cf24599f1da.diff
LOG: [CIR][NFC] Fix a build warning in CIRGenCall.cpp (#137366)
We have been getting a warning about a default statement in a fully
covered switch statement. This change fixes that by removing the
default, updating all paths to return a value rather than depending on a
local variable which is returned immediately after the switch, and
adding an llvm_unreachable for non-enum values.
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenCall.cpp
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
index 69266f79a88a5..fe8d502e504bd 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
@@ -110,7 +110,6 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
assert(!cir::MissingFeatures::opCallMustTail());
assert(!cir::MissingFeatures::opCallReturn());
- RValue ret;
switch (retInfo.getKind()) {
case cir::ABIArgInfo::Direct: {
mlir::Type retCIRTy = convertType(retTy);
@@ -132,23 +131,22 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
return RValue::get(results[0]);
}
- default:
+ case cir::TEK_Complex:
+ case cir::TEK_Aggregate:
cgm.errorNYI(loc,
"unsupported evaluation kind of function call result");
+ return getUndefRValue(retTy);
}
- } else
- cgm.errorNYI(loc, "unsupported function call form");
-
- break;
+ llvm_unreachable("Invalid evaluation kind");
+ }
+ cgm.errorNYI(loc, "unsupported function call form");
+ return getUndefRValue(retTy);
}
case cir::ABIArgInfo::Ignore:
// If we are ignoring an argument that had a result, make sure to construct
// the appropriate return value for our caller.
- ret = getUndefRValue(retTy);
- break;
- default:
- cgm.errorNYI(loc, "unsupported return value information");
+ return getUndefRValue(retTy);
}
- return ret;
+ llvm_unreachable("Invalid return info kind");
}
More information about the cfe-commits
mailing list