<div dir="ltr">Apparently not - I'm at 289944 locally. Sigh. Oh well, it was an interesting investigation.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 23, 2017 at 3:48 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This looks pretty similar to <a href="https://reviews.llvm.org/D27849" target="_blank">https://reviews.llvm.org/<wbr>D27849</a> – are you synced to trunk?</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Feb 23, 2017 at 5:42 PM, Kevin Marshall via Phabricator via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">kmarshall created this revision.<br>
<br>
The extent calculation function had a bug which caused it to ignore if the size value was defined prior to casting it. As a result, size expressions with free variables would trigger assertion failures during the cast operation.<br>
<br>
This patch adds that missing check, and replaces the redundant call to castAs<>() with the SVar that is returned by the checked cast.<br>
<br>
Added a regression test "Malloc+NewDynamicArray" that exercises the fix.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D30312" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3031<wbr>2</a><br>
<br>
Files:<br>
  lib/StaticAnalyzer/Checkers/Ma<wbr>llocChecker.cpp<br>
  test/Analysis/Malloc+NewDynami<wbr>cArray.cpp<br>
<br>
<br>
Index: test/Analysis/Malloc+NewDynami<wbr>cArray.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/Analysis/Malloc+NewDynami<wbr>cArray.cpp<br>
+++ test/Analysis/Malloc+NewDynami<wbr>cArray.cpp<br>
@@ -0,0 +1,17 @@<br>
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -verify %s<br>
+<br>
+//---------------------------<wbr>------------------------------<wbr>--------------<br>
+// Check that arrays sized using expressions with free variables<br>
+// do not cause the unix.Malloc checker to crash.<br>
+//<br>
+// The function should not actually be called from anywhere, otherwise<br>
+// the compiler will optimize the length expression and replace it with<br>
+// with precomputed literals.<br>
+//---------------------------<wbr>------------------------------<wbr>--------------<br>
+<br>
+void AllocateExpr(int lhs, int rhs) {<br>
+  new int[lhs + rhs];<br>
+}<br>
+<br>
+// expected-no-diagnostics<br>
+<br>
Index: lib/StaticAnalyzer/Checkers/Ma<wbr>llocChecker.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/StaticAnalyzer/Checkers/Ma<wbr>llocChecker.cpp<br>
+++ lib/StaticAnalyzer/Checkers/Ma<wbr>llocChecker.cpp<br>
@@ -1026,12 +1026,11 @@<br>
   ASTContext &AstContext = C.getASTContext();<br>
   CharUnits TypeSize = AstContext.getTypeSizeInChars(<wbr>ElementType);<br>
<br>
-  if (Optional<DefinedOrUnknownSVal<wbr>> DefinedSize =<br>
-          ElementCount.getAs<DefinedOrUn<wbr>knownSVal>()) {<br>
+  if (Optional<NonLoc> DefinedSize = ElementCount.getAs<NonLoc>()) {<br>
     DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder)<wbr>;<br>
     // size in Bytes = ElementCount*TypeSize<br>
     SVal SizeInBytes = svalBuilder.evalBinOpNN(<br>
-        State, BO_Mul, ElementCount.castAs<NonLoc>(),<br>
+        State, BO_Mul, *DefinedSize,<br>
         svalBuilder.makeArrayIndex(Ty<wbr>peSize.getQuantity()),<br>
         svalBuilder.<wbr>getArrayIndexType());<br>
     DefinedOrUnknownSVal extentMatchesSize = svalBuilder.evalEQ(<br>
<br>
<br>
<br></div></div>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>