<div dir="ltr"><div dir="ltr"><div>Hi!<br><br></div><div>If you look at how <span style="font-family:monospace,monospace">addTransition</span> is implemented, you can see a big TODO before a defensive check:<br><a href="https://github.com/llvm-mirror/clang/blob/7c8e954f273730037b454edf94c8d13123dbedf6/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h#L289">https://github.com/llvm-mirror/clang/blob/7c8e954f273730037b454edf94c8d13123dbedf6/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h#L289</a><br></div><div>According to that, it would seem that a checker-side check should always be there.<br><br></div><div>Let's see what others think of this -- to me it would make more sense to have this check within <span style="font-family:monospace,monospace">addTransition</span>, and I'm unsure myself why that TODO is there.<br></div></div></div><br><div class="gmail_quote"><div dir="ltr">Lou Wynn via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> ezt írta (időpont: 2018. okt. 9., K, 3:42):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p><font size="+1">Hi,</font></p>
    <p><font size="+1">I read the comment "avoid loops in the exploded
        graph" in the following snippet of code which is on page 32 of
        the <a href="https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf" target="_blank">workbook</a>.</font></p>
    <p><tt><font size="+1">LocationContext *LC = C. getLocationContext
          ();
          <br>
          ProgramStateRef State = C. getState ();
          <br>
          const Expr *E = /* Obtain an expression value of which is
          untrusted */;
          <br>
          ProgramStateRef NewState = State -> addTaint (E, LC );
          <br>
          if ( NewState != State ) // avoid loops in the exploded graph
          <br>
            C. addTransition ( NewState );</font></tt></p>
    <p><font size="+1">My question is why the new tainted state requires
        the if statement to prevent loops, while other new states in the
        book do not have the if statement when C.addTransition(State) is
        used? Do other states which are not tainted not need to prevent
        loops? For example, on page 30, when a new state is added, it
        reads:</font></p>
    <p><tt><font size="+1">ProgramStateRef State = C. getState ();
<br>
          State = modifyState ( State ); // do stuff
<br>
          C. addTransition ( State );</font></tt></p>
    <p><font size="+1">There is no if state to prevent a loop.<br>
      </font></p>
    <pre class="m_4496106036804767320moz-signature" cols="72">-- 
Love,
Lou

</pre>
  </div>

_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>