Iterating through an Expression in the Clang AST

You can use if (isa(stmt)) and if true, recast it as BinaryOperator. Have a look at the tutorials at:
https://github.com/loarabia/Clang-tutorial

The CIrewriter.cpp example gives numerous examples of using visitors like VisitBinaryOperator, handy if you use a recursive AST visitor to walk the tree.

Robert

You can use if (isa(stmt)) and if true, recast it as BinaryOperator.

Just as a aide note, we usually write that with a single dyn_cast rather than isa+cast, to use just one check instead of two.