[cfe-dev] Count number of array references
Gábor Kozár
kozargabor at gmail.com
Sat Sep 14 09:50:08 PDT 2013
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.
Hope this helps!
--
Gábor Kozár -- ShdNx
kozargabor at gmail.com
On Sat, Sep 14, 2013, at 12:02, ruhdam wrote:
Hi,
How can we count number of array references in a given C code with
clang?
Assume code looks like this,
void main()
{
int a[10];
a[5]=a[5]+1;
}
in the above code, number of array references are 2.
--
View this message in context:
[1]http://clang-developers.42468.n3.nabble.com/Count-number-of-array-re
ferences-tp4034459.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[2]cfe-dev at cs.uiuc.edu
[3]http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
References
1. http://clang-developers.42468.n3.nabble.com/Count-number-of-array-references-tp4034459.html
2. mailto:cfe-dev at cs.uiuc.edu
3. http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130914/b3aafa5e/attachment.html>
More information about the cfe-dev
mailing list