<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/78173>78173</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            static function used in template function in C++-20 module not found
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ZhalgasFromMSU
      </td>
    </tr>
</table>

<pre>
    Hi!

NB:
Here is a sample project, depicting the problem: https://godbolt.org/z/neo8M8orM

Imagine, that I have a `static inline` function `foo_header`, defined in some header:
```c++
// header.hpp
#pragma once

static inline int foo_header(int x) {
    return x;
}
```
And this function is used in a template function `foo_module` in some module:
```c++
// module.cpp
module;
#include "header.hpp"

export module Mod;

export template<typename T>
T foo_module(T x) {
    return foo_header(x);
}
```
Now I want to use latter in my `main.cpp`:
```c++
// main.cpp
import Mod;

int main() {
 int x = foo_module(5);
    return 0;
}
```

However, clang **falsely** claims, that there is no matching function `foo_header`:
```
In file included from /app/main.cpp:1:
module.cpp:9:12: error: no matching function for call to 'foo_header'
    9 |     return foo_header(x);
      | ^~~~~~~~~~
main.cpp:4:13: note: in instantiation of function template specialization 'foo_module<int>' requested here
    4 |     int x = foo_module(5);
      |             ^
1 error generated.
```

Here are some observation, based on which, I make an assumption that this is a clang bug:
1) This code compiles/works properly on trunk of gcc
2) This code compiles/works properly if I explicitly cast template parameter `T` to `int` like this:
```c++
// module.cpp
export template<typename T>
T foo_module(T x) {
 return foo_header(static_cast<int>(x));
}
```
3) This code compiles/works properly if I remove keyword `static` from `foo_header` function declaration

Based on those observations, I could assume that body of `foo_module` template function gets compiled in different translation unit, from where header was included, and therefore `static` specifier on `foo_header` hides this function
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk1z2zgS_TXQpSsqCtTnQQfZjio-OJf1XvaSAokmiTUIcAHQsnLY3z7VAClRcTLx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