Bug 386473 - refactoring extract local variable only replaces first occurrence
Summary: refactoring extract local variable only replaces first occurrence
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-02 05:49 EDT by maris zarins CLA
Modified: 2020-09-04 15:26 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maris zarins CLA 2012-08-02 05:49:48 EDT
In the following example the extract local variable function does not check for all places where it could substitute.  It gives up after the first substitution.
Before:

int asd = (a+b) * (c+d) *p;
int qwe = (a+b) * (c+d) *q;
int zxc = (a+b) * (c+d) *r;
int rty = (a+b) * (c+d) *s;

After:

int a0 = (a+b) * (c+d);
int asd = a0 * p;
int qwe = (a+b) * (c+d) *q;
int zxc = (a+b) * (c+d) *r;
int rty = (a+b) * (c+d) *s;

If the expression involved a call to a member function I would be quite happy to accept responsibility for ensuring that there were no side effects