[clang] dbd1129 - Stop checking whether std::strong_* has ::equivalent members.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 11:35:56 PST 2019


Author: Richard Smith
Date: 2019-12-06T11:35:41-08:00
New Revision: dbd112972416f48f7e5b117e7a14b6e4b4d38146

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

LOG: Stop checking whether std::strong_* has ::equivalent members.

Any attempt to use these would be a bug, so we shouldn't even look for
them.

Added: 
    

Modified: 
    clang/lib/AST/ComparisonCategories.cpp
    clang/test/SemaCXX/std-compare-cxx2a.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ComparisonCategories.cpp b/clang/lib/AST/ComparisonCategories.cpp
index ee4c1b0443a3..8999913b728b 100644
--- a/clang/lib/AST/ComparisonCategories.cpp
+++ b/clang/lib/AST/ComparisonCategories.cpp
@@ -190,19 +190,16 @@ ComparisonCategories::getPossibleResultsForType(ComparisonCategoryType Type) {
   using CCT = ComparisonCategoryType;
   using CCR = ComparisonCategoryResult;
   std::vector<CCR> Values;
-  Values.reserve(6);
-  Values.push_back(CCR::Equivalent);
+  Values.reserve(4);
   bool IsStrong = (Type == CCT::StrongEquality || Type == CCT::StrongOrdering);
   if (IsStrong)
-    Values.push_back(CCR::Equal);
+  Values.push_back(IsStrong ? CCR::Equal : CCR::Equivalent);
   if (Type == CCT::StrongOrdering || Type == CCT::WeakOrdering ||
       Type == CCT::PartialOrdering) {
     Values.push_back(CCR::Less);
     Values.push_back(CCR::Greater);
   } else {
-    Values.push_back(CCR::Nonequivalent);
-    if (IsStrong)
-      Values.push_back(CCR::Nonequal);
+    Values.push_back(IsStrong ? CCR::Nonequal : CCR::Nonequivalent);
   }
   if (Type == CCT::PartialOrdering)
     Values.push_back(CCR::Unordered);

diff  --git a/clang/test/SemaCXX/std-compare-cxx2a.cpp b/clang/test/SemaCXX/std-compare-cxx2a.cpp
index 6746fb480e62..941c4faeb7ff 100644
--- a/clang/test/SemaCXX/std-compare-cxx2a.cpp
+++ b/clang/test/SemaCXX/std-compare-cxx2a.cpp
@@ -27,7 +27,7 @@ struct partial_ordering {
 } // namespace std
 
 auto missing_member_test() {
-  // expected-error at +1 {{standard library implementation of 'std::partial_ordering' is not supported; member 'equivalent' is missing}}
+  // expected-error at +1 {{standard library implementation of 'std::partial_ordering' is not supported; member 'less' is missing}}
   return (1.0 <=> 1.0);
 }
 
@@ -35,13 +35,13 @@ namespace std {
 inline namespace __1 {
 struct strong_ordering {
   long long value;
-  static const strong_ordering equivalent; // expected-note {{declared here}}
+  static const strong_ordering equal; // expected-note {{declared here}}
 };
 } // namespace __1
 } // namespace std
 
 auto test_non_constexpr_var() {
-  // expected-error at +1 {{standard library implementation of 'std::strong_ordering' is not supported; member 'equivalent' does not have expected form}}
+  // expected-error at +1 {{standard library implementation of 'std::strong_ordering' is not supported; member 'equal' does not have expected form}}
   return (1 <=> 0);
 }
 


        


More information about the cfe-commits mailing list