Any other interesting scenarios to test while am at it?
Diff Detail
Event Timeline
This looks like a positive step, so LG.
(I assume you have checked that at least of them fails without your patch ;)
Richard might have more ideas for corner cases (he's a master of corner cases)
Committed these tests in r210306 but I'll leave this review request open in case the following code produces something in the next week or so :)
richard_smith_engine e(beer()); // not sure if this is a proper way to seed the engine obscure_frienddecl_distribution d(e); d();
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:
- What's the TypeSourceInfo case in FriendDecl::getSourceRange?
- I couldn't find a way to hit the first call to FriendDecl::Create inside Sema::ActOnTemplatedFriendTag (some kind of explicit specialization case). 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?
One comment, the rest looks fine.
include/clang/AST/DeclFriend.h | ||
---|---|---|
148 ↗ | (On Diff #10374) | 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. |
include/clang/AST/DeclFriend.h | ||
---|---|---|
148 ↗ | (On Diff #10374) | 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? #define DECL void f(); struct A{ friend DECL }; |