Proper template handling in C++
Currently templates are not handled properly:
template <typename>
struct S
{
int member;
};
int main()
{
S<int> s;
int i = s.member;
}
Issues:
- [ ] Querying info tree on
memberinside the definition ofSshows that this variable has only 1 usage in this code. - [x] Clicking on
memberinsidemain()crashes the web server. (Fix: #438)
I tried to reproduce the error with the given example with my branch standing on de4ce6f. The crash did not happen when clicking member inside main(), the info tree gave correct usage information for this occurrence of member. However, when I pulled all commits until fcf9666, the crash did happen. I assume a recent pull request might have caused this bug.
Calling info tree on member inside the declaration of S gave the same wrong result in both cases that was described before (only 1 usage).
This is a good catch, thanks. It is interesting, however, if I print the generated ID in this function, it shows that 3 instances of member function go to the database: two of them in line 3 with different mangled names and another one in line 6. It is not too surprising, because mangled name includes a lot of context in case of variables, so it's quite unstable. I hope USR will work better and it will solve the second half of the issue.
I have tested this on https://codecompass.net/ on a few template classes and functions in the source code of CodeCompass itself, and I could not reproduce the usage count bug, so I consider this resolved.