[clang-tools-extra] [clang-tidy] fix false positives when using name-independent variables after C++26 for bugprone-unused-local-non-trivial-variable (PR #121783)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 12:04:26 PST 2025
================
@@ -29,6 +29,12 @@ static constexpr StringRef DefaultIncludeTypeRegex =
AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
AST_MATCHER(VarDecl, isReferenced) { return Node.isReferenced(); }
+AST_MATCHER_P(VarDecl, explicitMarkUnused, LangOptions, LangOpts) {
+ // Implementations should not emit a warning that a name-independent
+ // declaration is used or unused.
+ return Node.hasAttr<UnusedAttr>() ||
+ (LangOpts.CPlusPlus26 && Node.isPlaceholderVar(LangOpts));
----------------
carlosgalvezp wrote:
Out of curiosity, is the CplusPlus26 needed? Won't `isPlaceholderVar` return `false` otherwise?
https://github.com/llvm/llvm-project/pull/121783
More information about the cfe-commits
mailing list