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

via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 30 03:13:57 PST 2023


================
@@ -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";
+}
----------------
whisperity wrote:

I don't think this is phonetically correct. For example, if I call this for the first letter in the word `union`, which is pronounced as [`YUU-ni-yon` or `YUUN-jen`](http://en.wiktionary.org/wiki/union#English), then it should be **`a union`** and not `an union`.

Some more examples: http://english.stackexchange.com/questions/266309/why-is-union-an-exception-to-the-a-an-rule

Might be worthwhile to just get rid of this altogether, and refactor the call site like this: `any held a value of 'Union'` or `any contained object of type 'Union'`.

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


More information about the cfe-commits mailing list