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

    <tr>
        <th>Summary</th>
        <td>
            [clang] ODR violation with header modules and template conversion operator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          emaxx-google
      </td>
    </tr>
</table>

<pre>
    Reproducer:

```c++
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: cd %t
//
// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=//small \
// RUN:     -fmodule-map-file=module-small.cppmap -xc++ module-small.cppmap -emit-module -o module-small.pcm
// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=//large \
// RUN: -fmodule-map-file=module-large.cppmap -xc++ module-large.cppmap -emit-module -o module-large.pcm
// RUN: %clang_cc1 -fmodules -fno-implicit-modules \
// RUN:     -fmodule-map-file=module-small.cppmap -fmodule-map-file=module-large.cppmap \
// RUN: -fmodule-file=module-small.pcm -fmodule-file=module-large.pcm -xc++ \
// RUN:     main.cc

//--- class-with-operator.h
#ifndef CLASS_WITH_OPERATOR_H
#define CLASS_WITH_OPERATOR_H

#include "func.h"

class Foo {
  template <class T>
  operator decltype(func<T>()) () {}
};

#endif

//--- func.h
#ifndef FUNC_H
#define FUNC_H

template <class T>
T func();

#endif

//--- main.cc
#include "class-with-operator.h"

//--- module-large.cppmap
module "//large" {
header "module-large.h"
}

//--- module-large.h
#include "unrelated-alias.h"
#include "class-with-operator.h"

//--- module-small.cppmap
module "//small" {
header "module-small.h"
}

//--- module-small.h
#include "class-with-operator.h"

//--- unrelated-alias.h
#ifndef UNRELATED_ALIAS_H
#define UNRELATED_ALIAS_H

#include "func.h"

template <class UnrelatedT>
using UnrelatedAlias = decltype(func<UnrelatedT>())();

#endif
```

This currently causes a compilation error:

```
In module '//small':
./class-with-operator.h:8:3: error: 'Foo' with definition in module '//small' has different definitions in different modules; first difference is this function template
    7 | template <class T>
      |   ~~~~~~~~~~~~~~~~~~
    8 |   operator decltype(func<T>()) () {}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./class-with-operator.h:8:3: note: but in '//large' found different function template
    7 |   template <class T>
 |   ~~~~~~~~~~~~~~~~~~
    8 |   operator decltype(func<T>()) () {}
 |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0Vk1vqzoT_jXOZkRETAjJggVNGp1KVfsqTfUuK8eY4HsNRrbJbTf3t1_ZQD4KSatTHYSUiHnm43k8M0C05vuSsRiFdyhcjUhtcqliVpD3d28v5V6w0U6mH_GGVUqmNWUKBQny3T3zm5sifGdvP0F4jfAaNq9PKEhAFeCpDBAOTc9W_J1yNWzSleDGy7hg1q4vQT00Tb8AIBxSQcr9G6UT8LJCprVgGryslB4vKsEpN97pafPPK0nBULBqQumCCAEoXPaC2-voU5DKlY2CVfvEOY5pVRWkAu-9FQoGraw41gGevMRUtPgTvARRezbI6wYn53SV06V1mFOD-TGnH5_HNzne1GcofkWLa4Aj9TPlrvEoCC_HlLbD5sye5wEVRGvvH25yT1ZMESPVOHeIgGdlyjJYPiYvL2__f9j-env-3_0m2T5v3n41iJRlvGTXEU2Ykoo6tdOHs7qk4xxh3BhdblhLCSiy8w5gWFEJYhigYNlYtyi4d6auOkgZFeajYgjPbTwULB0GzxFeILyA5p8LGa1somiFgrtjOaxMefZZhbawc9rr16flJ56nR35ytdKtC9aW81Xes0O5EGr4VDrdzvz7DYb8pB0Riz8NJsK4lTlnJGV2W-IL9y5-I9rVLHmv2LpUzEqRekRwoo-BfsLofLQGGDnzDUaN-5eMOtjvFttnft5Br0-b-8dke796Sx4fkpdPzTRo_WJg-k332lXQdl-tebk_PU1sWYCC1cDUXLp243Ojcb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