[llvm-branch-commits] [clang] release/19.x: [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815) (PR #108147)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 10 23:55:54 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport 6dbdb84
Requested by: @<!-- -->philnik777
---
Full diff: https://github.com/llvm/llvm-project/pull/108147.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+2-1)
- (modified) clang/test/SemaCXX/type-traits.cpp (+18)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/108147
More information about the llvm-branch-commits
mailing list