Skip to content

Commit b7f1deb

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd2ac21d328a4' from llvm.org/main into next
2 parents d6b0201 + d2ac21d commit b7f1deb

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,25 @@ namespace std {
1414
static constexpr bool value = true;
1515
};
1616

17+
template <typename T, typename U>
18+
static constexpr bool is_same_v = is_same<T, U>::value; // NOLINT
19+
1720
template<bool, typename T = void>
1821
struct enable_if {
1922
using type = T;
2023
};
2124

25+
template <bool B, typename T = void>
26+
using enable_if_t = typename enable_if<B, T>::type; // NOLINT
27+
28+
template <typename T>
29+
struct remove_reference {
30+
using type = T;
31+
};
32+
33+
template <typename T>
34+
using remove_reference_t = typename remove_reference<T>::type; // NOLINT
35+
2236
template <typename...>
2337
struct common_type {
2438
using type = int;
@@ -126,3 +140,13 @@ namespace my_std = std;
126140
using Alias = my_std::add_const<bool>::type;
127141
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use c++14 style type templates
128142
// CHECK-FIXES: using Alias = my_std::add_const_t<bool>;
143+
144+
template <typename T>
145+
struct ImplicitlyInstantiatedConstructor {
146+
template <typename U, typename = std::enable_if_t<std::is_same_v<U, T>>>
147+
ImplicitlyInstantiatedConstructor(U) {}
148+
};
149+
150+
const ImplicitlyInstantiatedConstructor<int> ImplicitInstantiation(std::remove_reference<int>::type(123));
151+
// CHECK-MESSAGES: :[[@LINE-1]]:68: warning: use c++14 style type templates
152+
// CHECK-FIXES: const ImplicitlyInstantiatedConstructor<int> ImplicitInstantiation(std::remove_reference_t<int>(123));

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,7 @@ bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
22122212
is the only callback that's made for this instantiation. \
22132213
We use getTemplateArgsAsWritten() to distinguish. */ \
22142214
if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { \
2215+
assert(D->getTemplateSpecializationKind() != TSK_ImplicitInstantiation); \
22152216
/* The args that remains unspecialized. */ \
22162217
TRY_TO(TraverseTemplateArgumentLocsHelper( \
22172218
ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs)); \

0 commit comments

Comments
 (0)