[cfe-dev] visiting complex<> declarations
John McCall
rjmccall at apple.com
Wed Feb 20 15:49:34 PST 2013
On Feb 20, 2013, at 12:38 PM, suppamax <max.giacometti at gmail.com> wrote:
> I am trying to get familiar with clang's AST.
>
> I want to parse some code that includes statements like
>
> complex<double> c1(1.1, 3.6);
> complex<double> c2(34.3, 8.7);
> complex<double> c3;
> c3 = c1 + c2;
>
> In my ASTVisitor class I have
>
> bool VisitVarDecl(VarDecl *v) {
> ...
> return true;
> }
>
> bool VisitBinaryOperator(BinaryOperator* bo) {
> ...
> return true;
> }
>
> These visiting functions work for floating point variables and arrays, but
> they're not used when complex data are met.
>
> Can you please help me clarifying?
The VarDecl visitor should certainly work. The BinaryOperator visitor
won't work because std::complex<T> is not a builtin type and its operators
are not builtin operators; you'll need to visit CXXOperatorCallExprs.
If this were the C99 _Complex T type, you'd still see BinaryOperator
expressions.
John.
More information about the cfe-dev
mailing list