I had another shot at it. I made a new checker, StreamV2, which is based off of SimpleStream, so that can stay as an example.<div><br></div><div>This patch moved the getFirstAllocation function from the malloc checker to CheckerContext so it can be reused. If there's a better spot for it, let me know.</div>


<div><br></div><div>I also added the printing for the MemRegion where the stream was opened. This did change the location where some of the bugs were reported. There is one example that I don't think is quite right:</div>

<div><br></div><div><div>int checkLeak(int *Data) {</div><div>  FILE *F = fopen("myfile.txt", "w");</div><div>  if (F != 0) {</div><div>    fputs ("fopen example", F); // expected-warning {{Opened file is never closed; potential resource leak of 'F'}}</div>

<div>  }</div><div><br></div><div>  if (Data)</div><div>    return *Data;</div><div>  else</div><div>    return 0;</div><div>}</div><div><br></div><div>It seems like the bug should be reported on the line: if (Data). I think this might be an error with the order in which I'm removing nodes from the graph and reporting bugs.</div>

<div><br></div><div>Adam</div><br><div class="gmail_quote">On Mon, Apr 22, 2013 at 3:10 PM, Adam Schnitzer <span dir="ltr"><<a href="mailto:adamschn@umich.edu" target="_blank">adamschn@umich.edu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Anna,<div><br></div><div>Thanks for the feedback. I think I have a better idea of how to go about it now. I'll have another shot at it.</div>


<span><font color="#888888"><div><br></div></font></span><div><span><font color="#888888">Adam</font></span><div><br><br><div class="gmail_quote">On Mon, Apr 22, 2013 at 1:17 PM, Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com" target="_blank">ganna@apple.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Adam,<div><br></div><div><div><div>The warning looks good for the listed test cases (though the column seems redundant). However, it might not be a good fit when the file name is not a string literal. In other checkers, we often pretty print the region instead; for example, see reportLeak in the MallocChecker. </div>



<div><br></div><div>The second issue is storing the string in the state. It should be possible to get the file info only at the point of a leak report, not when processing 'fopen'. Specifically, you would go up the path when reporting the leak and find the statement that opened the file. That logic would be very similar to "<span style="color:rgb(49,89,93);font-family:Menlo">getAllocationSite"</span> from mallocChecker. Let's see if we can factor it out so that we do not continue with copying and pasting of that code.</div>



<div><br></div><div>Thanks!</div><span><font color="#888888"><div>Anna.</div></font></span><div><div><div>On Apr 21, 2013, at 10:56 PM, Adam Schnitzer <<a href="mailto:adamschn@umich.edu" target="_blank">adamschn@umich.edu</a>> wrote:</div>



<br><blockquote type="cite"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Anna, <div><br></div><div>Got it, sorry about the mixup. I will go ahead and work in a separate file. But did it look like I was on the right track for the diagnostics?<div>



<br></div><div>Adam<br><br><div class="gmail_quote">On Mon, Apr 22, 2013 at 1:20 AM, Anna Zaks<span> </span><span dir="ltr"><<a href="mailto:ganna@apple.com" target="_blank">ganna@apple.com</a>></span><span> </span>wrote:<br>



<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Adam,<br><br>Sorry if I was not 100% clear. We'd like to leave the SimpleStreamChecker.cpp file as is for reference purposes. You can either create a new file or replace StreamChecker.cpp with your checker.<br>



<br>Thanks,<br>Anna.<br><div><div>On Apr 20, 2013, at 11:34 PM, Adam Schnitzer <<a href="mailto:adamschn@umich.edu" target="_blank">adamschn@umich.edu</a>> wrote:<br><br>> This is my first patch for the SimpleStreamChecker. It improves diagnostics by adding the file name in the case of a resource leak. I did so by adding a std::string to the StreamState to hold the file name.<br>



><br>> Any feedback would be great.<br>><br>> Adam<br></div></div>> <SimpleStreamChecker.patch></blockquote></div></div></div></div></blockquote></div></div></div><br></div></div></blockquote></div><br>



</div></div>
</blockquote></div><br></div>