<div dir="ltr">Hi,<div><br></div><div>I noticed a strange behavior of function call inlining when I was debugging my checker. </div><div>For a very simple code example:</div><div><br></div><div><div><font face="monospace, monospace">void func_with_loop(int loop_times) {</font></div><div><font face="monospace, monospace">  for (int i = 0; i < loop_times; i++) {</font></div><div><font face="monospace, monospace">    //Do nothing</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">void call_loop(int tag) {</font></div><div><font face="monospace, monospace">  func_with_loop(tag);</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>When I run clang static analyzer on this piece of code with scan-build, the function "func_with_loop()" will not be inlined by ExprEngine.</div><div><br></div><div>To demo this behavior, here is my patch to the clang to print if the function call is inlined: <a href="https://gist.github.com/zeroomega/bbe2cfa298a912a1b5b37fa4b9cd76b5">https://gist.github.com/zeroomega/bbe2cfa298a912a1b5b37fa4b9cd76b5</a> . The output of clang after this patch is:</div><div><br></div><div><div><font face="monospace, monospace">testmxchannel.c:204:3func_with_loop  Should inline: Direct inlined</font></div><div><font face="monospace, monospace">Block Count exceeded maxBlockVisitOnPath 4Dump SRC</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> [B1]</font></div><div><font face="monospace, monospace">   1: i</font></div><div><font face="monospace, monospace">   2: [B1.1]++</font></div><div><font face="monospace, monospace">   Preds (1): B2</font></div><div><font face="monospace, monospace">   Succs (1): B2</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> Dump Dst:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> [B2]</font></div><div><font face="monospace, monospace">   1: i</font></div><div><font face="monospace, monospace">   2: [B2.1] (ImplicitCastExpr, LValueToRValue, int)</font></div><div><font face="monospace, monospace">   3: loop_times</font></div><div><font face="monospace, monospace">   4: [B2.3] (ImplicitCastExpr, LValueToRValue, int)</font></div><div><font face="monospace, monospace">   5: [B2.2] < [B2.4]</font></div><div><font face="monospace, monospace">   T: for (...; [B2.5]; ...)</font></div><div><font face="monospace, monospace">   Preds (2): B1 B3</font></div><div><font face="monospace, monospace">   Succs (2): B1 B0</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">testmxchannel.c:204:3func_with_loop  InlinedFailedState is not null  Should not inline </font></div></div><div><br></div><div>It seems that the ExprEngine did try to inline the function "func_with_loop", but the total block count of this function exceeded "maxBlockVisitOnPath", which by default is 4. The inline process was rolled back and this function is evaluated by "conservativeEvalCall". I manually increased the value of "maxBlockVisitOnPath" but "<span style="font-family:monospace,monospace">func_with_loop" </span><font face="arial, helvetica, sans-serif">was still not inlined.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Is it an intended behavior of clang static analyzer or is it a bug? In my understanding, by default, when clang static analyzer evaluate a loop that the total times of the loop cannot determined, the loop will be evaluated for 4 times and an additional ExplodedNode will be created with the loop condition evaluated to false. But why in this code example it causes the function inline to be rolled back instead of creating an additional node that evaluate the loop conditions to false?</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Another question I have is that is it possible in checkPreCall() callback of a checker to determine if the function call will not be inlined by ExprEngine? </font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks for any help,</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Haowei</font></div></div>