@@ -2009,11 +2009,12 @@ Value *CodeGenFunction::EmitCheckedArgForBuiltin(const Expr *E,
2009
2009
if (!SanOpts.has (SanitizerKind::Builtin))
2010
2010
return ArgValue;
2011
2011
2012
- SanitizerScope SanScope (this );
2012
+ auto CheckOrdinal = SanitizerKind::SO_Builtin;
2013
+ auto CheckHandler = SanitizerHandler::InvalidBuiltin;
2014
+ SanitizerDebugLocation SanScope (this , {CheckOrdinal}, CheckHandler);
2013
2015
Value *Cond = Builder.CreateICmpNE (
2014
2016
ArgValue, llvm::Constant::getNullValue (ArgValue->getType ()));
2015
- EmitCheck (std::make_pair (Cond, SanitizerKind::SO_Builtin),
2016
- SanitizerHandler::InvalidBuiltin,
2017
+ EmitCheck (std::make_pair (Cond, CheckOrdinal), CheckHandler,
2017
2018
{EmitCheckSourceLocation (E->getExprLoc ()),
2018
2019
llvm::ConstantInt::get (Builder.getInt8Ty (), Kind)},
2019
2020
{});
@@ -2025,10 +2026,11 @@ Value *CodeGenFunction::EmitCheckedArgForAssume(const Expr *E) {
2025
2026
if (!SanOpts.has (SanitizerKind::Builtin))
2026
2027
return ArgValue;
2027
2028
2028
- SanitizerScope SanScope (this );
2029
+ auto CheckOrdinal = SanitizerKind::SO_Builtin;
2030
+ auto CheckHandler = SanitizerHandler::InvalidBuiltin;
2031
+ SanitizerDebugLocation SanScope (this , {CheckOrdinal}, CheckHandler);
2029
2032
EmitCheck (
2030
- std::make_pair (ArgValue, SanitizerKind::SO_Builtin),
2031
- SanitizerHandler::InvalidBuiltin,
2033
+ std::make_pair (ArgValue, CheckOrdinal), CheckHandler,
2032
2034
{EmitCheckSourceLocation (E->getExprLoc ()),
2033
2035
llvm::ConstantInt::get (Builder.getInt8Ty (), BCK_AssumePassedFalse)},
2034
2036
std::nullopt );
@@ -2051,7 +2053,15 @@ static Value *EmitOverflowCheckedAbs(CodeGenFunction &CGF, const CallExpr *E,
2051
2053
return EmitAbs (CGF, ArgValue, true );
2052
2054
}
2053
2055
2054
- CodeGenFunction::SanitizerScope SanScope (&CGF);
2056
+ SmallVector<SanitizerKind::SanitizerOrdinal, 1 > Ordinals;
2057
+ SanitizerHandler CheckHandler;
2058
+ if (SanitizeOverflow) {
2059
+ Ordinals.push_back (SanitizerKind::SO_SignedIntegerOverflow);
2060
+ CheckHandler = SanitizerHandler::NegateOverflow;
2061
+ } else
2062
+ CheckHandler = SanitizerHandler::SubOverflow;
2063
+
2064
+ SanitizerDebugLocation SanScope (&CGF, Ordinals, CheckHandler);
2055
2065
2056
2066
Constant *Zero = Constant::getNullValue (ArgValue->getType ());
2057
2067
Value *ResultAndOverflow = CGF.Builder .CreateBinaryIntrinsic (
@@ -2063,12 +2073,12 @@ static Value *EmitOverflowCheckedAbs(CodeGenFunction &CGF, const CallExpr *E,
2063
2073
// TODO: support -ftrapv-handler.
2064
2074
if (SanitizeOverflow) {
2065
2075
CGF.EmitCheck ({{NotOverflow, SanitizerKind::SO_SignedIntegerOverflow}},
2066
- SanitizerHandler::NegateOverflow ,
2076
+ CheckHandler ,
2067
2077
{CGF.EmitCheckSourceLocation (E->getArg (0 )->getExprLoc ()),
2068
2078
CGF.EmitCheckTypeDescriptor (E->getType ())},
2069
2079
{ArgValue});
2070
2080
} else
2071
- CGF.EmitTrapCheck (NotOverflow, SanitizerHandler::SubOverflow );
2081
+ CGF.EmitTrapCheck (NotOverflow, CheckHandler );
2072
2082
2073
2083
Value *CmpResult = CGF.Builder .CreateICmpSLT (ArgValue, Zero, " abscond" );
2074
2084
return CGF.Builder .CreateSelect (CmpResult, Result, ArgValue, " abs" );
0 commit comments