Help me out with this bug

Hi, it has been more than a year I have reported bug 13699, since no progress
has been made I have setup a debugging version of clang, right now I’m digging
the sources and have inferred that

clang::Decl::setObjectOfFriendDecl DeclBase.h:887 called at
clang::TemplateDeclInstantiator::VisitClassTemplateDecl SemaTemplateInstantiateDecl.cpp:941

// TODO: do we want to track the instantiation progeny of this
// friend target decl?

later affects

ResultBuilder::isInterestingDecl SemaCodeComplete.cpp:496

// Friend declarations and declarations introduced due to friends are never
// added as results.
if (IDNS & (Decl::IDNS_OrdinaryFriend | Decl::IDNS_TagFriend))
return false;

Given this gist, executing

clang-hacking file.cpp 11 12

provides completion for the boost::shared_ptr class template but

clang-hacking file.cpp 12 12

will not. This happens because IDNS of the class template is changed because of
the parsing of the first declaration coming at line 11, such parsing ends up
instantiating the friend class template, and changing its IDNS. After this first
change, no more completions for such type happens.

On 13699 there’re two small patterns that bring this issue up. Also, as such
patterns are not very uncommon, it affects for-range loops over libc++
containers, boost classes and annoys some programmers.

This is all on revision 202241.

I’m still not a clang developer (still not), all I know comes from this
debugging session, so I think there can be more wise patches than mine now.

Francisco Lopes

The core issue aside, one of the shortcomings of our tracker is that llvmbugs@ is only emailed on status changes. If you update a bug with new information months after filing it, nobody gets notified unless they are on the cc list. Often what happens is users end up talking to themselves if the code owner doesn’t actively cc themself on the bug. I don’t think everyone on llvmbugs wants mail on every bug update, but the current situation isn’t good.