[cfe-dev] Missing FieldDecl from macro calls and template arguments
Eli Friedman
eli.friedman at gmail.com
Wed Jun 15 12:53:58 PDT 2011
On Wed, Jun 15, 2011 at 12:27 PM, Adrien Chauve <adrien.chauve at gmail.com> wrote:
> 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
> }
> };
other.bar in this situation is a CXXDependentScopeMemberExpr, I think...
>
> 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?
Are you sure you're compiling the given file with asserts enabled?
The expression won't show up in the AST if it gets #define'ed out.
-Eli
More information about the cfe-dev
mailing list