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
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.
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.
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.
Exactly, I’ve closed the bug.