From cfe-dev Mon May 04 00:47:12 2015 From: Dimitar Dobrev Date: Mon, 04 May 2015 00:47:12 +0000 To: cfe-dev Subject: Re: [cfe-dev] Incorrect location of a friend declaration Message-Id: <1447821873.734602.1430700432550.JavaMail.yahoo () mail ! yahoo ! com> X-MARC-Message: https://marc.info/?l=cfe-dev&m=143070073923776 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============4719232043622229977==" --===============4719232043622229977== Content-Type: multipart/alternative; boundary="----=_Part_734601_1669316359.1430700432541" ------=_Part_734601_1669316359.1430700432541 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =C2=A0=C2=A0=C2=A0 Through testing I found out that Clang considers the ent= ity at line 11 a function redeclaration so I am able to get the correct lin= e number by iterating through redeclarations. I guess it's not a bug after = all.=20 On Monday, May 4, 2015 3:36 AM, Nikola Smiljanic = wrote: =20 If I understand correctly you think that FunctionDecl at line 8 should poi= nt to line 11? That doesn't seem right, what you have at line 8 really is a= function declaration. What you have at line 11 is the definition of previo= usly declared function. On Mon, May 4, 2015 at 12:49 AM, Dimitar Dobrev wrote= : =C2=A0=C2=A0=C2=A0 Hi all, =C2=A0=C2=A0=C2=A0 I have the following header: =C2=A0=C2=A0=C2=A0=C2=A0class Class1 =C2=A0=C2=A0=C2=A0=C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0}; =C2=A0=C2=A0=C2=A0=C2=A0class Class2 =C2=A0=C2=A0=C2=A0=C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0public: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0friend inline const Class1 opera= tor+(const Class1& f1, const Class1& f2); =C2=A0=C2=A0=C2=A0=C2=A0}; =C2=A0=C2=A0=C2=A0=C2=A0inline const Class1 operator+(const Class1& f1, con= st Class1& f2) =C2=A0=C2=A0=C2=A0=C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0return Class1(); =C2=A0=C2=A0=C2=A0=C2=A0} =C2=A0=C2=A0=C2=A0=C2=A0Decl::getLocation() returns line 8 for the friend -= that's correct. But it returns 8 for the friend declaration, that is, the = function itself, too, while the function is actually located at line 11. If= the friend is deleted, then the correct location is reported. =C2=A0=C2=A0=C2=A0 I think it's a bug so I filed it at https://llvm.org/bug= s/show_bug.cgi?id=3D23401 . But I may me wrong so I'd appreciate your opini= on. =C2=A0=C2=A0=C2=A0 Dimitar Dobrev =C2=A0 _______________________________________________ cfe-dev mailing list cfe-dev@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev ------=_Part_734601_1669316359.1430700432541 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

    Through testing I found out that = Clang considers the entity at line 11 a function redeclaration so I am able= to get the correct line number by iterating through redeclarations. I gues= s it's not a bug after all.

=

------=_Part_734601_1669316359.1430700432541-- --===============4719232043622229977== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ cfe-dev mailing list cfe-dev@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev --===============4719232043622229977==--