[clang] [Clang] Add missing __ob_trap check for sign change (PR #188340)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 2 10:50:49 PDT 2026
================
@@ -1663,6 +1667,20 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
llvm::Type *DstTy = ConvertType(DstType);
+ // Determine whether an overflow behavior of 'trap' has been specified for
+ // either the destination or the source types. If so, we can elide sanitizer
+ // capability checks as this overflow behavior kind is also capable of
+ // emitting traps without runtime sanitizer support.
+ // Also skip instrumentation if either source or destination has 'wrap'
+ // behavior - the user has explicitly indicated they accept wrapping
+ // semantics. Use non-canonical types to preserve OBT annotations.
+ const auto *DstOBT = NoncanonicalDstType->getAs<OverflowBehaviorType>();
+ const auto *SrcOBT = NoncanonicalSrcType->getAs<OverflowBehaviorType>();
----------------
mizvekov wrote:
I was thinking this could have been a left over from before obt was part of the canonical type.
Anyway, using the canonical type seems to be the right approach here.
https://github.com/llvm/llvm-project/pull/188340
More information about the cfe-commits
mailing list