[llvm-branch-commits] [clang] 6278084 - [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 16 11:30:45 PDT 2024


Author: Nikolas Klauser
Date: 2024-09-16T20:30:33+02:00
New Revision: 6278084bc69a427cf7a610076817c420e3dc8594

URL: https://github.com/llvm/llvm-project/commit/6278084bc69a427cf7a610076817c420e3dc8594
DIFF: https://github.com/llvm/llvm-project/commit/6278084bc69a427cf7a610076817c420e3dc8594.diff

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

Fixes #107777

(cherry picked from commit 6dbdb8430b492959c399a7809247424c6962902f)

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 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