[clang] [analyzer] Add std::any checker (PR #76580)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 01:50:40 PST 2024


================
@@ -87,6 +85,28 @@ bool isStdVariant(const Type *Type) {
   return isStdType(Type, llvm::StringLiteral("variant"));
 }
 
+bool isStdAny(const Type *Type) {
+  return isStdType(Type, llvm::StringLiteral("any"));
+}
+
+bool isVowel(char a) {
+  switch (a) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
+    return true;
+  default:
+    return false;
+  }
+}
+
+llvm::StringRef indefiniteArticleBasedOnVowel(char a) {
+  if (isVowel(a))
+    return "an";
+  return "a";
+}
----------------
DonatNagyE wrote:

I'm bikeshedding this in the other direction, because I think that the length / verbosity of the messages is an important factor, so we shouldn't insert meaningless words just to simplify the code. We do not need absolutely perfect grammar, if we're attaching an article to an arbitrary variable name, it's OK if there are rare situations when it doesn't fit the pronunciation.

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


More information about the cfe-commits mailing list