[PATCH] Offer typo suggestions for 'using'.

Luke Zarko zarko at google.com
Wed Jun 26 15:04:42 PDT 2013


Thanks for looking it over!

I've attached an updated patch with the indent fix (clang-format
wanted the extra two spaces for some reason) and tests for
IsTypeName/isa<TypeDecl> combinations. I moved the tests to
using-decl-1.cpp; they seemed more appropriate there.

It's unclear how to get into the IsInstantiation case, since the
callers of BuildUsingDeclaration always seem to pass in 0 for Scope
when they pass true for instantiation
(TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl,
TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl). Using
getScopeForContext(CurContext) to try and get at a Scope when I need
it for CorrectTypo returned null. UsingValidatorCCC's checks should be
logically equivalent to the checks subsequent in the source file.

On Wed, Jun 26, 2013 at 12:41 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Wed, Jun 26, 2013 at 12:35 PM, Luke Zarko <zarko at google.com> wrote:
>> I found a case where Clang doesn't yet help with typo correction:
>>
>> tests/base_using.cc:
>>
>> namespace Q { class AAA {}; }
>> using Q::AAB;
>>
>> Before:
>>
>> tests/base_using.cc:2:10: error: no member named 'AAB' in namespace 'Q'
>> using Q::AAB;
>>       ~~~^
>>
>> After:
>>
>> tests/base_using.cc:2:10: error: no member named 'AAB' in namespace
>> 'Q'; did you mean 'AAA'?
>> using Q::AAB;
>>       ~~~^
>> tests/base_using.cc:1:21: note: 'AAA' declared here
>> namespace Q { class AAA {}; }
>>                     ^
>
> Code change looks good, but could do with more test coverage for the
> type name / non-type-name / in instantiation cases.
>
> +        Diag(R.getNameLoc(), diag::err_no_member_suggest)
> +            << NameInfo.getName() << LookupContext << CorrectedQuotedStr
> +            << SS.getRange();
>
> We typically indent << only two spaces, not four (clang-format bug?).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: using-typo-v2.patch
Type: application/octet-stream
Size: 3465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130626/9e9d3692/attachment.obj>


More information about the cfe-commits mailing list