[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 5 01:04:39 PST 2021


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:219
+  ProgramStateManager &Mgr = State->getStateManager();
+  SValBuilder &Bldr = Mgr.getSValBuilder();
+  SVal Eval =
----------------
`Bldr` is always equal to `*this` here, there's no need to obtain it separately.


================
Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:306-307
+        (1ULL << (getContext().getTypeSize(resultTy) - 1)) - 1;
+    if (RHS > 0 && RHS < ResultTyMaxVal &&
+        isGreater(State, LHS, ResultTyMaxVal - RHS.getExtValue()))
+      return UndefinedVal();
----------------
All three checks deserve a separate lit test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92634/new/

https://reviews.llvm.org/D92634



More information about the cfe-commits mailing list