r.stahl added a comment.

To be honest I was quite surprised that this change in behavior didn't cause 
more test failures, because for detecting null dereferences the old behavior is 
definitely more useful. Since it did not, I was convinced that this change is 
desired.

We use the analyzer for finding dereferences to fixed addresses - very similar 
to the FixedAddressChecker. For this purpose it is crucial that the execution 
engine works as perfect as possible, without "swallowing" any arithmetic.

For the struct example you mentioned you can still get the final address by 
asking the ASTContext if needed, but with pointer arithmetic the information is 
lost forever. Information is lost either way here. Either you forget that the 
arithmetic was based on a null pointer or you lose whatever was added to or 
subtracted from it.

So unless you can somehow tag the information in the SVal when an operation was 
based on a null pointer, this is pretty difficult. You also could introduce a 
heuristic that defines all dereferences around zero as null dereferences, but 
it would be very arbitrary and platform dependent. Or maybe the 
DereferenceChecker should explicitly break early on all statements that do 
arithmetic on pointers constrained to null. Overall I don't know enough about 
the analyzer to suggest more here.

Thanks for the comments, I will address them soon.


https://reviews.llvm.org/D37478



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

Reply via email to