<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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 class="">================<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 class="">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>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><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><br></div></div>