zaks.anna added inline comments.

================
Comment at: test/Analysis/ReturnNonBoolTest.c:67
@@ +66,3 @@
+
+  if (rc < 0)
+    // error handling
----------------
How about addressing this as follows: in checkBranchCondition, you check for 
any comparisons of the tracked value other than comparisons to bool. If you see 
such a comparison, you assume that the error handling has occurred and remove 
the symbol from the set of tracked symbols. This will ensure that any code 
after the cleansing condition (error handling) can cast the return value to 
bool. 

The warning will still get triggered if the error handling is **after** the 
comparison to bool. That could be avoided as well, but the solution would be 
more complicated. I am thinking something along the lines of tracking all 
comparisons until the symbol goes out of scope. For each symbol, you'd track 
it's state (for example, "performedErrorHandling  | 
comparedToBoolAndNoErrorHandling | notSeen"). You can draw the automaton to see 
what the transitions should be. When the symbol goes out of scope, you'd check 
if it's state is "comparedToBoolAndNoErrorHandling". Further, we'd need to walk 
up the path to find the location where we compared the symbol and use that for 
error reporting.


Repository:
  rL LLVM

https://reviews.llvm.org/D24507



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

Reply via email to