<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 5, 2016 at 11:50 AM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On May 5, 2016, at 11:20 AM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi Apelete,<br>
><br>
> Thanks for trying to help cleanup the LLVM codebase of Clang Static Analyzer warnings.<br>
><br>
> But it seems a lot of the fixes that are being proposed are somewhat mechanical and may be doing the wrong thing in a few ways.<br>
><br>
> * Initializing variables that are only used when initialized through some existing codepath - this can make tools like Memory Sanitizer less useful, because now the value is initialized even in some path where that value is never intended to be used<br>
><br>
> * Adding assertions for pointers that are known to be non-null - in some cases this is helpful, when the algorithm that ensures the non-null-ness is sufficiently opaque. But for function parameters - we have /lots/ of non-null function parameters. I think it'd be impractical to assert on all of them.<br>
<br>
</span>Any reason we don't use more references? I like references because when I read code it is very clear that the argument *can't* be null and I don't have to think if I need to handle the null case.<br>
When I made the DataLayout "mandatory" on the Module last year, I moved every single use of the DataLayout to be a reference, and this helped to remove each and every places that were null-checking the DL.<br></blockquote><div><br></div><div>I'm a big fan of references as well - but there's still some (read: a lot of) community/codebase momentum behind certain entities being referenced by pointer because their pointer identity is so intrinsic to their nature (comparing instruction pointers, etc). Not that one can't take the address of a thing and compare it, stuff it in a container, etc.<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
Mehdi<br>
<span class=""><br>
<br>
><br>
> But if we want to do something like this we should probably have some community discussion about how how to go about any of these things across the codebase. Maybe using nonnull attributes would be a better approach to the parameter issue, for example - but it'll still be a lot of code churn that there should probably be general consensus on rather than approaching it piecemeal with reviewers in different parts of the codebase.<br>
><br>
> Thanks,<br>
> - Dave<br>
</span>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br></div></div>