abrahamcd created this revision. Herald added a project: All. abrahamcd requested review of this revision. Herald added a project: clang-tools-extra. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D128663 Files: clang-tools-extra/test/clang-tidy/checkers/bugprone-standalone-empty.cpp Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-standalone-empty.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-standalone-empty.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: %check_clang_tidy %s bugprone-standalone-empty %t - -namespace std { - -template <typename T> -struct vector { - bool empty(); - void clear(); -}; - -template <typename T> -bool empty(T &&); - -} // namespace std - -namespace absl { -template <typename T> -struct vector { - bool empty(); - void clear(); -}; - -template <class T> -bool empty(T &&); -} // namespace absl - -int test_member_empty() { - std::vector<int> v; - - v.empty(); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::vector<int> w; - - w.empty(); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}w.clear();{{$}} -} - -int test_qualified_empty() { - absl::vector<int> v; - - std::empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} -} - -int test_unqualified_empty() { - std::vector<int> v; - - empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::vector<int> w; - - empty(w); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}w.clear();{{$}} - - { - using std::empty; - empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }} v.clear();{{$}} - } - - { - using absl::empty; - empty(w); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }} w.clear();{{$}} - } -}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-standalone-empty.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-standalone-empty.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: %check_clang_tidy %s bugprone-standalone-empty %t - -namespace std { - -template <typename T> -struct vector { - bool empty(); - void clear(); -}; - -template <typename T> -bool empty(T &&); - -} // namespace std - -namespace absl { -template <typename T> -struct vector { - bool empty(); - void clear(); -}; - -template <class T> -bool empty(T &&); -} // namespace absl - -int test_member_empty() { - std::vector<int> v; - - v.empty(); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::vector<int> w; - - w.empty(); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}w.clear();{{$}} -} - -int test_qualified_empty() { - absl::vector<int> v; - - std::empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} -} - -int test_unqualified_empty() { - std::vector<int> v; - - empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}v.clear();{{$}} - - absl::vector<int> w; - - empty(w); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }}w.clear();{{$}} - - { - using std::empty; - empty(v); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }} v.clear();{{$}} - } - - { - using absl::empty; - empty(w); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'absl::empty' [bugprone-standalone-empty] - // CHECK-FIXES: {{^ }} w.clear();{{$}} - } -}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits