[clang-tools-extra] [clang-tidy] Extend readability-container-size-empty to std::size() (PR #201231)

Aayush Shrivastava via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 23:35:42 PDT 2026


================
@@ -924,6 +930,50 @@ class ReportInTemplateContainerNonEmptyMethod {
   }
 };
 
+namespace GH198494 {
+
+void testStdSize(const std::string &str, std::vector<int> vect) {
+  if (std::size(vect))
+    ;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
----------------
iamaayushrivastava wrote:

> Same as other places.

Thank you for the review. I've updated the test as suggested.


https://github.com/llvm/llvm-project/pull/201231


More information about the cfe-commits mailing list