[cfe-commits] [PATCH] Add callback object to Sema::CorrectTypo

Kaelyn Uhrain rikka at google.com
Tue Jan 10 17:06:48 PST 2012

This patch is a rough draft of my attempt to replace the
Sema::CorrectTypoContext enum with a callback object for performing finer
grained validation of potential typo corrections. This version just
includes a wrapper for Sema::CorrectTypo to translate a CorrectTypoContext
value into a corresponding callback object. The idea is to give CorrectTypo
a way to filter potential corrections with more accuracy by being able to
take into account e.g. what kinds of decls are allowed/expected, instead of
giving a very rough guide on what corrections are acceptable
(CorrectTypoContext values mainly affect which keywords should be added to
the set of possible corrections; the exceptions are
that CTC_ObjCMessageReceiver would give precedence to the "super" keyword
over other corrections with the same edit distance, and CTC_ObjCIvarLookup
would trigger ObjC ivar lookup before other forms of lookup when looking up
potential typo correction identifiers).

I'll be surprised if the interface of the callback class doesn't expand or
improve as I fix up callers of CorrectTypo to use callback objects
directly. I also hope to entirely remove or at least come up with a cleaner
solution than the flags in the callback class that control which keywords
are added to the candidate pool. I'm sending this initial patch to start
gathering feedback on the approach while fixing up the CorrectTypo callers,
as those changes will most likely dwarf the changes that add the callback
infrastructure to CorrectTypo. As such, I'm fine with either submitting
this patch or holding off until the conversion is further along.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120110/acc69b1e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typo-correction-callback.diff
Type: text/x-patch
Size: 15269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120110/acc69b1e/attachment.bin>

More information about the cfe-commits mailing list