[clang-tools-extra] [clang-tidy] ignore uninitialized std::array in member init (PR #98134)

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 02:19:26 PDT 2024


================
@@ -422,6 +422,28 @@ static const char *getInitializer(QualType QT, bool UseAssignment) {
   }
 }
 
+static bool isStdArray(QualType QT) {
+  const auto *RT = QT->getAs<RecordType>();
+  if (!RT)
+    return false;
+  const auto *RD = RT->getDecl();
+  if (!RD)
+    return false;
+
+  const IdentifierInfo *II = RD->getIdentifier();
+  if (!II)
+    return false;
+
+  if (II->getName() == "array") {
+    const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(RD->getDeclContext());
+    if (NS && NS->getName() == "std") {
----------------
njames93 wrote:

Use the `clang::Decl::isInStdNamespace` helper function here instead. It handles things like inline namespaces that would break this logic on some standard library implementations

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


More information about the cfe-commits mailing list