<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64091>64091</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ODRHash] Regression after f82df0b285ac
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:modules
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ChuanqiXu9
</td>
</tr>
</table>
<pre>
This comes from https://reviews.llvm.org/D154324.
I registered the issue for tracking it formally.
The reproducer reported is:
```
$ cat a.cppmap
module "a" {
export *
module "a.h" {
export *
header "a.h"
}
use "c"
}
$ cat b.cppmap
module "b" {
export *
module "b.h" {
export *
header "b.h"
}
use "c"
}
$ cat c.cppmap
module "c" {
export *
module "c1.h" {
export *
textual header "c1.h"
}
module "c2.h" {
export *
textual header "c2.h"
}
module "c3.h" {
export *
textual header "c3.h"
}
}
$ cat test.cppmap
module "test" {
export *
use "a"
use "b"
}
$ cat a.h
#ifndef A_H_
#define A_H_
#include "c1.h"
namespace q {
template <typename T,
typename std::enable_if<::p::P<T>::value>::type>
class X {};
} // namespace q
#include "c3.h"
#endif // A_H_
$ cat b.h
#ifndef B_H_
#define B_H_
#include "c2.h"
#endif // B_H_
$ cat c1.h
#ifndef C1_H_
#define C1_H_
namespace std {
template <class _Tp, _Tp __v>
struct integral_constant {
static constexpr const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant type;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
template <class _Tp, _Tp __v>
constexpr const _Tp integral_constant<_Tp, __v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <bool, class _Tp = void>
struct enable_if {};
template <class _Tp>
struct enable_if<true, _Tp> {
typedef _Tp type;
};
} // namespace std
namespace p {
template <typename T>
struct P : ::std::false_type {};
}
#endif // C1_H_
$ cat c2.h
#ifndef C2_H_
#define C2_H_
#include "c3.h"
enum E {};
namespace p {
template <>
struct P<E> : std::true_type {};
} // namespace proto2
inline void f(::util::EnumErrorSpace<E>) {}
#endif // C2_H_
$ cat c3.h
#ifndef C3_H_
#define C3_H_
#include "c1.h"
namespace util {
template <typename T>
class ErrorSpaceImpl;
class ErrorSpace {
protected:
template <bool* addr>
struct OdrUse {
constexpr OdrUse() : b(*addr) {}
bool& b;
};
template <typename T>
struct Registerer {
static bool register_token;
static constexpr OdrUse<®ister_token> kRegisterTokenUse{};
};
private:
template <typename T>
static const ErrorSpace* GetBase() {
return 0;
}
static bool Register(const ErrorSpace* (*space)()) { return true; }
};
template <typename T>
bool ErrorSpace::Registerer<T>::register_token =
Register(&ErrorSpace::GetBase<T>);
template <typename T>
class ErrorSpaceImpl : public ErrorSpace {
private:
static constexpr Registerer<ErrorSpaceImpl> kRegisterer{};
};
template <typename T, typename = typename std::enable_if<p::P<T>::value>::type>
class EnumErrorSpace : public ErrorSpaceImpl<EnumErrorSpace<T>> {};
} // namespace util
#endif // C3_H_
$ cat test.cc
#include "a.h"
#include "b.h"
int main(int, char**) {}
$ clang -fmodules -fno-implicit-modules -fno-implicit-module-maps -fmodule-name=c -fmodule-map-file=c.cppmap -xc++ -c c.cppmap -Xclang=-emit-module -o c.pcm
$ clang -fmodules -fno-implicit-modules -fno-implicit-module-maps -fmodule-name=a -fmodule-map-file=a.cppmap -fmodule-map-file=c.cppmap -xc++ -c a.cppmap -Xclang=-emit-module -o a.pcm
$ clang -fmodules -fno-implicit-modules -fno-implicit-module-maps -fmodule-name=b -fmodule-map-file=b.cppmap -fmodule-map-file=c.cppmap -xc++ -c b.cppmap -Xclang=-emit-module -o b.pcm
$ clang -fmodules -fno-implicit-modules -fno-implicit-module-maps -fmodule-name=test -fmodule-map-file=test.cppmap -fmodule-map-file=a.cppmap -fmodule-map-file=b.cppmap -Xclang=-fmodule-file=a.pcm -Xclang=-fmodule-file=b.pcm -xc++ -c test.cc -o test.pcm
In module 'b':
./c3.h:44:7: error: 'util::EnumErrorSpace' has different definitions in different modules; definition in module 'b.b.h' is here
44 | class EnumErrorSpace : public ErrorSpaceImpl<EnumErrorSpace<T>> {};
| ^
./c3.h:44:7: note: definition in module 'a.a.h' is here
44 | class EnumErrorSpace : public ErrorSpaceImpl<EnumErrorSpace<T>> {};
| ^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWUlv4zoS_jX0hbAhk3IUH3zwkszr03t4kwH6ZlBUyea0tiapTPrfD0hqoRY7C9DAC4JI4lL11VfFKpJhSolLAbBDmwPanBas1tdS7o7XmhU_xfd6u4jL5Nfu5SoU5mUOCqeyzPFV60ohukfkGZFnCa8C_qdWWfaar0p5QeT5tN6ElIQrFJxQsHd_v2EJF6E0SEiwvgIWStWA01JiLRn_IYoLFtp85yzLfg3mvlwBS6hkmdQcpHktpYYEC4vCG4gegubXfZIQc6YxW_GqylnlWvMyqTPAiBCGCMEoOrh2jOHNCMaI7NsWb-zqOhw9HYzxFVgCsh_e9qDo1L7WyorjXW_X16KNb6CNP4E2HqPFc-N9wPHXAfMbgPknAPP1BxFreNM1yzzkzdQZ6J548nXx5APi6dfF03nxE5Y1KH2DaNP1LteNH5mnrGmKb7vWhHHTQEVaJJDi_fmPc9eWQCoK8Nu60QXP6gQmDnJ_C5aDqhgH_LNHrSGvMqYBI3rUvyowg_ALIseeP_fTdSqdmAxA91CwOIOzSBE9upbKPf5C9PiC6JP7emVZDd2XEWM-rHSeMaXwd4smOiF66BjB2CU67IG-YyydGIsIhSIRaSfIp7Bd8xOeDzM8H-7zTN5XfZiott4Z6T6uZ5T7jSMnKp3Mu9Gxen6pEDmaBz6fXzvKlZY111gUGi6SZWdeFkqzQvtxrDTTgmPbBW-VdG9WlHUmRvTkhHZTjFuNEd2Ys3P0ZMBU8Whgr7WsQDJdSl8geURk2-ApSnjjUFnoWIKuZYGbYDv4KaOX2AvqhDuJX5A7CNjP-WCO2AkviB7b6W6qv5iGem9Ri-gxLsvMyNDSrkH7HLrmI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