Community
Participate
Working Groups
In the following code class A { public: void m(); }; void test() { A a; a.m(); } CPPVariableReadWriteFlags.getReadWriteFlags returns READ for 'a' in a.m(). It should return WRITE since the method m is not declared const.
Created VariableReadWriteFlagsTest, which uncovered two more problems: 1. int a = 1; READ | WRITE instead of expected WRITE 2. struct A { int x; }; void test() { A a; a.x = 1; READ instead of expected WRITE };
Created attachment 210705 [details] Proposed fix Markus, Could you please review the attached fix for the function call issue. Thanks.
Comment on attachment 210705 [details] Proposed fix Looks good to me.
(In reply to comment #3) > Comment on attachment 210705 [details] > Proposed fix > Looks good to me. It just came to my mind that you may have to check the indirection of using the variable. The indirection is passed around as an argument and is modified when one of the operators [], *, & is encountered. Currently it is not adjusted when the operator -> is found. void test() { A* ap; A a; (*ap).m(); // read access to ap ap->m(); // read access to ap (&a)->m(); // read/write access to a }
Fixed in master.
*** cdt git genie on behalf of Sergey Prigogin *** Bug 370887 - CPPVariableReadWriteFlags.getReadWriteFlags returns incorrect results. [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=61e9d699ba21775a06748d2fbf3183d064411c37
*** cdt git genie on behalf of Sergey Prigogin *** Bug 370887 - CPPVariableReadWriteFlags.getReadWriteFlags returns incorrect results. [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=61e9d699ba21775a06748d2fbf3183d064411c37 *** cdt git genie on behalf of Sergey Prigogin *** Bug 370887 - CPPVariableReadWriteFlags.getReadWriteFlags returns incorrect results. [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=61e9d699ba21775a06748d2fbf3183d064411c37