[PATCH] Location and Range unittests for FriendDecl

Richard Smith richard at metafoo.co.uk
Tue Jun 24 09:04:28 PDT 2014


On Thu, Jun 12, 2014 at 4:54 PM, Nikola Smiljanić <popizdeh at gmail.com>
wrote:

> Turns out we didn't have correct location and range for class template
> friend. The same was true for case where friend is not the first token as
> in Richard's inline example.
>
> Manuel:
> Are my constructor/destructor matchers good?
>
> Richard:
> 1. What's the TypeSourceInfo case in FriendDecl::getSourceRange?
>

This is a C++11 feature:

struct A;
struct B {
  friend A; // note, not 'friend struct A;'
};

2. I couldn't find a way to hit the first call to FriendDecl::Create inside
> Sema::ActOnTemplatedFriendTag (some kind of explicit specialization case).


Should be:

template<typename> struct C {};
struct D {
  template<> friend struct C<int>;
};

(That's ill-formed, but our error recovery path treats it as if it didn't
have the 'template<>'.) If that doesn't hit that codepath, I think it may
be unreachable.


> I tried issuing a random diagnostic from there hoping it would break
> something in the test suite but it seems we don't have any coverage for
> this?
> http://reviews.llvm.org/D3906
>
> Files:
>   include/clang/AST/DeclFriend.h
>   include/clang/Sema/Sema.h
>   lib/Sema/SemaDecl.cpp
>   lib/Sema/SemaDeclCXX.cpp
>   lib/Sema/SemaTemplate.cpp
>   unittests/AST/SourceLocationTest.cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140624/33e43860/attachment.html>


More information about the cfe-commits mailing list