[PATCH v3 4/9] Have TypoCorrectionConsumer remember the TypoCorrections it returned.

Kaelyn Takata rikka at google.com
Fri Jul 25 14:39:27 PDT 2014


On Fri, Jul 25, 2014 at 2:01 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> +  TypoCorrection &getNextCorrection();
> +
> +  /// \brief Get the last correction returned by getNextCorrection().
> +  TypoCorrection &getCurrentCorrection() {
>
> Since the TypoCorrections are now intended to be reused, it would seem
> wise to return them either by value or by const reference.
>

They originally were returned by value, but there is a case where the set
of decls associated with the TypoCorrection needs to be modified for the
proper diagnostics to be emitted: specifically by the overload resolution
in the MemberExprTypoRecovery callback introduced in patch #9. Making the
return value be a non-const reference had been a separate patch that I
folded into the others to avoid unnecessary churn. I agree it would be
nicer to return them by value or const reference, but doing so greatly
complicates the recovery callback's ability to select the right method from
a group of methods with the same name in a way that will be visible to
TransformTypos::Transform when it comes time to emit diagnostics
(particularly without introducing any additional AST<->Sema layering
violations).


> On Mon, Jul 14, 2014 at 4:55 PM, Kaelyn Takata <rikka at google.com> wrote:
>
>>
>> Two additional methods are provided: one to return the current
>> correction (the last correction returned by getNextCorrection), and one
>> to "reset" the state so that getNextCorrection will return the previous
>> corrections before returning any new corrections.
>>
>> Also ensure that all TypoCorrections have valid source ranges.
>> ---
>>  include/clang/Sema/SemaInternal.h   | 31 ++++++++++++++++++++++++++-----
>>  include/clang/Sema/TypoCorrection.h |  2 +-
>>  lib/Sema/SemaLookup.cpp             | 16 ++++++++++++----
>>  3 files changed, 39 insertions(+), 10 deletions(-)
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140725/bcf59621/attachment.html>


More information about the cfe-commits mailing list