Skip to content

Commit

Permalink
better name and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ghehg committed Nov 11, 2024
1 parent fbf3377 commit c8e0a23
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,16 @@ RValue CIRGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
return RValue::get(r);
}

static bool isMemBuiltinOutOfBound(const CallExpr *expr,
clang::CIRGen::CIRGenModule &cgm,
llvm::APSInt &size) {
static bool isMemBuiltinOutOfBoundPossible(const CallExpr *expr,
clang::CIRGen::CIRGenModule &cgm,
llvm::APSInt &size) {
clang::Expr::EvalResult sizeResult, dstSizeResult;
if (!expr->getArg(2)->EvaluateAsInt(sizeResult, cgm.getASTContext()) ||
!expr->getArg(3)->EvaluateAsInt(dstSizeResult, cgm.getASTContext()))
return true;
size = sizeResult.Val.getInt();
llvm::APSInt dstSize = dstSizeResult.Val.getInt();
if (size.ugt(dstSize))
return true;
return false;
return size.ugt(dstSize);
}

RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Expand Down Expand Up @@ -1490,7 +1488,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin___memcpy_chk: {
// fold __builtin_memcpy_chk(x, y, cst1, cst2) to memcpy iff cst1<=cst2.
llvm::APSInt size;
if (isMemBuiltinOutOfBound(E, CGM, size))
if (isMemBuiltinOutOfBoundPossible(E, CGM, size))
break;
Address dest = emitPointerWithAlignment(E->getArg(0));
Address src = emitPointerWithAlignment(E->getArg(1));
Expand All @@ -1506,7 +1504,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin___memmove_chk: {
// fold __builtin_memcpy_chk(x, y, cst1, cst2) to memcpy iff cst1<=cst2.
llvm::APSInt size;
if (isMemBuiltinOutOfBound(E, CGM, size))
if (isMemBuiltinOutOfBoundPossible(E, CGM, size))
break;
Address Dest = emitPointerWithAlignment(E->getArg(0));
Address Src = emitPointerWithAlignment(E->getArg(1));
Expand Down Expand Up @@ -1545,7 +1543,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin___memset_chk: {
// fold __builtin_memset_chk(x, y, cst1, cst2) to memset iff cst1<=cst2.
llvm::APSInt size;
if (isMemBuiltinOutOfBound(E, CGM, size))
if (isMemBuiltinOutOfBoundPossible(E, CGM, size))
break;
Address dest = emitPointerWithAlignment(E->getArg(0));
mlir::Value byteVal = emitScalarExpr(E->getArg(1));
Expand Down

0 comments on commit c8e0a23

Please sign in to comment.