================
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "PointerToSpanCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+/// Return true if \p T is an unsigned integer type commonly used for sizes
+/// (size_t, unsigned, unsigned long, etc.).
+static bool isSizeType(QualType T) {
+  T = T.getCanonicalType();
+  if (const auto *BT = T->getAs<BuiltinType>()) {
+    switch (BT->getKind()) {
+    case BuiltinType::UInt:
+    case BuiltinType::ULong:
+    case BuiltinType::ULongLong:
+    case BuiltinType::Int:
+    case BuiltinType::Long:
+    case BuiltinType::LongLong:
+      return true;
+    default:
+      return false;
+    }
+  }
+  return false;
+}
+
+/// Return true if the parameter name suggests it represents a size or count.
+static bool isSizeName(StringRef Name) {
+  const std::string LowerStorage = Name.lower();
+  const StringRef Lower(LowerStorage);
+  return Lower == "size" || Lower == "len" || Lower == "length" ||
+         Lower == "count" || Lower == "n" || Lower == "num" ||
+         Lower == "nelems" || Lower == "nelem" || Lower == "num_elements" ||
+         Lower == "num_elems" || Lower == "sz" || Lower == "cnt" ||
+         Lower.ends_with("_size") || Lower.ends_with("_len") ||
----------------
hjanuschka wrote:

Updated this to the C++/LLVM equivalent of Python `endswith(tuple)`: suffixes 
are now in a static list and checked via `llvm::any_of(...)` + `ends_with(...)`.

https://github.com/llvm/llvm-project/pull/182085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to