Skip to content

Commit 6dbdb84

Browse files
authored
[Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815)
Fixes #107777
1 parent bc152fb commit 6dbdb84

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5171,7 +5171,8 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S,
51715171

51725172
// const ClassT& obj;
51735173
OpaqueValueExpr Operand(
5174-
{}, Decl->getTypeForDecl()->getCanonicalTypeUnqualified().withConst(),
5174+
KeyLoc,
5175+
Decl->getTypeForDecl()->getCanonicalTypeUnqualified().withConst(),
51755176
ExprValueKind::VK_LValue);
51765177
UnresolvedSet<16> Functions;
51775178
// obj == obj;

clang/test/SemaCXX/type-traits.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,6 +4147,24 @@ class Template {};
41474147
// Make sure we don't crash when instantiating a type
41484148
static_assert(!__is_trivially_equality_comparable(Template<Template<int>>));
41494149

4150+
4151+
struct S operator==(S, S);
4152+
4153+
template <class> struct basic_string_view {};
4154+
4155+
struct basic_string {
4156+
operator basic_string_view<int>() const;
4157+
};
4158+
4159+
template <class T>
4160+
const bool is_trivially_equality_comparable = __is_trivially_equality_comparable(T);
4161+
4162+
template <int = is_trivially_equality_comparable<basic_string> >
4163+
void find();
4164+
4165+
void func() { find(); }
4166+
4167+
41504168
namespace hidden_friend {
41514169

41524170
struct TriviallyEqualityComparable {

0 commit comments

Comments
 (0)