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

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 01:35:17 PST 2024


=?utf-8?q?Gábor?= Spaits,=?utf-8?q?Gábor?= Spaits,
=?utf-8?q?Gábor?= Spaits,=?utf-8?q?Gábor?= Spaits,
=?utf-8?q?Gábor?= Spaits
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/76580 at github.com>


================
@@ -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:

If you skip the article, the message looks as if it was reporting the _value_ stored in the `std::any`, which may be an annoying confusion if the type name is not immediately recognizable as a type name.

I see that it has some advantages, but overall I think it's worse than any of the three other solutions (decision based on `isVowel()`, using a(n) and using filler words to dodge the issue).

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


More information about the cfe-commits mailing list