15
15
#include " clang/ASTMatchers/ASTMatchFinder.h"
16
16
#include " clang/ASTMatchers/ASTMatchers.h"
17
17
#include " clang/ASTMatchers/ASTMatchersMacros.h"
18
+ #include " clang/Basic/LangOptions.h"
18
19
19
20
using namespace clang ::ast_matchers;
20
21
using namespace clang ::tidy::matchers;
@@ -29,9 +30,10 @@ static constexpr StringRef DefaultIncludeTypeRegex =
29
30
30
31
AST_MATCHER (VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl (); }
31
32
AST_MATCHER (VarDecl, isReferenced) { return Node.isReferenced (); }
32
- AST_MATCHER_P (VarDecl, explicitMarkUnused, LangOptions, LangOpts ) {
33
+ AST_MATCHER (VarDecl, explicitMarkUnused) {
33
34
// Implementations should not emit a warning that a name-independent
34
35
// declaration is used or unused.
36
+ LangOptions const &LangOpts = Finder->getASTContext ().getLangOpts ();
35
37
return Node.hasAttr <UnusedAttr>() ||
36
38
(LangOpts.CPlusPlus26 && Node.isPlaceholderVar (LangOpts));
37
39
}
@@ -66,7 +68,7 @@ void UnusedLocalNonTrivialVariableCheck::registerMatchers(MatchFinder *Finder) {
66
68
varDecl (isLocalVarDecl (), unless (isReferenced ()),
67
69
unless (isExceptionVariable ()), hasLocalStorage (), isDefinition (),
68
70
unless (hasType (isReferenceType ())), unless (hasType (isTrivial ())),
69
- unless (explicitMarkUnused (getLangOpts () )),
71
+ unless (explicitMarkUnused ()),
70
72
hasType (hasUnqualifiedDesugaredType (
71
73
anyOf (recordType (hasDeclaration (namedDecl (
72
74
matchesAnyListedName (IncludeTypes),
0 commit comments