Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360149 - Cannot extract variable if one of the function arguments is macro expansion.
Summary: Cannot extract variable if one of the function arguments is macro expansion.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: 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-10-06 14:39 EDT by Eugene Ostroukhov CLA
Modified: 2012-05-22 20:43 EDT (History)
2 users (show)

See Also:


Attachments
Suggested fix (933 bytes, patch)
2011-10-06 14:39 EDT, Eugene Ostroukhov CLA
cdtdoug: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Ostroukhov CLA 2011-10-06 14:39:43 EDT
Created attachment 204703 [details]
Suggested fix

Assume following source code:
1 #define BLOCKS 32
2 
3 void myfunction(int a) {}
4 void myfunction(int a, int b) {}
5 
6 void deviceFindMax() {
7 	myfunction(1, BLOCKS);
8 }

On the line 7 select "1" and do "Extract Local Variable". Enter some variable name and proceed to second wizard page. Note that variable declaration is introduced but line 7 was not changed.

In the editor change line 7 to:
7 	myfunction(1);

Verify that 1 can be extracted as expected.

This issue is caused by ASTWriterVisitor detecting that statement has macro expansion (see condition in public int visit(IASTStatement statement)) and copying statement text from the original code without applying any modification.

I do not understand what this code is for hence attached patch is most likely wrong. I would be glad to work more on fixing this issue if somebody could provide me more scenarios to test.
Comment 1 Sergey Prigogin CLA 2011-12-14 15:30:16 EST
Fixed together with bug 363244.