[PATCH] D131858: [clang] Track the templated entity in type substitution.

Evgeny Eltsin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 21 23:19:42 PDT 2022


eaeltsin added a comment.

Heads-up - I'm seeing the compilation failure that reduces to this commit. I didn't get a reproducer of the reasonable size yet :(

The problem occurs when using modules only.

The module has code like:

  template <typename T>
  class A {
   public:
    T x;
    template <typename H>
    friend H Helper(H h, const A& a) {
      return H::foo(std::move(h), a.x);
    }
  };

Then, when the module client uses `Helper`, we get an error:

  header.h:46:12: error: inline function 'Helper<B>' is not defined [-Werror,-Wundefined-inline]

If I move `Helper` definition out of friend declaration:

  template <typename T>
  class A {
   public:
    T x;
    template <typename H>
    friend H Helper(H h, const A& a);
  };
  
  template <typename H, typename T>
  H Helper(H h, const A<T>& a) {
    return H::foo(std::move(h), a.x);
  }

things compile ok.

Without modules, both versions compile ok.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131858/new/

https://reviews.llvm.org/D131858



More information about the cfe-commits mailing list