Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 "Find all references" to list potential writes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stifu
New Member

9 Posts

Posted - Jul 31 2020 :  06:07:12 AM  Show Profile  Reply with Quote
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  Show Profile  Reply with Quote
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
Go to Top of Page

stifu
New Member

9 Posts

Posted - Jul 31 2020 :  2:04:49 PM  Show Profile  Reply with Quote
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.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19039 Posts

Posted - Aug 01 2020 :  09:09:35 AM  Show Profile  Reply with Quote
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
Go to Top of Page

kimbo
Senior Member

43 Posts

Posted - Nov 22 2024 :  06:24:11 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19039 Posts

Posted - Nov 25 2024 :  09:22:20 AM  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000