================
@@ -420,6 +420,118 @@ AST_MATCHER(CXXConstructExpr, 
isSafeSpanTwoParamConstruct) {
   return false;
 }
 
+class MaxValueEval : public RecursiveASTVisitor<MaxValueEval> {
+
+  std::vector<llvm::APInt> val;
+  ASTContext &Context;
+  llvm::APInt Max;
+  unsigned bit_width;
+
+public:
+  typedef RecursiveASTVisitor<MaxValueEval> VisitorBase;
+
+  explicit MaxValueEval(ASTContext &Ctx, const Expr *exp) : Context(Ctx) {
+    bit_width = Ctx.getIntWidth(exp->getType());
+    Max = llvm::APInt::getSignedMaxValue(bit_width);
----------------
ziqingluo-90 wrote:

Also types of those bitwise operands matter.  For example, `((unsigned long 
long) -1) & ((unsigned) var)` is of type `unsigned long long` but the value is 
actually upper-bounded by the max value of `unsigned`.  
(https://godbolt.org/z/b1zd1zEje)

Handle this in next version sounds good me.

https://github.com/llvm/llvm-project/pull/112284
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to