-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Multiple CppFunction entities #720
Comments
Current stateDepending on the kind of VariablesThis code produces 3
This code also produces 3
Note that an AST node is also generated for each of them, so navigation on the UI is working fine. RecordsThis code produces no
This code produces 1
Note that an AST node is still generated for each of them regardless of definition, so navigation on the UI is working fine. FunctionsThis code produces 3
This code also produces 3
Note that an AST node is also generated for each declaration and definition as well, so navigation on the UI is working fine. This code produces 4
Interesting side note: When I select either of the This code produces 5
Again, an interesting side note here is that regardless of which declaration I select, the default values are not displayed on the Info Tree anyway, so it probably wouldn't matter if the multiple definitions of TemplatesA similar pattern can be observed with records and functions when making them into templates. Template recordsThe following code produces no
The following code produces 1
Furthermore, any distinct instantiations of
Similarly, having different names for template parameters has no effect. The code below still produces 1
And instantiating it produces another 3
An interesting side node is that the Info Tree displays A similar logic applies to having different defaults for the template parameters.
Template functionsThe following code produces 3
The following code also produces 3
Furthermore, just like with records, any distinct instantiation of
As expected, changing the name of the template parameter does not change the behavior, the code below still produces 4
And any distinct instantiations add further
An interesting side note is that whichever declaration of
Finally, a rather curious thing happens when we have different defaults for the template parameter.
I do not have a full explanation for why this happens. There might be more to this issue that has to do with the fact that certain re-declarations reside in different compilation units... |
Assumptions on correctnessIn
This is the piece of code responsible for skipping anything that only needs to happen for the definition of a record. (Which is also why for every struct, only one Assuming that this is the correct behavior - which is what I would advocate for at first glance anyway - we could add the same early-return check into VariablesThis code now produces no
For This code now produces only 1
For FunctionsThis code now produces no
Similarly to This code now produces 1
Similarly to This code now also produces 1
Interesting side note: The Parameters section (showing This code now also produces 1
A similar observation can be made here as with Template functionsThe following code now produces no
Info Tree behavior is same as with The following code now produces 1
Info Tree behavior is same as with
As expected, changing the name of the template parameter does not change the behavior, the code below still produces 1
And any distinct instantiations add further
Everything that could be said about the behavior of the Info Tree in the baseline case also applies here:
Finally, the "curious" case for when we have different defaults for the template parameter:
Database sizeApart from the behavioral changes listed above, eliminating duplicate definitions of variables and functions also affects the database size. I did a file size comparison using the SQLite database configuration for TinyXML and Xerces-C before and after applying the changes outlined at the beginning of this post. The results are as follows (sizes are given in bytes): TinyXML: Xerces-C: But perhaps more interesting is the comparison between the sizes of the CppVariable and CppFunction tables themselves (e.g. number of records) in these repositories: TinyXML:
Xerces-C:
Even though the redundancy is not as pronounced in overall database size as I would have expected, it is definitely significant in the size of the |
The above statistics were exported from my diagnostics branch created specifically for this purpose: Note: The changes on this branch are meant to serve diagnostic purposes of hypothetical scenarios only (i.e. what would happen to CodeCompass if...?). As expected, for the reasons already outlined in #714 (comment), these changes make certain unit tests fail, thus making the CI for the whole branch fail as well. The sample codes I used to analyze the CC database can be found at https://github.com/dbukki/cc-tests/tree/master/decl_def |
As @dbukki discovered in #714 (comment), multiple
CppFunction
entities are persisted for each function: one for each declaration and one for the definition.It should be examined whether these multiple entities are truly required or not. Key aspects to focus on during the examination:
CppFunction
entity for declarations, or maybe is it enough to store one for the definition? What will happen in such a case when a function does not have a definition, but only declaration? Would the Info Tree still be able to show the available information about the function?The text was updated successfully, but these errors were encountered: