[clang] [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (PR #107815)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 9 00:16:20 PDT 2024
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/107815
Fixes #107777
>From 0059de326ef8dd01e24f45cb18d9035957e77873 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 9 Sep 2024 09:15:39 +0200
Subject: [PATCH] [Clang] Fix crash due to invalid source location in
__is_trivially_equality_comparable
---
clang/lib/Sema/SemaExprCXX.cpp | 3 ++-
clang/test/SemaCXX/type-traits.cpp | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e086c601107041..5f7f4eee632bf1 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5168,7 +5168,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;
diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index b8a9db103782c3..91ef7786f11bb9 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -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 {
More information about the cfe-commits
mailing list