[cfe-commits] Patch: Change how struct/class mismatches are handled

Richard Trieu rtrieu at google.com
Thu Jun 9 20:21:28 PDT 2011


Submitted at revision 132831 with camelCase.

On Thu, Jun 9, 2011 at 4:47 PM, Douglas Gregor <dgregor at apple.com> wrote:

> This looks good to me, although I'd prefer if previous_mismatch were in
> camelCase. Otherwise, please commit. Thanks!
>
> Sent from my iPhone
>
> On Jun 8, 2011, at 2:13 PM, Richard Trieu <rtrieu at google.com> wrote:
>
> On Tue, Jun 7, 2011 at 2:18 PM, Richard Trieu < <rtrieu at google.com>
> rtrieu at google.com> wrote:
>
>>
>>
>> On Wed, Jun 1, 2011 at 4:33 PM, Douglas Gregor < <dgregor at apple.com>
>> dgregor at apple.com> wrote:
>>
>>>
>>> On May 29, 2011, at 1:51 PM, Richard Trieu wrote:
>>>
>>> Made changes to how 'struct'/'class' mismatches are handled.
>>> - Removed fix-it hints from template instaniations since changes to the
>>> templates are rarely helpful.
>>> - Changed the caret in template instaniations from the class/struct name to the
>>> class/struct keyword, matching the other warnings.
>>> - Do not offer fix-it hints when multiple declarations disagree.  Warnings are
>>> still given.
>>> - Once a definition is found, offer a fix-it hint to all previous declarations
>>> with wrong tag.
>>> - Declarations that disagree with a previous definition will get a fix-it hint
>>> to change the declaration.
>>>
>>> I think this is great. I have one question:
>>>
>>> +    if (isTemplate) {
>>> +      Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
>>> +        << (NewTag == TTK_Class)
>>> +        << isTemplate << &Name
>>> +        << FixItHint::CreateReplacement(SourceRange(NewTagLoc),
>>> +                                        OldTag == TTK_Class ?
>>> +                                        "class" : "struct");
>>> +      Diag(Previous->getLocation(), diag::note_previous_use);
>>> +      return true;
>>> +    }
>>>
>>> Why do we bail out early for templates, rather than treating them the
>>> same way as non-templates?
>>>
>>> - Doug
>>>
>>>  Not really.  I thought there was some issue with it earlier, but can't
>> remember what it is now.  I'll test it out and see if there's any problems.
>
>
> Made the following changes:
> Templates and non-templates are now treated the same.
> Added FileCheck to the test case.
> Fixed issue so that definitions now check all previous declarations for
> mismatches.
>
> <struct-class-mismatch2.patch>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110609/05edcbf3/attachment.html>


More information about the cfe-commits mailing list