================
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "UsePlaceholderBindingCheck.h"
+#include "../utils/DeclRefExprUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+AST_POLYMORPHIC_MATCHER(isInMacro,
+                        AST_POLYMORPHIC_SUPPORTED_TYPES(Stmt, Decl)) {
+  return Node.getBeginLoc().isMacroID() || Node.getEndLoc().isMacroID();
+}
+
+AST_MATCHER(VarDecl, hasAutomaticStorageDurationAndNoSpecifiers) {
+  return !Node.isStaticLocal() && !Node.isConstexpr() && !Node.hasAttrs() &&
----------------
OmarAzizi wrote:

Good catch, dropping the first two.

`isStaticLocal()` is redundant: it reduces to `SC_Static || (SC_None && 
thread_local)`, both already excluded by the checks below it.

`isConstexpr()`: `constexpr auto [x, y] = ...` is legal, so this does get 
matched, but I excluded `static/thread_local` because `_` is only exempt from 
the "no redeclaration in scope" rule for automatic storage duration, and plain 
`constexpr` doesn't change storage duration, so that problem doesn't apply 
here. No reason to keep it.

Thought I'd keep `hasAttrs()` as `[[maybe_unused]] auto [x, y] = f()` is valid 
and would be matched by this check too. I excluded it conservatively, mirroring 
`hasAnySpecifiersShouldBeIgnored` in `UseStructuredBindingCheck`.

https://github.com/llvm/llvm-project/pull/207604
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to