[PATCH] D124658: [analyzer] Canonicalize SymIntExpr so the RHS is positive when possible

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 05:37:57 PDT 2022


steakhal added a comment.

This time I've checked this on our test set, and it seems to run without any issues. I'm still waiting for the results of analyzing LLVM, but I think safe to say that this should work.
Could you please give this another shoot at this @uabelho?



================
Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:107-122
+// Checks if the negation the value and flipping sign preserve
+// the semantics on the operation in the resultType
+static bool isNegationValuePreserving(const llvm::APSInt & val,
+                                      const APSIntType resultType) {
+  const unsigned valueBits = val.getSignificantBits();
+  if (valueBits == resultType.getBitWidth()) {
+    // The value is the lowest negative value that is representable
----------------
Please follow the naming conventions of LLVM, so variables are `UpperCase`, and the `&` sign binds to the variable name.
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
I'm not sure why `clang-format` did not complain about these.

Also, taking a parameter by-const-value is discouraged, since it has no visible effect.


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

https://reviews.llvm.org/D124658



More information about the cfe-commits mailing list