[llvm-branch-commits] [clang] b833e0c - PR44786: Don't assert when profiling <=> expressions.

Richard Smith via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 4 18:31:10 PST 2020


Author: Richard Smith
Date: 2020-02-04T18:30:54-08:00
New Revision: b833e0c5f1190e7102e570b0eb5055174aa03b32

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

LOG: PR44786: Don't assert when profiling <=> expressions.

(cherry picked from commit b96c6b65b93f7b3878bced2374bef747a4c3b690)

Added: 
    

Modified: 
    clang/lib/AST/StmtProfile.cpp
    clang/test/SemaCXX/cxx2a-three-way-comparison.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 382ea5c8d7ef..60dec50d53da 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1535,8 +1535,8 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
     return Stmt::BinaryOperatorClass;
 
   case OO_Spaceship:
-    // FIXME: Update this once we support <=> expressions.
-    llvm_unreachable("<=> expressions not supported yet");
+    BinaryOp = BO_Cmp;
+    return Stmt::BinaryOperatorClass;
 
   case OO_AmpAmp:
     BinaryOp = BO_LAnd;

diff  --git a/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp b/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
index eb1480ce6102..29ae95066e27 100644
--- a/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
+++ b/clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
@@ -1,5 +1,14 @@
 // RUN: %clang_cc1 -std=c++2a -verify %s
 
+// Keep this test before any declarations of operator<=>.
+namespace PR44786 {
+  template<typename T> void f(decltype(T{} <=> T{})) {} // expected-note {{previous}}
+
+  struct S {};
+  int operator<=>(S const &, S const &);
+  template<typename T> void f(decltype(T{} <=> T{})) {} // expected-error {{redefinition}}
+}
+
 struct A {};
 constexpr int operator<=>(A a, A b) { return 42; }
 static_assert(operator<=>(A(), A()) == 42);


        


More information about the llvm-branch-commits mailing list