[cfe-dev] [patch] Fix source range of CXXNewExprs
Nico Weber
thakis at chromium.org
Thu Nov 18 01:25:38 PST 2010
On Thu, Nov 18, 2010 at 2:00 AM, John McCall <rjmccall at apple.com> wrote:
>
> On Nov 17, 2010, at 4:49 PM, Nico Weber wrote:
>
>> On Thu, Nov 18, 2010 at 12:36 AM, John McCall <rjmccall at apple.com> wrote:
>>>
>>> On Nov 17, 2010, at 3:35 PM, Nico Weber wrote:
>>>
>>>> On Thu, Nov 18, 2010 at 12:29 AM, John McCall <rjmccall at apple.com> wrote:
>>>>>
>>>>> On Nov 17, 2010, at 3:22 PM, Nico Weber wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> the attached patch fixes the source range on CXXNewExprs. For code like
>>>>>>
>>>>>> foo:A* a = new foo::A;
>>>>>>
>>>>>> the CXXNewExpr's source range's end would point to `foo` instead of
>>>>>> `A`. This was because Sema::BuildCXXNew() uses the allocated type's
>>>>>> TypeLoc's source range's end as end location for CXXNewExpr if no
>>>>>> parens are present (new foo::A() is handled correctly already), and
>>>>>> TypeSpecTypeLoc has only a start location.
>>>>>
>>>>> This should be an ElaboratedTypeLoc. If it isn't, that's the bug, not changing
>>>>> TypeSpecTypeLoc.
>>>>
>>>> It is an ElaboratedTypeLoc, but TypeLoc::getEndLoc() skips the
>>>> ElaboratedTypeLoc's position and moves on the next loc:
>>>
>>> Ah. So the problem is that the TypeSpecTypeLoc's location should be
>>> the location of the qualified identifier, not the location of the start of the
>>> qualification.
>>
>> Like this? If so, I guess the other calls to SetTypeSpecType() where a
>> annot_typename is parsed need this change, too?
>
> On SemaType.cpp:1561, try changing
> if (Keyword == ETK_Typename) {
> to
> if (DS.getTypeSpecType() == TST_typename)
That doesn't seem to help.
Nico
More information about the cfe-dev
mailing list