[cfe-dev] Incorrect location of a friend declaration

Dimitar Dobrev dpldobrev at yahoo.com
Sun May 3 17:47:12 PDT 2015


    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 guess it's not a bug after all. 


     On Monday, May 4, 2015 3:36 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
   

 If I understand correctly you think that FunctionDecl at line 8 should point 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 previously declared function.
On Mon, May 4, 2015 at 12:49 AM, Dimitar Dobrev <dpldobrev at yahoo.com> wrote:


    Hi all,
    I have the following header:


    class Class1
    {
    };

    class Class2
    {
    public:
        friend inline const Class1 operator+(const Class1& f1, const Class1& f2);
    };

    inline const Class1 operator+(const Class1& f1, const Class1& f2)
    {
        return Class1();
    }


    Decl::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.
    I think it's a bug so I filed it at https://llvm.org/bugs/show_bug.cgi?id=23401 . But I may me wrong so I'd appreciate your opinion.

    Dimitar Dobrev
 
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150504/8e1c5b4e/attachment.html>


More information about the cfe-dev mailing list