<div dir="ltr"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 10, 2020 at 10:47 PM Artem Dergachev <<a href="mailto:noqnoqneo@gmail.com">noqnoqneo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Operator bool() is never invoked in your code. The body of the operator <br>
is analyzed separately, outside of any known context (call site). For <br>
that reason you get a "symbolic region" for it, which is a notation for <br>
the memory region around a pointer that isn't known to point into any <br>
specific memory location on the current execution path (in this case, <br>
it's the pointer 'this' during the unknown invocation of operator <br>
bool()). A symbolic region is always an alias for a particular <br>
"concrete" region, it's simply not known *which* one; it may or may not <br>
be the struct you've constructed in your other function.<br></blockquote><div><br></div><div>OK, got it, I think I understand now that looking at operator bool() is a red herring in my case. What I'm trying to do is to see whether, at the end of any path through the function, the pointer in MyStruct is known to be null or known to be non-null. Not sure why I had convinced myself that operator bool() would be called in that situation ... :-) So maybe I should actually be able to achieve this by just consulting the program state map at the exit point of the function.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Studying the static analyzer by printing values to standard output may <br>
get very confusing because the analyzer doesn't explore the program in <br>
any particular linear order. Analysis is much better represented as a <br>
graph which can be easily dumped <br>
(<a href="https://www.youtube.com/watch?v=g0Mqx1niUi0" rel="noreferrer" target="_blank">https://www.youtube.com/watch?v=g0Mqx1niUi0</a>). If you want to debug your <br>
checker this way, you should implement the "printState()" method in the <br>
checker, so that to see the extra information from it in the graph.<br></blockquote><div><br></div><div>Can I do this without compiling my own clang and llvm? I have tried to figure out how to dump the graph before, but I thought I ran into the problem of having to have a debug-enabled copy of clang.<br></div><div><br></div><div>By the way, these talk videos you've sent have really been quite useful, and I think they'd be prime candidates for turning into documentation or blog posts! I haven't yet found time to watch them all the way through, but documentation would be searchable and browseable :-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

On 1/11/20 9:05 AM, <a href="mailto:philip.chimento@gmail.com" target="_blank">philip.chimento@gmail.com</a> wrote:<br>
> On Wed, Jan 1, 2020 at 11:57 AM Artem Dergachev <<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a> <br>
> <mailto:<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a>>> wrote:<br>
><br>
>     On 12/30/19 7:55 PM, <a href="mailto:philip.chimento@gmail.com" target="_blank">philip.chimento@gmail.com</a><br>
>     <mailto:<a href="mailto:philip.chimento@gmail.com" target="_blank">philip.chimento@gmail.com</a>> wrote:<br>
>     > However, the returned region seems to be different in the<br>
>     constructor<br>
>     > and in the get() method. For example I'm testing my code with a<br>
>     > "struct MyStruct : std::unique_ptr<char>" and I'll get debug output<br>
>     > such as:<br>
>     ><br>
>     >     constructor: Storing 0 (Loc) into map with key<br>
>     > SymRegion{conj_$5{struct MyStruct *, LC1, S3038538, #1}}<br>
>     >     get(): Retrieving key SymRegion{reg_$0<const struct MyStruct *<br>
>     > this>}: not present<br>
>     That sounds strange because i think i fixed most of these problems<br>
>     (<a href="https://www.youtube.com/watch?v=4n3l-ZcDJNY" rel="noreferrer" target="_blank">https://www.youtube.com/watch?v=4n3l-ZcDJNY</a>). Can you post the<br>
>     specific<br>
>     code you're trying to analyze? Is your Clang fresh enough?<br>
><br>
><br>
> I'm using 9.0.0, would this be something that I need to build the <br>
> master branch for?<br>
><br>
> The test code I'm trying to analyze is this:<br>
><br>
> struct Context;<br>
> char* StringFunc(Context* cx);<br>
><br>
> struct MyStruct : public std::unique_ptr<char> {<br>
>     MyStruct(char* p) : MyStruct::unique_ptr(p) {}<br>
>     operator bool() const { return !!get(); }<br>
> };<br>
><br>
> MyStruct OkayBoolConvertibleReturn(Context* cx) {<br>
>     char* ptr = StringFunc(cx);<br>
>     if (ptr)<br>
>         return ptr;<br>
>     return nullptr;<br>
> }<br>
><br>
> Cheers,<br>
> -- <br>
> Philip<br>
<br>
</blockquote></div><br clear="all"></div>Cheers,<br><div>-- <br><div dir="ltr" class="gmail_signature">Philip</div></div></div>