[cfe-dev] Get number of unique operators and operands for calculation of Halstead metrics

Douglas Gregor dgregor at apple.com
Mon Aug 16 07:27:11 PDT 2010


On Aug 15, 2010, at 1:27 PM, manavender reddy wrote:

> Hi all,
> 
> Can anyone help me with this. How can i find number of unique operators and operands in a function. Here's what i am doing.
> I first got an CFG of the function and then i am going through each block. I am stuck after that, i dont know how to parse each Stmt/Expr in a block to get operators and operands ? 

You can gather this information by walking the abstract syntax tree. Look for StmtVisitor in the Clang code-base; it will help you walk the AST so you can count operators and operands.

	- Doug





More information about the cfe-dev mailing list