brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 42fb927 Raw
45 lines · cpp
1// RUN: %check_clang_tidy -std=c++20 %s readability-container-size-empty %t -- -- -fno-delayed-template-parsing2 3namespace std {4struct strong_ordering {5  int n;6  constexpr operator int() const { return n; }7  static const strong_ordering equal, greater, less;8};9constexpr strong_ordering strong_ordering::equal = {0};10constexpr strong_ordering strong_ordering::greater = {1};11constexpr strong_ordering strong_ordering::less = {-1};12} // namespace std13 14template <typename T>15struct OpEqOnly {16  OpEqOnly();17  bool operator==(const OpEqOnly<T> &other) const;18  unsigned long size() const;19  bool empty() const;20};21 22template <typename T>23struct HasSpaceshipMem {24  HasSpaceshipMem();25  bool operator<=>(const HasSpaceshipMem<T> &other) const = default;26  unsigned long size() const;27  bool empty() const;28};29 30void returnsVoid() {31  OpEqOnly<int> OEO;32  HasSpaceshipMem<int> HSM;33 34  if (OEO != OpEqOnly<int>())35    ;36  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness37  // CHECK-FIXES: if (!OEO.empty())38  // CHECK-MESSAGES: :19:8: note: method 'OpEqOnly'::empty() defined here39  if (HSM != HasSpaceshipMem<int>())40    ;41  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness42  // CHECK-FIXES: if (!HSM.empty())43  // CHECK-MESSAGES: :27:8: note: method 'HasSpaceshipMem'::empty() defined here44}45