<div dir="ltr"><div>Thanks for your help!<br><br></div><div>Regards,<br></div>Xin<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-20 0:16 GMT-07:00 Artem Dergachev <span dir="ltr"><<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the function is inlined, then its exploded graph becomes part of the big graph, with the necessary adjustments to the context.<br>
<br>
If it is not inlined ("evaluated conservatively), then just one CallExpr node is added to the graph instead; in this case the graph of the callee function is not looked at (it may not even be available), and this node behaves similarly for all functions: by destroying the data gathered by the analyzer if this function call might have altered this data. In any case there may be more nodes added by the checkers around the call.<div><div class="h5"><br>
<br>
20/06/2017 8:33 AM, Xin Wang 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">
Thank you very much!<br>
<br>
But I still have a question. I am writing a checker to check if a function is called during ctor/dtor.<br>
<br>
void VirtualCallChecker::checkPreCa<wbr>ll(const CallEvent &Call,<br>
CheckerContext &C) const {<br>
const Decl *D = dyn_cast_or_null<Decl>(Call.ge<wbr>tDecl());<br>
if (!D)<br>
return;<br>
ProgramStateRef state = C.getState();<br>
// Enter a constructor, increase the corresponding integer<br>
if (dyn_cast<CXXConstructorDecl>(<wbr>D)) {<br>
unsigned constructorflag = state->get<ConstructorFlag>();<br>
state = state->set<ConstructorFlag>(++<wbr>constructorflag);<br>
C.addTransition(state);<br>
return;<br>
}<br>
if (state->get<ConstructorFlag>() > 0) {<br>
if (!BT_CT) {<br>
BT_CT.reset(new BugType(this, "Call to virtual function<br>
during construction",<br>
"not pure"));<br>
}<br>
ExplodedNode *N = C.generateNonFatalErrorNode();<br>
auto Reporter = llvm::make_unique<BugReport>(*<wbr>BT_CT,<br>
BT_CT->getName(), N);<br>
C.emitReport(std::move(Reporte<wbr>r));<br>
return;<br>
}<br>
}<br>
<br>
If I use this checker to check the code which use the pointer to construct the class, it seems that the static analyzer doesn't enter the construction which is not inline. Is it true that the static analyzer doesn't enter the exploded graph which is not inline?<br>
<br>
Regards,<br>
Xin<br>
<br></div></div>
2017-06-19 12:00 GMT-07:00 Artem Dergachev <<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a> <mailto:<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a>>>:<div><div class="h5"><br>
<br>
It seems that in the first case the analyzer decides to inline the<br>
constructor - i.e. jump into it and see what exactly is going on<br>
inside it, and apply these operations within the current analysis.<br>
And then it decides not to analyze the constructor separately,<br>
because it has a better idea about this part of the program when<br>
it knows what's going on around the code.<br>
<br>
Normally we don't guarantee that we inline any particular<br>
function, just try our best. In this case, it might be that the<br>
analyzer just wasn't ever taught that operator-new calls *that*<br>
constructor; instead, he decides to behave as if an unknown<br>
function is being called.<br>
<br>
In fact, you can see and confirm all the details by looking at the<br>
exploded graphs themselves; they should be quite easy to<br>
understand, even though they often contain too much information.<br>
<br>
On 6/19/17 7:05 PM, Xin Wang via cfe-dev wrote:<br>
<br>
Hello everyone,<br>
<br>
I have some questions about the exploded graph.<br>
<br>
/class A {<br>
public:<br>
A() {foo();}<br>
void foo();<br>
};<br>
int main() {<br>
/<br>
/ A a;<br>
/<br>
/}<br>
/<br>
When I use the clang to dump the exploded graph of the code<br>
above. There is only one exploded graph.<br>
<br>
/class A {<br>
public:<br>
A() {foo();}<br>
void foo();<br>
};<br>
int main() {<br>
A *a = new A();<br>
/<br>
/ delete a;<br>
/<br>
/}<br>
<br>
/<br>
But when I dump the code above. There is two exploded graph,<br>
one for main and another for the construction of the class A.<br>
<br>
My question is: what is the difference between using the<br>
pointer and using the object to initialize a class? Can I use<br>
the path-sensitive checker to explore the exploded graph of<br>
the construction.<br>
<br>
Regards,<br>
Xin<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br></div></div>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a> <mailto:<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><wbr>><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin<wbr>/mailman/listinfo/cfe-dev</a>><br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>