Author |
Topic |
|
stifu
New Member
9 Posts |
Posted - Jul 31 2020 : 06:07:12 AM
|
The function "find all references" can distinguish between read and write access of a certain variable. However, this only works inside the scope of this variable. If you pass a variable by non-const reference or by pointer to a function/method, VA lists the variable in that function call as a read access, although the function might actually modify the underlying data.
As it is a common usecase, to find all places where a certain variable is modified, it would be incredibly useful if these function calls were listed as a "potential write access". This could be achieved by looking at the signature of the called function to check if the parameter is passed by non-const reference or by pointer to non-const object. |
|
feline
Whole Tomato Software
United Kingdom
19039 Posts |
Posted - Jul 31 2020 : 08:07:35 AM
|
This is something we are considering doing at some point:
case=9955
the main complication here is overloaded methods. Ignoring them, and macros, its fairly straight forward to identify possibly modified locations. But once overloads and macros are considered, it gets quite a bit more tricky. But we do see the value in this idea, it's just not easy |
zen is the art of being at one with the two'ness |
|
|
stifu
New Member
9 Posts |
Posted - Jul 31 2020 : 2:04:49 PM
|
Right, overloads and macro indeed make it more complex. Maybe a "references in function calls" filter, i.e., without checking the function signature, could be a first step, that could be improved upon later on.
Now that I think about it: Someone could also create a shorthand alias-reference int& i = MyLongVariableNameIDoNotWantToRepeatEachTime; or, similarily, a pointer int* i = &MyLongVariableNameIDoNotWantToRepeatEachTime; that you'd have to track as well, if you really want to catch all writes.
|
|
|
feline
Whole Tomato Software
United Kingdom
19039 Posts |
Posted - Aug 01 2020 : 09:09:35 AM
|
Yes, this is where it starts to get tricky. We can and do identify direct updates, but beyond this, its all a lot more unclear. |
zen is the art of being at one with the two'ness |
|
|
kimbo
Senior Member
43 Posts |
Posted - Nov 22 2024 : 06:24:11 AM
|
digging up...
I would also suggest to check the member function constness here.
I often search for variables and got lots of results where a member function is called and it would be nice to see if this is a const one. That would really help to find the "write" places. Turning off the "Display read references" doesn't work for me (it shows nearly nothing).
If there are const/nonconst overloadings, it's fine to mark them as non-const. |
|
|
feline
Whole Tomato Software
United Kingdom
19039 Posts |
Posted - Nov 25 2024 : 09:22:20 AM
|
That makes sense, and I can see how this is both a logical extension of what we are already doing, and a helpful filter when doing a find on a widely used variable. I have put in a feature request for this to see what our developers make of this:
case=165208 |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|