<div dir="ltr">I've just realized that you are talking about FunctionDecl and not FriendDecl, it all makes sense now, I'll make the change and rerun the tests.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Jul 17, 2014 at 11:02 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Wed, Jul 16, 2014 at 4:34 PM, Nikola Smiljanic <span dir="ltr"><<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FunctionDecl has the location for the 'friend' keyword and used it as a start location of the whole declaration but that doesn't seem to be right for the example you gave:<div>
<div><br></div><div><span style="color:rgb(0,0,0);font-family:Menlo,Consolas,Monaco,monospace;font-size:11px;line-height:16px;white-space:pre-wrap;background-color:rgb(255,255,255)">int inline friend f() { return 0; }</span><br>
</div><div><span style="color:rgb(0,0,0);font-family:Menlo,Consolas,Monaco,monospace;font-size:11px;line-height:16px;white-space:pre-wrap;background-color:rgb(255,255,255)"><br></span></div></div>If we do what you suggest this function declaration will start with 'friend' and that doesn't seem right, but then again it might be as the user is still able to get the NamedDecl from it... Do you want me to change the test as use DeclLoc for start even in this case?</div>
</blockquote><div><br></div></div><div>I just tested this: in the above case the start of the FunctionDecl is the 'int' keyword. If we move the 'friend' keyword to the front, then the start of the FunctionDecl is the 'friend' keyword. So it seems like the right thing to do is to take the start of the FunctionDecl as the start of the FriendDecl.</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 17, 2014 at 9:23 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Mon, Jun 30, 2014 at 10:52 PM, Nikola Smiljanić <span dir="ltr"><<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>================<br>
Comment at: include/clang/AST/DeclFriend.h:148<br>
@@ +147,3 @@<br>
+ SourceLocation DeclLoc = ND->getLocStart();<br>
+ return SourceRange(FriendLoc < DeclLoc ? FriendLoc : DeclLoc,<br>
+ ND->getLocEnd());<br>
----------------<br>
</div><div>Richard Smith wrote:<br>
> This use of `<` is not correct (it'll do the wrong thing in the presence of macro expansion). `SourceManager::isBeforeInTranslationUnit` is the right way, but it's hard to get at from here. What does a `friend` function declaration think its `LocStart` is? Does that include the `friend` token already? Maybe you can just use that.<br>
</div>This is very unfortunate but getStartLoc depends on the range, it's whatever beginning of the range is :(<br>
<br>
Note that we need this only for that contrived case of yours ;) where friend isn't the first token in the declaration. What's worse, having wrong range in that case or in the presence of macro expansion? Who uses macros anyway :P<br>
<br>
I tried this but friend keyword and start of NamedDecl point to same location. Could we already be wrong in this case?<br></blockquote><div><br></div></div></div><div>If the start of the `FunctionDecl` already points to the `friend` keyword, then we should be able to use `DeclLoc` in all cases.</div>
<div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
```<br>
#define DECL void f();<br>
struct A{<br>
friend DECL<br>
};<br>
```<br>
<br>
<a href="http://reviews.llvm.org/D3906" target="_blank">http://reviews.llvm.org/D3906</a><br>
<br>
<br>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div><br></div>