Author: Timm Baeder
Date: 2024-10-02T05:44:54+02:00
New Revision: e1e788f423b5c780c40912ab102b0a3c4b92b9de

URL: 
https://github.com/llvm/llvm-project/commit/e1e788f423b5c780c40912ab102b0a3c4b92b9de
DIFF: 
https://github.com/llvm/llvm-project/commit/e1e788f423b5c780c40912ab102b0a3c4b92b9de.diff

LOG: [clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers (#110699)

These are also called for vectors.

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 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;


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to