Skip to content

Commit

Permalink
[Clang] Fix crash due to invalid source location in __is_trivially_eq…
Browse files Browse the repository at this point in the history
…uality_comparable (#107815)

Fixes #107777
  • Loading branch information
philnik777 authored Sep 11, 2024
1 parent bc152fb commit 6dbdb84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5171,7 +5171,8 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S,

// const ClassT& obj;
OpaqueValueExpr Operand(
{}, Decl->getTypeForDecl()->getCanonicalTypeUnqualified().withConst(),
KeyLoc,
Decl->getTypeForDecl()->getCanonicalTypeUnqualified().withConst(),
ExprValueKind::VK_LValue);
UnresolvedSet<16> Functions;
// obj == obj;
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaCXX/type-traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4147,6 +4147,24 @@ class Template {};
// Make sure we don't crash when instantiating a type
static_assert(!__is_trivially_equality_comparable(Template<Template<int>>));


struct S operator==(S, S);

template <class> struct basic_string_view {};

struct basic_string {
operator basic_string_view<int>() const;
};

template <class T>
const bool is_trivially_equality_comparable = __is_trivially_equality_comparable(T);

template <int = is_trivially_equality_comparable<basic_string> >
void find();

void func() { find(); }


namespace hidden_friend {

struct TriviallyEqualityComparable {
Expand Down

0 comments on commit 6dbdb84

Please sign in to comment.