r209511 - PR19352 - getLocation() points to the wrong position for FriendDecls

Abramo Bagnara abramo.bagnara at bugseng.com
Fri Aug 29 08:47:23 PDT 2014


Il 29/08/2014 17:34, Abramo Bagnara ha scritto:
> Il 23/05/2014 14:48, Nikola Smiljanic ha scritto:
>> Author: nikola
>> Date: Fri May 23 07:48:27 2014
>> New Revision: 209511
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=209511&view=rev
>> Log:
>> PR19352 - getLocation() points to the wrong position for FriendDecls
>>
>> Modified:
>>     cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=209511&r1=209510&r2=209511&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri May 23 07:48:27 2014
>> @@ -11425,7 +11425,9 @@ FriendDecl *Sema::CheckFriendTypeDecl(So
>>    //   If the type specifier in a friend declaration designates a (possibly
>>    //   cv-qualified) class type, that class is declared as a friend; otherwise,
>>    //   the friend declaration is ignored.
>> -  return FriendDecl::Create(Context, CurContext, LocStart, TSInfo, FriendLoc);
>> +  return FriendDecl::Create(Context, CurContext,
>> +                            TSInfo->getTypeLoc().getLocStart(), TSInfo,
>> +                            FriendLoc);
>>  }
> 
> This seems wrong to me.
> 
> Did you mean to write getLocEnd() instead? (Under the assumption that
> identifier should comes last in class type)
> 

It is useful to know that currently for:

template <class U> class C {
  template<class T> friend struct A<T>::B;
};

getLocation() for the FriendDecl in the C template is on `B' (correctly)

getLocation() for the FriendDecl in the C instantiations is on `struct'
(incorrectly)

As a side note it might be useful to remark that also FriendDecl source
range changes from C template (where it is from `template' to `B') to C
instantiations (where it is from `friend' to `B').


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-commits mailing list