Skip to content

[clang-tidy][NFC] clean LangOpts parameter in explicitMarkUnused matcher #122170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchersMacros.h"
#include "clang/Basic/LangOptions.h"

using namespace clang::ast_matchers;
using namespace clang::tidy::matchers;
Expand All @@ -29,9 +30,10 @@ 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) {
AST_MATCHER(VarDecl, explicitMarkUnused) {
// Implementations should not emit a warning that a name-independent
// declaration is used or unused.
LangOptions const &LangOpts = Finder->getASTContext().getLangOpts();
return Node.hasAttr<UnusedAttr>() ||
(LangOpts.CPlusPlus26 && Node.isPlaceholderVar(LangOpts));
}
Expand Down Expand Up @@ -66,7 +68,7 @@ void UnusedLocalNonTrivialVariableCheck::registerMatchers(MatchFinder *Finder) {
varDecl(isLocalVarDecl(), unless(isReferenced()),
unless(isExceptionVariable()), hasLocalStorage(), isDefinition(),
unless(hasType(isReferenceType())), unless(hasType(isTrivial())),
unless(explicitMarkUnused(getLangOpts())),
unless(explicitMarkUnused()),
hasType(hasUnqualifiedDesugaredType(
anyOf(recordType(hasDeclaration(namedDecl(
matchesAnyListedName(IncludeTypes),
Expand Down
Loading