Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] issue with ASTRewrite and assert macro



I am trying to understand what the correct behavior would be in this case. I believe when you generate the AST you’re already dealing with the code after preprocessor, so you don’t have any idea about whether it was a macro or not in the original code. Is that correct? If so, then the only possible thing to generate is the expanded version of the macro, i.e. code under the macro definition, right? How is that different from any other code then and why it is not working now… Any suggestions what I should look for?





From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sergey Prigogin
Sent: Friday, July 19, 2013 5:32 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] issue with ASTRewrite and assert macro


I don't think ASTRewrite can handle changes affecting macro arguments. Could you please file a bug. I'll gladly review any patch that comes with it.




On Fri, Jul 19, 2013 at 5:12 PM, Ayupov, Andrey <andrey.ayupov@xxxxxxxxx> wrote:

Just wanted to check if the issue that I am hitting is a known one and would appreciate any feedback on whether there are plans to fix it.

ASTRewrite does not generate assert macro from AST correctly. I made an experiment, where for the following code




I just replaced IASTIdExpression (corresponding to variable ‘a’ in the _expression_ above a>0) by its copy, presumably without changing the AST structure:

rewriter.replace(orig, orig.copy(), null);


The code that’s being generated looks like this:



Just for reference, the assert macro is taken from assert.h that looks like this:

# define assert(expr) \

  (__ASSERT_VOID_CAST ((expr) ? 0 :                                                                           \

                                     (__assert_fail (__STRING(expr), __FILE__, __LINE__,    \

                                                                   __ASSERT_FUNCTION), 0)))





cdt-dev mailing list


Back to the top