<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Probably easiest to do by deriving from RecursiveASTVisitor and incrementing your counter by one for each ArraySubscriptExpr. That's assuming you want to count all 'array[index]' expressions. If you want to count all references to array-typed variables, it's best to look for DeclRefExpr-s whose type is an ArrayType. If you also want to find array references from functions calls, I think you'd better visit all Expr-s, and check their type for ArrayType.<br></div>
<div> </div>
<div>Hope this helps!<br></div>
<div> </div>
<div id="sig19426269"><div class="signature">-- <br></div>
<div class="signature">  Gábor Kozár -- ShdNx<br></div>
<div class="signature">  kozargabor@gmail.com<br></div>
<div class="signature"> </div>
</div>
<div> </div>
<div> </div>
<div>On Sat, Sep 14, 2013, at 12:02, ruhdam wrote:<br></div>
<blockquote type="cite"><div>Hi,<br></div>
<div>How can we count number of array references in a given C code with clang?<br></div>
<div>Assume code looks like this,<br></div>
<div>void main()<br></div>
<div>{<br></div>
<div>     int a[10];<br></div>
<div>    a[5]=a[5]+1;<br></div>
<div>}<br></div>
<div> </div>
<div>in the above code, number of array references are 2.<br></div>
<div> </div>
<div> </div>
<div> </div>
<div>--<br></div>
<div>View this message in context:<br></div>
<div><a href="http://clang-developers.42468.n3.nabble.com/Count-number-of-array-references-tp4034459.html">http://clang-developers.42468.n3.nabble.com/Count-number-of-array-references-tp4034459.html</a><br></div>
<div>Sent from the Clang Developers mailing list archive at Nabble.com.<br></div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
</blockquote></body>
</html>