[PATCH] D46081: [analyzer] Expand conversion check to check more expressions for overflow and underflow

Paul Fultz II via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 07:01:15 PDT 2018


pfultz2 added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:77
     if (Opc == BO_Assign) {
-      LossOfSign = isLossOfSign(Cast, C);
-      LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
+      if (!B->getRHS()->isIntegerConstantExpr(C.getASTContext())) {
+        LossOfSign = isLossOfSign(Cast, C);
----------------
george.karpenkov wrote:
> Sorry, I don't quite follow: why we don't want to warn when RHS is an integer constant?
Because we want to treat `unsigned i = -1` as an explicit conversion. Ideally, I would like to just check that the RHS is a literal, but this seems like the closest way to do that.


Repository:
  rC Clang

https://reviews.llvm.org/D46081





More information about the cfe-commits mailing list