-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SymbolExternalizer needs a complete rewrite #29
Comments
Commit 625e4af addresses 2 and 3. The issue addressed by 1 was fixed when the IntervalTree was introduced. Now with regard to the last comment, here is a brain dump of my ideas with regard to how to do it. Clang-extract is able to rename the symbols we are externalizing, e.g.
The resulting code would be:
Notice the following here: the declaration of With this cleared, we can construct even more complex cases by introducing
In this case, the first use of Now, let's say we moved the declaration of the externalized variable just before its first use in this case. The resulting code would be:
Here, it is not necessary to expand Now, a way to implement this would be to first account the This problem can be solved efficiently by using the IntervalTree, or not-so-efficiently by doing a linear search on the Now, if we do not want to do the same thing with the declaration that contains the use of that externalized variable (that means, try to postpone its declaration as well) then we know that the file that contains the function that uses the externalized variable is expanded, else the change would have been lost. So we go there just before the declaration and write the externalized variable there. One thing that may be of a concern are Macros. Clang-extract often get confused when the declaration comes as a result of a macro, so if the first use of the function comes as a result of a macro expansion, perhaps it would be a good idea to abort this optimization attempt then. You can detect this because the Declaration will have all sort of weirdness in the SouceRange, but the most common one is the result of Since we at this point we are not trying to postpone the declaration that Uses the externalized symbol, we do not need to use the IncludeTree here, and the optimization code should be reduced quite a lot when compared to the general case. |
Commit 74a63c6 implements the last item. |
The SymbolExternalizer engine needs a complete rewrite so we can do proper optimizations related to clang-extract's execution speed and code size.
With regard to speed:
With regard to code size:
The same features is currently have must be kept. We should also think of ways of implementing #5.
The text was updated successfully, but these errors were encountered: