[PATCH] D19964: [scan-build] fix warnings emiited on LLVM Analysis code base

silviu.baranga@arm.com via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 02:57:41 PDT 2016


sbaranga added inline comments.

================
Comment at: lib/Analysis/LoopInfo.cpp:548
@@ -547,2 +547,3 @@
     }
+    assert(Unloop && "does not contain any loop");
     if (L != Unloop && Unloop->contains(L)) {
----------------
apelete wrote:
> apelete wrote:
> > sbaranga wrote:
> > > Would there be any reason to have this assert here and not at the top?
> > Code path that leads to "Called C++ object pointer is null" is the one inside the for() loop on line 537.
> > Not sure asserting outside that path would help, I'm going to verify that.
> Tested moving the assert at the top of function, and I can confirm that it has no effect on the codepath inside the for() loop at line 537.
> 
> Would you prefer to have it at the beginning of the for() loop ?
Sorry for taking so long to reply. I don't fully understand how clang gets this warning, but having it at the top of the function would surely guarantee that Unloop is not null. So maybe the static analyzer is too eager?

I think it would be overall a lot better to change Unloop to be a reference (which removes this issue entirely).


http://reviews.llvm.org/D19964





More information about the llvm-commits mailing list