[llvm-branch-commits] [clang] release/19.x: [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815) (PR #108147)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Sep 16 11:30:40 PDT 2024
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/108147
>From 6278084bc69a427cf7a610076817c420e3dc8594 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 11 Sep 2024 08:47:24 +0200
Subject: [PATCH] [Clang] Fix crash due to invalid source location in
__is_trivially_equality_comparable (#107815)
Fixes #107777
(cherry picked from commit 6dbdb8430b492959c399a7809247424c6962902f)
---
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 14d1f395af90e3..de50786f4d6c07 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5140,7 +5140,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 7c5be2ab374a75..608852da703312 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3958,6 +3958,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 llvm-branch-commits
mailing list