[clang] 8951b51 - [clang][bytecode] Add more checks to _ai32_* builtins (#114412)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 1 06:20:03 PDT 2024
Author: Timm Baeder
Date: 2024-11-01T14:19:59+01:00
New Revision: 8951b51402d17af1f97e5804f60c946e624650d6
URL: https://github.com/llvm/llvm-project/commit/8951b51402d17af1f97e5804f60c946e624650d6
DIFF: https://github.com/llvm/llvm-project/commit/8951b51402d17af1f97e5804f60c946e624650d6.diff
LOG: [clang][bytecode] Add more checks to _ai32_* builtins (#114412)
They are called in a few different forms that we don't support.
Added:
Modified:
clang/lib/AST/ByteCode/InterpBuiltin.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index cb5092b7a0815b..144f2291651ccf 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1254,7 +1254,7 @@ static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
- if (!Call->getArg(0)->getType()->isIntegerType() ||
+ if (Call->getNumArgs() != 2 || !Call->getArg(0)->getType()->isIntegerType() ||
!Call->getArg(1)->getType()->isIntegerType())
return false;
@@ -1286,7 +1286,9 @@ static bool interp__builtin_ia32_bzhi(InterpState &S, CodePtr OpPC,
const Function *Func,
const CallExpr *Call) {
QualType CallType = Call->getType();
- if (!CallType->isIntegerType())
+ if (Call->getNumArgs() != 2 || !Call->getArg(0)->getType()->isIntegerType() ||
+ !Call->getArg(1)->getType()->isIntegerType() ||
+ !CallType->isIntegerType())
return false;
PrimType ValT = *S.Ctx.classify(Call->getArg(0));
@@ -1311,7 +1313,8 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, CodePtr OpPC,
const Function *Func,
const CallExpr *Call) {
QualType CallType = Call->getType();
- if (!CallType->isIntegerType())
+ if (!CallType->isIntegerType() ||
+ !Call->getArg(0)->getType()->isIntegerType())
return false;
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
@@ -1324,7 +1327,8 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, CodePtr OpPC,
const Function *Func,
const CallExpr *Call) {
QualType CallType = Call->getType();
- if (!CallType->isIntegerType())
+ if (!CallType->isIntegerType() ||
+ !Call->getArg(0)->getType()->isIntegerType())
return false;
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
@@ -1336,7 +1340,7 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
- if (!Call->getArg(0)->getType()->isIntegerType() ||
+ if (Call->getNumArgs() != 2 || !Call->getArg(0)->getType()->isIntegerType() ||
!Call->getArg(1)->getType()->isIntegerType())
return false;
@@ -1361,7 +1365,7 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
- if (!Call->getArg(0)->getType()->isIntegerType() ||
+ if (Call->getNumArgs() != 2 || !Call->getArg(0)->getType()->isIntegerType() ||
!Call->getArg(1)->getType()->isIntegerType())
return false;
More information about the cfe-commits
mailing list