visiting complex<> declarations

Hi all,

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


I added

  bool VisitCXXOperatorCallExprs(CXXOperatorCallExpr *e) {
    llvm::errs() << "Visiting cxxoperatorcall" << "\n";
    return true;

class MyASTVisitor : public RecursiveASTVisitor<MyASTVisitor>
but I don't see the desired print.

  bool VisitVarDecl(VarDecl *v) {
    llvm::errs() << "Visiting declaration of variable " <<
v->getDeclName().getAsString() << "\n";
    return true;

is inactive regarding complex<> variable declaration, while it works fine
for float variables.

Any other suggestion?

   Maybe you should override shouldVisitTemplateInstantiations <>.

I tried also overriding shouldVisitTemplateInstantiations, but nothing