<html>
<head></head>
<body>
<p>Hi,</p>
<p>Up to now, to determine if two objects "Stmt" were the same, I have been using the function "areSameExpr", which appers at the end of this link:</p>
<p><a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a></p>
<pre><span class="k">static</span> <span class="kt">bool</span> <span class="nf">areSameExpr</span><span class="p">(</span><span class="n">ASTContext</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="k">const</span> <span class="n">Expr</span> <span class="o">*</span><span class="n">First</span><span class="p">,</span>                        <span class="k">const</span> <span class="n">Expr</span> <span class="o">*</span><span class="n">Second</span><span class="p">)</span> <span class="p">{</span>  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">First</span> <span class="o">||</span> <span class="o">!</span><span class="n">Second</span><span class="p">)</span>    <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>  <span class="n">llvm</span><span class="o">::</span><span class="n">FoldingSetNodeID</span> <span class="n">FirstID</span><span class="p">,</span> <span class="n">SecondID</span><span class="p">;</span>  <span class="n">First</span><span class="o">-></span><span class="n">Profile</span><span class="p">(</span><span class="n">FirstID</span><span class="p">,</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="nb">true</span><span class="p">);</span>  <span class="n">Second</span><span class="o">-></span><span class="n">Profile</span><span class="p">(</span><span class="n">SecondID</span><span class="p">,</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="nb">true</span><span class="p">);</span>  <span class="k">return</span> <span class="n">FirstID</span> <span class="o">==</span> <span class="n">SecondID</span><span class="p">;</span><span class="p">}</span></pre><p>However, I have a problem with that function. To illustrate the issue, I retrieve a concrete Stmt (in bold in the example below) in a CompoundStmt through a matcher:</p>
<p>{<br/>
A::getca();<br/>
m();<br/>
<strong>A::getca(); </strong><br/>
int  l = 1; <br/>
}</p>
<p>Then, when handling that Stmt, I search for the position of that stmt within the compoundStmt with a simple loop and using the function  <span class="nf">"areSameExpr</span>" aforementioned.</p>
<p>for(CompoundStmt::body_iterator st = CompStmt->body_begin(); st != CompStmt->body_end(); st++){ <br />                     <br />                    if(areSameStmt(Context, *st, StmtBound)){<br/>
                    ....<br/>
                   }<br/>
}</p>
<p>However, this function considers that the first stmt in the compoundStmt is the same as the third one, and that is a problem in my case because I need to determine every stmt as unique to know the position. <br/>
I have been studying the class llvm::FoldingSetNodeID<br/>
<a href="http://llvm.org/docs/doxygen/html/classllvm_1_1FoldingSetNodeID.html#a66f5b8a0b6a74b310d856ca736c1eb8c" target="_blank">http://llvm.org/docs/doxygen/html/classllvm_1_1FoldingSetNodeID.html#a66f5b8a0b6a74b310d856ca736c1eb8c</a></p>
<p>I tried to use the method "ComputeHash" to compare both stmt, but it didn't suppose any change.</p>
<p>Please, does anyone know how I could fix this?</p>
<p>Thanks,</p>
<p>Pedro.</p>

</body>
</html>