[PATCH] D28399: PR31469: Don't add friend template class decls to redecl chain in dependent contexts.

Kim Gräsman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 6 09:41:45 PST 2017


kimgr added a comment.

I think we're seeing similar new behavior in IWYU, I've been meaning to bring it up on cfe-dev. But since it might be relevant here, I'll add our observations.

To us, it looks like friends in templates form their own redecl chain. An example:

  // template.h
  void foo();
  
  template<class T>
  struct Template {
    friend void foo();
  };
  
  // foo.h
  inline void foo() {
  }
  
  // main.cpp
  #include "template.h"
  #include "foo.h"
  
  Template<int> i;
  
  int main() {
    foo();  // attributed to Template<T>::foo
  }

This behavior changed in r283207.

We never got to the bottom of whether the redecl shuffling is correct or not, so we decided to just work around it, our code here:
https://github.com/include-what-you-use/include-what-you-use/blob/master/iwyu_ast_util.cc#L842

Relevant to this patch, I wonder if you're also about to work around a more central problem?


Repository:
  rL LLVM

https://reviews.llvm.org/D28399





More information about the cfe-commits mailing list