[cfe-dev] [patch] Fix source range of CXXNewExprs
Nico Weber
thakis at chromium.org
Wed Nov 17 16:49:52 PST 2010
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?
Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sourceranges2.patch
Type: application/octet-stream
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101118/2b9149da/attachment.obj>
More information about the cfe-dev
mailing list