[cfe-commits] r147962 - in /cfe/trunk: include/clang/Sema/Sema.h include/clang/Sema/TypoCorrection.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaLookup.cpp test/SemaCXX/typo-correction.cpp

Kaelyn Uhrain rikka at google.com
Wed Jan 11 12:50:23 PST 2012


On Wed, Jan 11, 2012 at 11:49 AM, Chandler Carruth <chandlerc at gmail.com>wrote:

> A few comments inline...
>
> On Wed, Jan 11, 2012 at 11:37 AM, Kaelyn Uhrain <rikka at google.com> wrote:
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=147962&r1=147961&r2=147962&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 11 13:37:46 2012
>> @@ -1745,6 +1745,30 @@
>>                              EllipsisLoc);
>>  }
>>
>> +namespace {
>> +
>> +// Callback to only accept typo corrections that are namespaces.
>>
>
> I think this comment was cut/pasted from the other callback.
>

Whoops! Yes, it was.


>
> Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=147962&r1=147961&r2=147962&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/typo-correction.cpp Wed Jan 11 13:37:46 2012
>> @@ -29,3 +29,14 @@
>>  inline error_condition make_error_condition(errc _e) {
>>   return error_condition(static_cast<int>(_e));
>>  }
>> +
>> +
>> +// Prior to the introduction of a callback object to further filter
>> possible
>> +// typo corrections, this example would not trigger a suggestion as
>> "base_type"
>> +// is a closer match to "basetype" than is "BaseType" but "base_type"
>> does not
>> +// refer to a base class or non-static data member.
>> +struct BaseType { };
>> +struct Derived : public BaseType { // expected-note {{base class
>> 'BaseType' specified here}}
>> +  static int base_type;
>> +  Derived() : basetype() {} // expected-error{{initializer 'basetype'
>> does not name a non-static data member or base class; did you mean the base
>> class 'BaseType'?}}
>> +};
>
>
> It would be good to try to add similar examples for the other two code
> paths you switched to the callback mechanism.
>

The code path in SemaLookup that uses the callback mechanism is emulating
the functionality of CorrectTypoContext within the old version of
CorrectTypo, so shouldn't change any behavior.

I started to add an example for the other code path in SemaDeclCXX.cpp, but
discovered that (as far as I could tell) there isn't any change in behavior
from the switch as CorrectTypo is also being passed LookupNamespaceName for
the Sema::LookupNameKind--meaning CorrectTypo only receives namespace
identifiers from the LookupVisibleDecls helper function. Looking again at
the code in CorrectTypo just now, I think it *might* be possible to slip in
a correction candidate which LookupVisibleDecls won't return when requested
to only look up namespace names... by having the same namespace typo for
something that isn't a namespace. If that works, I'll commit the example
along with the comment fix.

Cheers,
Kaelyn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120111/35825662/attachment.html>


More information about the cfe-commits mailing list