Bug 509060 - [Extract Function] incorrectly extract multiple insertion operations (<<)
Summary: [Extract Function] incorrectly extract multiple insertion operations (<<)
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: Next   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: 2016-12-12 04:16 EST by Daniel Marty CLA
Modified: 2020-09-04 15:22 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Marty CLA 2016-12-12 04:16:16 EST
Only the last insertion operation seems to be responsible for the outcome of the extraction.

/*$*/a++;/*$$*/
std::cout << a;

Above selection is correctly extracted:

int extracted (int a) {
   a++;
   return a;
}

But following is incorrectly extracted:

/*$*/a++;/*$$*/
std::cout << a << '\n';

->

void extracted(int a) {
   a++;
}

Following example with 2 variables shows that it is the last insertion operation that works correctly.

/*$*/a++;
b++;/*$$*/
std::cout << a << b;

-> 

int extracted(int a, int b) {
	a++;
	b++;
	return b;
}

but it should be:

int extracted(int a, int& b) {
	a++;
	b++;
	return a;
}

The Set returned by getVariableReadOutside() in NodeContainer does only contain the variable of the last << operation.
getFlowInfo(IASTNode node) inside FlowAnalyzer removes the entry of the HashMap. Maybe it can be fixed by changing it to get() instead of remove()