[cfe-dev] Missing FieldDecl from macro calls and template arguments

Adrien Chauve adrien.chauve at gmail.com
Wed Jun 15 12:27:59 PDT 2011


Hi,

I've implemented an ASTConsumer deriving from RecursiveASTVisitor to
rename field names. The consumer implements VisitFieldDecl and
VisitMemberExpr,
but it seems that (at least) two kinds of expressions are not visited.

1- First, function arguments that are instance of templates, e.g.:

    template<typename T>
    struct Foo
    {
        int bar;

        void copy(const Foo<T>& other) {
            bar = other.bar;  /// bar is visited but not other.bar
        }
    };


If I write the same code but with a non-template Foo struct, all bar
member expressions are visited.


2- Code inside macros, e.g.:

    Foo foo;
    foo.bar = 2; // bar is visited
    assert(foo.bar == 2); // bar is not visited

Do I have to get the body of the macro from the Preprocessor and make
something with it?



In both cases I really don't have a clue why these expressions are not visited.

Thanks for the hints,
Adrien



More information about the cfe-dev mailing list