Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334188 - The refactoring infrastructure does not apply changes made to ASTNodes that are a part of a statement if any part of the statement is a macro
Summary: The refactoring infrastructure does not apply changes made to ASTNodes that a...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Sergey Prigogin CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 20:55 EST by Fredrik Berg Kjolstad CLA
Modified: 2012-05-22 20:20 EDT (History)
5 users (show)

See Also:


Attachments
Removes a check that directly prints verbatim statements with macro sub-nodes (2.52 KB, patch)
2011-01-12 21:07 EST, Fredrik Berg Kjolstad CLA
cdtdoug: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fredrik Berg Kjolstad CLA 2011-01-12 20:55:47 EST
Build Identifier: M20100909-0800

If any child node of an IASTStatement (except for Compund statements) is a macro then the refactoring infrastructure will not apply any changes made to another child node.

The following function call demonstrates the bug. I want replace the last actual argument of the MPI_Isend function with another expression:
MPI_Isend(message, strlen(message) + 1, MPI_CHAR, 1, 42, MPI_COMM_WORLD, &waitreq2);

However, since MPI_CHAR is a macro the ASTWriterVisitor decides to write the statement directly, and aborts further processing in its sub-tree.

The code in question is line 185-187 in visit(IASTStatement statement) in ASTWriterVisitor.java.  Here, the method StatementWriter.writeMixedStatement is called to print the statement directly, without the modifications in its subtree, if it contains a macro.  On the next line, 188, provisions are made in the case where the statement itself is a macro.

I can not easily work around this by just replacing the whole statement, as I do not know which actual I need to modify (I discover this by searching for all variables for a binding).

Reproducible: Always

Steps to Reproduce:
1. Create a statement containing a macro in one actual argument
2. Use ASTRewriter.replace (remove works too) to replace one actual argument
3. Apply the rewriter and observe that the modification was lost
Comment 1 Fredrik Berg Kjolstad CLA 2011-01-12 21:07:48 EST
Created attachment 186696 [details]
Removes a check that directly prints verbatim statements with macro sub-nodes

Is the code to directly print statements containing various macros correct, and what is its purpose?  It seems that it may be unnecessary as the macros will be dealt with anyway when the sub-nodes are visited by the printer.

The attached patch removes this check altogether, which fixes my problem.  Does this break another case I have failed to anticipate?
Comment 2 Sergey Prigogin CLA 2011-12-14 15:40:47 EST
Fixed together with bug 363244.