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
 Technical Support
 Find References does not work with constructors
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

XMi
Junior Member

11 Posts

Posted - May 12 2015 :  02:31:48 AM  Show Profile  Reply with Quote
Hi.

I noticed a few problems with the Find References. It does not work properly with constructors, destructors and overloaded operators.

In the sample code below, if I run 'Find References' on one of the constructors or the destructor, VA list me all the occurrences of the class name. If I run it on operator=(), I get an error message "Find References is not available because the symbol is unrecognized."

Regards,
Xavier


#include <iostream>
#include <string>


class Foo 
{
public:
   Foo(std::string const& name);
   ~Foo();
private:
   Foo(Foo const& ref);
   Foo& operator=(Foo const&);
   std::string name_;
};


Foo::Foo(std::string const& name)
   : name_(name)
{
}


Foo::~Foo()
{
}


Foo::Foo(Foo const& ref)
   : name_(ref.name_)
{

}


Foo& Foo::operator=(Foo const& ref)
{
   name_ = ref.name_;
   return *this;
}


int main(int argc, char* arg)
{
   Foo("bar");
   return 0;
}


My setup:
VS2013 Pro
Windows 8.1 Pro 64bit EN
VA build 2062

feline
Whole Tomato Software

United Kingdom
18983 Posts

Posted - May 12 2015 :  10:43:39 PM  Show Profile  Reply with Quote
Find References on the constructor returning all references to the class is currently expected behaviour. We are considering a change to how Find References handles constructors, the trick is to pick up all of the spots where a class instance is being constructed:

case=1262

You also mention destructors. What are you expecting to happen here? Sometimes the destructor is called when the class instance goes out of scope, so there is no explicit reference to try and find here.

Better handling of overloaded operators is also something we are considering, but if anything this can be even more tricky than constructors, depending on which operator has been overloaded:

case=57778

zen is the art of being at one with the two'ness
Go to Top of Page

XMi
Junior Member

11 Posts

Posted - May 13 2015 :  12:55:20 AM  Show Profile  Reply with Quote
Hi.

I knew what I asked was tricky, and thank you for your answer. mostly because of the implicit calls made to those functions. Yesterday I noticed you put a warning in the 'Change Signature' dialog when calling it with a constructor. Maybe you could put a similar warning in the 'Find Reference' window: "Here are the explicit calls we could find, but there may be some implicit call to this function.


Edited by - XMi on May 14 2015 12:42:25 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18983 Posts

Posted - May 13 2015 :  11:05:54 PM  Show Profile  Reply with Quote
This is a good point, and we may well do something like that when we try allowing Find References to pick up constructors. Hopefully what we do will be reasonably robust before being released, but there are always edge cases if you know where to look.

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