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

Gábor Spaits via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 01:56:15 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";
+}
----------------
spaits wrote:

I think a good solution would be just to use the current text, but instead of deciding the indefinite article dynamically, we could just use `a(n)`. I think with this solution we would have correct grammar and a short warning. What do you think?

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


More information about the cfe-commits mailing list