Skip to content

Commit 859705c

Browse files
committed
Avoid computing ODR Hash duplicatly
1 parent 40012e1 commit 859705c

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

clang/lib/AST/ODRHash.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -803,16 +803,6 @@ void ODRHash::AddDecl(const Decl *D) {
803803

804804
AddDeclarationName(ND->getDeclName());
805805

806-
const auto *Specialization =
807-
dyn_cast<ClassTemplateSpecializationDecl>(D);
808-
AddBoolean(Specialization);
809-
if (Specialization) {
810-
const TemplateArgumentList &List = Specialization->getTemplateArgs();
811-
ID.AddInteger(List.size());
812-
for (const TemplateArgument &TA : List.asArray())
813-
AddTemplateArgument(TA);
814-
}
815-
816806
// If this was a specialization we should take into account its template
817807
// arguments. This helps to reduce collisions coming when visiting template
818808
// specialization types (eg. when processing type template arguments).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/type_traits.cppm -emit-module-interface -o %t/type_traits.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/test.cpp -fprebuilt-module-path=%t -verify
7+
8+
//--- type_traits.cppm
9+
export module type_traits;
10+
11+
export template <typename T>
12+
constexpr bool is_pod_v = __is_pod(T);
13+
14+
//--- test.cpp
15+
// expected-no-diagnostics
16+
import type_traits;
17+
// Base is either void or wrapper<T>.
18+
template <class Base> struct wrapper : Base {};
19+
template <> struct wrapper<void> {};
20+
21+
// wrap<0>::type<T> is wrapper<T>, wrap<1>::type<T> is wrapper<wrapper<T>>,
22+
// and so on.
23+
template <int N>
24+
struct wrap {
25+
template <class Base>
26+
using type = wrapper<typename wrap<N-1>::template type<Base>>;
27+
};
28+
29+
template <>
30+
struct wrap<0> {
31+
template <class Base>
32+
using type = wrapper<Base>;
33+
};
34+
35+
inline constexpr int kMaxRank = 40;
36+
template <int N, class Base = void>
37+
using rank = typename wrap<N>::template type<Base>;
38+
using rank_selector_t = rank<kMaxRank>;
39+
40+
static_assert(is_pod_v<rank_selector_t>, "Must be POD");

0 commit comments

Comments
 (0)