-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
Reference collapsing works wrong #50
Comments
Hello, thank for reporting that. The collapsing is sometimes a problem with the goal to get compiling code. I need to have a deep look into this case and check to not break others. |
I've made some investigation on the following snippet:
When insights processes a template instantiation it eventually calls
Actually, at this point
Simplified call graph looks like:
So, clang itself produces 2 ampersands for lvalues. Looks like a bug in clang for me, but 'm not sure. P.S.: tested on llvm-6.0.1 |
Hello adromanov, thanks for nailing it down. It sure looks like a bug in clang. And I agree, it can be workaround in insights. I already have an idea, but this issue did draw my attention more to templates. Currently I'm looking into more than just this issue. There are a couple of other things which are incorrect. As soon as I have all together I will push a (temporary) fix. |
I'll try to report in a couple of days. |
To fix #50 it is important to start ensuring that template code is valid and does not change. Hence all compiling code does define INSIGHTS_USE_TEMPLATE to enable compilation of the transformed template code.
It looks like clang does handle l-value references in the AST dump wrong. It adds a second ampersand which makes it an r-value reference. As #50 points out this second ampersand leads to invalid code. The workaround implemented here does a simple (but expensive) string search in case of an l-value ref and simply replaces the && with just &.
Fix #50: Remove second and invalid ampersand for an l-value ref.
That workaround doesn't work with:
Top level && should be replaced with &, not the first one. This is tricky when we have only string representation of a type. |
Thanks! I'm curious what they say. I will revert the not so well working patch. |
Please, remove double ampersand hack from
Thanks! |
Hello adromanov, I just reverted the hack. However, I could not confirm that it is fixed in my clang 7.0.0 version. That could be as it is a couple days if not weeks old. Also it will not show up in the web-frontend as Travis CI does not support the new llvm 7 repository yet. At least not easily. |
I've built a fresh 7.0.0 yesterday (tags/RELEASE_700/final) - it works for me. |
Ok now I see it as well. The next problem is static linking such that I can use it for the web frontend. Thanks for keeping an eye on that issue! |
Hello adromanov, I finally updated to Clang 7.0. As far as I can see this issue is be solved now. |
For the following piece of code:
output of an instantiation of
foo
is the following:Argument type should be
Test &
but notTest &&
because of reference collapsing.The text was updated successfully, but these errors were encountered: