[clang] [clang] -fstrict-enums optimization for by-value parameters (PR #154807)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 21 10:56:27 PDT 2025
================
@@ -1986,10 +2013,15 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
getContext().isTypeIgnoredBySanitizer(SanitizerKind::Enum, Ty))
return false;
- llvm::APInt Min, End;
- if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool))
+ const std::optional<llvm::ConstantRange> Range = getRangeForType(
+ Ty, getContext().getTypeSize(Ty), /*ForceStrictEnums=*/true,
+ /*AssumeBooleanRepresentation*/ IsBool);
----------------
keinflue wrote:
`AssumeBooleanRepresentation` is used here because of `|| NSAPI(CGM.getContext()).isObjCBOOLType(Ty)` in `IsBool` above. This condition was not present in the use of `getRangeForType` for load optimization purposes and I do not know why it is special cased like this for the sanitizer.
https://github.com/llvm/llvm-project/pull/154807
More information about the cfe-commits
mailing list