[clang] 6dbdb84 - [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 23:47:27 PDT 2024


Author: Nikolas Klauser
Date: 2024-09-11T08:47:24+02:00
New Revision: 6dbdb8430b492959c399a7809247424c6962902f

URL: https://github.com/llvm/llvm-project/commit/6dbdb8430b492959c399a7809247424c6962902f
DIFF: https://github.com/llvm/llvm-project/commit/6dbdb8430b492959c399a7809247424c6962902f.diff

LOG: [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815)

Fixes #107777

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprCXX.cpp
    clang/test/SemaCXX/type-traits.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 14feafd1e6b17f..a14a086731c13d 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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;

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