Author |
Topic |
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Apr 23 2019 : 4:43:30 PM
|
Hi there,
We have (unfortunately) a code structure that uses nested classes in lieu of namespaces. For example:
Foo.h
class Foo
{
void FooBlah();
class Bar
{
void BarBlah();
int _soap;
}
}
Foo.cpp:
void Foo::FooBlah();
{
// ...
}
Bar.cpp:
void Foo::Bar::BarBlah()
{
_soap++;
}
If I right click on _soap in the header, VAX can't find it's references (it only lists a reference to it in this header). It also has trouble finding some functions in the symbols dialog, refactoring, etc...
Known issue?
Thanks |
Edited by - swinefeaster on Apr 23 2019 4:44:29 PM |
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Apr 23 2019 : 8:51:22 PM
|
I've created a test project in an attempt to try to reproduce your problem on my side. Unfortunately, I wasn't able to.
Can you please contact [email protected] ? I'll reply back with my test project zipped up if you would like to test it out. It would be helpful to know whether you're still seeing the same problem on your side with this project as well.
Please mention the URL of this topic in your mail so we can match it up. |
Edited by - accord on Apr 23 2019 8:53:47 PM |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Apr 25 2019 : 05:35:40 AM
|
Are all of the functions that VA has trouble finding nested classes, or members of nested classes?
If you jump to the header file where these classes are defined, and look at VA Outline, is VA showing the correct outline for the file? If you use Alt-G on the function declarations, are you taken to the function implementation in the matching cpp file? I am wondering if VA is having any problems parsing some of these files.
If there is something in a few of the files confusing our parser then it would explain why it only effects some classes, and why a simple example does not reproduce it here. |
zen is the art of being at one with the two'ness |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Apr 25 2019 : 2:32:18 PM
|
quote: Originally posted by feline
Are all of the functions that VA has trouble finding nested classes, or members of nested classes?
Yes, it appears it happens in this nested class. If I test the parent class, VA finds everything correctly.
quote: [i]If you jump to the header file where these classes are defined, and look at VA Outline, is VA showing the correct outline for the file? If you use Alt-G on the function declarations, are you taken to the function implementation in the matching cpp file? I am wondering if VA is having any problems parsing some of these files.
VA Outline shows the data members for this nested class, but can't find them in the class's .cpp. So Find References just shows their usage in other classes, but not in it's own class.
Using VA to just to member function implementation doesn't work for this class. Visual Studio is able to find the implementation just fine though.
How can I give you info about where the parser is getting lost without giving you confidential code? |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Apr 25 2019 : 3:10:57 PM
|
We can look at code confidentially, but I appreciate this is often not an option, so for now we can try to pin down the trigger for the problem, and why we cannot reproduce the problem here based on your example above.
In the example above you are using fully qualified names. Is this normal? Or do you try some form of "using class Foo" in the cpp files? Similar to how you can do using namespace?
Do you use macros in "bar.cpp" to help generate the function names?
If you make sure that "bar.cpp" is closed, so it is not one of the open tabs in the IDE, and now show VA's Open File dialog (Alt-Shift-O) is this file listed? I am wondering if the file is actually being picked up as part of the solution.
A related thought, is "bar.cpp" part of the same project as "foo.cpp"? If it is in a different project, and VA's Find References is set to only search the current project then we might be deliberately ignoring the "bar.cpp" file.
I am just trying to to think of anything that you might be doing that could trigger the problem, so we know where to look.
If none of this applies, can you please go to "bar.cpp" and place the caret into the function name. If you now use Alt-G what happens? If you run Find References from the function name in "bar.cpp" what happens?
I have your email, I will reply with a simple test solution, along with notes on what results I am seeing inside the test solution soon. |
zen is the art of being at one with the two'ness |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Apr 25 2019 : 7:50:04 PM
|
quote: Originally posted by feline
We can look at code confidentially, but I appreciate this is often not an option, so for now we can try to pin down the trigger for the problem, and why we cannot reproduce the problem here based on your example above.
In the example above you are using fully qualified names. Is this normal? Or do you try some form of "using class Foo" in the cpp files? Similar to how you can do using namespace?
>> we use fully qualified names in the cpp, not using
Do you use macros in "bar.cpp" to help generate the function names?
>> no macros
If you make sure that "bar.cpp" is closed, so it is not one of the open tabs in the IDE, and now show VA's Open File dialog (Alt-Shift-O) is this file listed? I am wondering if the file is actually being picked up as part of the solution.
>> yes verified it shows up
A related thought, is "bar.cpp" part of the same project as "foo.cpp"? If it is in a different project, and VA's Find References is set to only search the current project then we might be deliberately ignoring the "bar.cpp" file.
>> yes same project
I am just trying to to think of anything that you might be doing that could trigger the problem, so we know where to look.
If none of this applies, can you please go to "bar.cpp" and place the caret into the function name. If you now use Alt-G what happens?
>> nothing shows up (if I do it on a parent member function in the parent class's cpp file, the popup menu shows up just fine)
If you run Find References from the function name in "bar.cpp" what happens?
>> --------------------------- Visual Assist --------------------------- Find References is not available because the symbol is unrecognized. --------------------------- OK ---------------------------
I have your email, I will reply with a simple test solution, along with notes on what results I am seeing inside the test solution soon.
|
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Apr 26 2019 : 06:35:27 AM
|
In a way this explains the problem you are having. Since Find References cannot be run on the function name in "bar.cpp", this tells us that VA is not able to parse this file correctly. Since we cannot parse it correctly, we won't find results inside of this file when searching from another file.
If you look at both the Alt-M (list of methods in the current file) and VA Outline for "bar.cpp" are you seeing anything that looks odd or wrong? Often if something is confusing our parser then this will also effect one or both of these, and give you a clue as to where in the file the problem starts.
If you go to the first function implementation in "bar.cpp" and run Find References on it, does this work? Or you you still get the symbol is unrecognized error message?
If you get the error with the very first function implementation, what, if anything, is above this first function? Is it just #include lines? If so, it is possible something in one of the included files is confusing our parser.
What happens if you try Find References on the class names, rather than just the function name? |
zen is the art of being at one with the two'ness |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Apr 26 2019 : 3:21:42 PM
|
quote: Originally posted by feline
In a way this explains the problem you are having. Since Find References cannot be run on the function name in "bar.cpp", this tells us that VA is not able to parse this file correctly. Since we cannot parse it correctly, we won't find results inside of this file when searching from another file.
If you look at both the Alt-M (list of methods in the current file) and VA Outline for "bar.cpp" are you seeing anything that looks odd or wrong? Often if something is confusing our parser then this will also effect one or both of these, and give you a clue as to where in the file the problem starts.
>> ok so Alt-M correctly lists the methods in the cpp. but find references from the header or from the cpp doesn't work correctly as noted earlier.
quote:
If you go to the first function implementation in "bar.cpp" and run Find References on it, does this work? Or you you still get the symbol is unrecognized error message?
>> I get the unrecognized error dialog
quote:
If you get the error with the very first function implementation, what, if anything, is above this first function? Is it just #include lines? If so, it is possible something in one of the included files is confusing our parser.
just some includes and a pragma region. if I edit the lines above the function just to #include the class header file, I still get the same error.
but, if I change the definition from
void Foo::Bar::Blah() { }
to
void Bar::Blah() { }
it fixes the problem. well, it no longer compiles because the compile says error C2653: 'Bar': is not a class or namespace name. But VA Find References now finds it in the header and the cpp (but not in other files that reference it).
quote: What happens if you try Find References on the class names, rather than just the function name?
>> that works without issue. (Find Refences on Bar that is) |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Apr 27 2019 : 07:01:27 AM
|
I am not sure what is going wrong here. Did you receive my email reply? The subject was:
Re: (Case 138761) VAX Has Problems With Nested Classes
and it had my simple test solution attached, where I had set up the code you included in your first post, and cannot reproduce the problem. I was wondering what happened if you tried the same tests in the test solution I sent you.
I am not seeing any obvious clues as to the bug. It does sound like VA does not like nested classes, but it has no problems with your sample nested classes when I test them here. |
zen is the art of being at one with the two'ness |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Jun 06 2019 : 5:47:28 PM
|
so we narrowed it down to the following repro.
any update? would love to see this fix. VS has no problem with it, but VAX fails.
Foo.h
class Foo
{
void FooBlah();
class Bar;
}
Foo.cpp:
void Foo::FooBlah();
{
// ...
}
Bar.h:
class Foo::Bar
{
void BarBlah();
int _soap;
}
Bar.cpp:
void Foo::Bar::BarBlah()
{
_soap++;
}
|
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Jun 08 2019 : 7:08:16 PM
|
Many apologies for the slow reply on this.� There is definitely a problem with VA's ability to understand this code structure.� While trying to make sense of this I have found a few cases where VA has no problems, and understands this forward declared class quite happily, but so far I have not been able to find a pattern to explain why this works in a few cases, and fails most of the time.
I have put in a bug report for this, and am going to see if I can work out a pattern here, in case it will help to offer a work around:
case=140771 |
zen is the art of being at one with the two'ness |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Jun 18 2019 : 12:26:12 PM
|
Apologies for the slow progress here, the root problem here is actually the "final" keyword on the forward declared class. Remove this keyword and the problem goes away. I was never able to reproduce the problem at first since the code samples here don't use "final", but the test solution you sent me that shows the problem does use the "final" keyword.
Assuming you can make a small edit to these classes, I have found a work around. Using the example from the test solution you sent, we start with this forward declared class being defined as:
class Fool::Moo final
{
public:
float Wakawaka(void);
}; change this code to:
#define HIDE_FINAL_FROM_VA final
class Fool::Moo HIDE_FINAL_FROM_VA
{
public:
float Wakawaka(void);
}; when compiled, and the macro is expanded by the pre-processor we end up with exactly the same code, so this won't actually change anything. Before closing the IDE now press the button:
VA Options -> Performance -> Rebuild symbol databases
and close the IDE. Before loading the IDE again find the root directory of your solution, the directory with the ".SLN" file in it. In this directory create a new, empty text file called "va_stdafx.h" and edit the file, so it contains the code:
#define HIDE_FINAL_FROM_VA
and make sure the file ends with a blank line before saving it.
This file should not be added to your solution, VA looks for this file specifically before starting to parse your solution, and uses it to help with any solution specific problems our parser might be having. In this example we are telling VA to ignore this macro, so VA is ignoring the "final" keyword on your class definition.
I have checked, and this fixes the problem here in your test solution. So hopefully this will work for you on your main solution as well. |
zen is the art of being at one with the two'ness |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Jun 18 2019 : 2:34:16 PM
|
Thank you for looking into this and providing the workaround. However, since not all team members are using VAX, adding this hackery will likely be a tough sell.
Are you planning on including a real fix to the next VAX update so that it will be on par with Visual Studio's parsing capabilities of standard C++ code?
Thanks
|
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Jun 19 2019 : 07:05:39 AM
|
Unfortunately I don't currently have an estimate for when this will be fixed. It is a very specific problem, not something that most of our users are going to encounter, so it is not likely to be a major priority. But it is in the list and we will keep an eye on it. |
zen is the art of being at one with the two'ness |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Jun 19 2019 : 1:06:09 PM
|
It should be in the next release that will show up by mid-July. |
|
|
swinefeaster
Tomato Guru
310 Posts |
Posted - Jun 19 2019 : 2:26:46 PM
|
Perfect thank you! |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
|
|
Topic |
|