On Mon, Jun 30, 2014 at 10:52 PM, Nikola Smiljanić <popiz...@gmail.com>
wrote:

> ================
> Comment at: include/clang/AST/DeclFriend.h:148
> @@ +147,3 @@
> +      SourceLocation DeclLoc = ND->getLocStart();
> +      return SourceRange(FriendLoc < DeclLoc ? FriendLoc : DeclLoc,
> +                         ND->getLocEnd());
> ----------------
> Richard Smith wrote:
> > 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.
> This is very unfortunate but getStartLoc depends on the range, it's
> whatever beginning of the range is :(
>
> 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
>
> I tried this but friend keyword and start of NamedDecl point to same
> location. Could we already be wrong in this case?
>

If the start of the `FunctionDecl` already points to the `friend` keyword,
then we should be able to use `DeclLoc` in all cases.


>
> ```
> #define DECL void f();
> struct A{
>   friend DECL
> };
> ```
>
> http://reviews.llvm.org/D3906
>
>
>
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to