[patch] DeclarationNameInfo::getEndLoc

Hi all,

I'm writing a clang tool which needs to find the end location for a
BinaryOperator. Unfortunately, it turns out that DeclarationName
doesn't properly report its end position. Here's a short example:

#include <stdlib.h>

int a = 0, b = 1;

int foo()
    int c;
    c = a == b;
    return c;

If you run clang-check on it, you get:

    >-BinaryOperator 0x150b5c0 <line:8:5, col:14> 'int' '='
    > >-DeclRefExpr 0x150b4f0 <col:5> 'int' lvalue Var 0x150b480 'c' 'int'
    > `-BinaryOperator 0x150b598 <col:9, col:14> 'int' '=='
    > >-ImplicitCastExpr 0x150b568 <col:9> 'int' <LValueToRValue>
    > > `-DeclRefExpr 0x150b518 <col:9> 'int' lvalue Var 0x150a200 'a' 'int'
    > `-ImplicitCastExpr 0x150b580 <col:14> 'int' <LValueToRValue>
    > `-DeclRefExpr 0x150b540 <col:14> 'int' lvalue Var 0x150b2f0 'b' 'int'

I've fixed that column-number problem in the attached patch. The new output is:

    >-BinaryOperator 0x3d58500 <line:8:5, col:15> 'int' '='
    > >-DeclRefExpr 0x3d58430 <col:5, col:6> 'int' lvalue Var
0x3d583c0 'c' 'int'
    > `-BinaryOperator 0x3d584d8 <col:9, col:15> 'int' '=='
    > >-ImplicitCastExpr 0x3d584a8 <col:9, col:10> 'int' <LValueToRValue>
    > > `-DeclRefExpr 0x3d58458 <col:9, col:10> 'int' lvalue Var
0x3d581a0 'a' 'int'
    > `-ImplicitCastExpr 0x3d584c0 <col:14, col:15> 'int' <LValueToRValue>
    > `-DeclRefExpr 0x3d58480 <col:14, col:15> 'int' lvalue Var
0x3d58230 'b' 'int'

The end column of the root BinaryOperator is correct in the fixed output.

The patch works for me. It would be great if someone could review &
commit. Thanks.


decl-name-end-loc.patch (539 Bytes)