binary operator

Hi,

When iterating through the AST I encounter BinaryOperator-s, part of an
IfStmt.
My question now is: how can I find which operator it is? E.g. ==, >=,
etc.
I'm using libclang.

Folkert van Heusden

Hi Folkert,

Hi,

> When iterating through the AST I encounter BinaryOperator-s, part of an
> IfStmt.
> My question now is: how can I find which operator it is? E.g. ==, >=,
> etc.
> I'm using libclang.

You can call BinaryOperator::getOpcode, which will return an Opcode,
which is a typedef of the BinaryOperatorKind enum.

That is part of the C++ api right? I'm using the one with the clang_
prefixes and I could not find any getOpcode call in there (I checked
Index.h).

Folkert van Heusden

> When iterating through the AST I encounter BinaryOperator-s, part of an
> IfStmt.
> My question now is: how can I find which operator it is? E.g. ==, >=,
> etc.
> I'm using libclang.
>

You can call BinaryOperator::getOpcode, which will return an Opcode,
which is a typedef of the BinaryOperatorKind enum.

This c++ version, is this from libtooling? Or which library?

Folkert van Heusden

The C++ clang library (libclang?)

http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html

I thought you had an instance of this class.

Csaba