GNU bug report logs -
#57318
29.0.50; c++-mode: Functions are shown as variables: partial template specialization
Previous Next
Reported by: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
Date: Sun, 21 Aug 2022 13:28:02 UTC
Severity: normal
Found in version 29.0.50
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hello Alan,
Alan Mackenzie <acm <at> muc.de> writes:
> Hello, Naofumi.
>
> Thank you indeed for your bug report, and thanks even more for
> diagnosing the cause and writing a patch!
>
> I'm truly astounded that you managed to debug this problem, hidden as it
> was in the fontification parts of CC Mode, which are difficult to run
> with the debugger. Respect!
>
Thank you, I'm glad to hear that.
> Looking at your patch, I can see one or two problems with it. The main
> one is that after encountering a template opener "<", I'm a bit worried
> about the accuracy of checking for the matching ">".
>
> Looking further into the problem, it seems the misfontification bug was
> triggered by the commas in the template expressions. When there's a
> comma there, the (c-forward-<>-arglist ...) call (which "; Should always
> work") fails. This failure is caused by the dynamic binding of
> c-restricted-<>-arglists to t.
>
> When this dynamic binding is instead at nil (rather than t), the
> fontification works properly, with functions fontified as functions.
> The reason for this faulty binding was fixing a bug report where
> scrolling a buffer containing lots of templates was very slow. Binding
> c-restricted-<>-arglists to t "solved" that slowness.
>
Indeed. I confirmed that avoiding (c-restricted-<>-arglists t) binding
solves this misfontification problem at least, but it makes scrolling
terribly slow...
> That slowness had been caused by inefficient scanning of the template
> structures. I've now identified and implemented an alternative
> optimisation, which doesn't cause problems with commas in templates.
>
[..snip..]
> Can I ask you, please, to apply and test my proposed patch, which I
> enclose below. Would you please test it on your real C++ source code,
> and either confirm it really works, or say what's still faulty about it.
> If there are any problems with applying the patch, feel free to send me
> personal email.
>
I've applied your patch. It works well and solves misfontification
problem. At the same time, I've not seen any noticeable performance
degradation by this patch so far. Great.
attachment: fix_c-restricted--arglists_verification.png
I came across this problem when I tried to compare the current
tree-sitter's fontification quality and performance with familiar
cc-mode by using very-fast flat_hash_map code [1][2]. Now problematic
fontification has gone.
> So I must apologize that I won't be using your patch, but I thoroughly
> appreciate the time you must have spent debugging the problem.
>
That's just fine with me. I don't mind at all because I'm not an
expert. Fixing the root cause should be done.
Best regards,
Naofumi
[1] https://github.com/skarupke/flat_hash_map/blob/master/flat_hash_map.hpp
[2] https://probablydance.com/2017/02/26/i-wrote-the-fastest-hashtable/
[fix_c-restricted--arglists_verification.png (image/png, attachment)]
This bug report was last modified 2 years and 320 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.