[clang] [clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers (PR #110699)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 1 09:41:36 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
These are also called for vectors.
---
Full diff: https://github.com/llvm/llvm-project/pull/110699.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+8)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index ebc800623f0d48..72c94e6fad3e0d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1205,6 +1205,10 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+ QualType CallType = Call->getType();
+ if (!CallType->isIntegerType())
+ return false;
+
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
pushInteger(S, Val.countLeadingZeros(), Call->getType());
return true;
@@ -1214,6 +1218,10 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+ QualType CallType = Call->getType();
+ if (!CallType->isIntegerType())
+ return false;
+
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
pushInteger(S, Val.countTrailingZeros(), Call->getType());
return true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/110699
More information about the cfe-commits
mailing list