Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 393068 - Constructor call is treated as write access for arguments
Summary: Constructor call is treated as write access for arguments
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.2   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Sergey Prigogin CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 394151
  Show dependency tree
 
Reported: 2012-10-29 12:20 EDT by Sergey Prigogin CLA
Modified: 2013-02-27 11:57 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Prigogin CLA 2012-10-29 12:20:41 EDT
To reproduce select the marked line in the code bellow and try to extract a function. The signature of the extracted function is "A* extracted(int* x)", which is an indication that CDT thinks that x can be modified by the A(x) call.
 
struct A {
  A(int s);
};

int test() {
  int x;
  A* a = new A(x);  // Select this line
  delete a;
  return x;
}
Comment 1 Sergey Prigogin CLA 2012-10-29 14:15:33 EDT
The problem stems from the fact that A(x) gets resolved to CPPClassType A instead of CPPConstructor A. As a result getExpressionType() on the containing IASTIdExpression returns EvalFixed.INCOMPLETE. This causes confusion of VariableReadWriteFlags.rwArgumentForFunctionCall(IASTFunctionCallExpression, IASTNode, int) method, which decides to play safe and returns READ | WRITE.
Comment 3 Sergey Prigogin CLA 2012-12-04 23:57:24 EST
Another change related to this bug: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=679683b6c952990e70c413be7cbe438043cf2f3b
Comment 4 CDT Genie CLA 2013-02-27 11:54:19 EST
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 393068 - Constructor call is treated as write access for arguments

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=cfd9acad9531149754b4292161f45a8c305a32af
Comment 5 CDT Genie CLA 2013-02-27 11:54:21 EST
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 393068 - Constructor call is treated as write access for arguments

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=add4edd847636d91be922df9c5d91398d4d29d5d
Comment 6 CDT Genie CLA 2013-02-27 11:56:59 EST
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 393068 - Constructor call is treated as write access for arguments

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=679683b6c952990e70c413be7cbe438043cf2f3b
Comment 7 CDT Genie CLA 2013-02-27 11:57:07 EST
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 393068 - Constructor call is treated as write access for arguments

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=81c9f2d7555147406dc00e29e4641d409e89a0c9