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

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 02:54:08 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 think parenthesized `a(n)` in 100% of the messages is uglier than incorrectly applied `a` or `an` in <1% of the messages (in average English text, 1% of the words start with `u` [1] -- this may be different for type names, but the order of magnitude should be similar).

However, this is just bikesheddig, so I won't block any of the three solutions (decision based on `isVowel()`, using `a(n)` and using filler words to dodge the issue).

[1] https://www.johndcook.com/blog/2021/08/16/initial-letter-frequency/

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


More information about the cfe-commits mailing list