a.sidorin added a subscriber: a.sidorin.

================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:41
@@ +40,3 @@
+    const Stmt *Parent = PM.getParent(Cast);
+    if (!Parent)
+      return;
----------------
Parent should always exist for an implicit cast. May be it's better to assert 
here?

================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:49
@@ +48,3 @@
+    BinaryOperator::Opcode Opc = B->getOpcode();
+    if (Opc == BO_Assign || Opc == BO_MulAssign)
+      diagnoseLossOfPrecision(Cast, C);
----------------
It's not evident why do you omit other Assign operators here, like 
BO_SubAssign, BO_AddAssign and BO_DivAssign. As I see from your test, there are 
some problems with them. Could you add a comment?

================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:74
@@ +73,3 @@
+static bool isSigned(const Expr *E) {
+  const Type *T = E ? E->getType().getTypePtr() : nullptr;
+  return T && T->isSignedIntegerType();
----------------
Source sub-expression of cast expression we're visiting cannot be null and it 
should have non-null type. I think you can use something like 
`E->getType()->isSignedIntegerType()` instead of this function or you can use 
some assertions.


http://reviews.llvm.org/D13126



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

Reply via email to