================ @@ -54,6 +55,7 @@ class MiscModule : public ClangTidyModule { CheckFactories.registerCheck<MisleadingIdentifierCheck>( "misc-misleading-identifier"); CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const"); + CheckFactories.registerCheck<MustUseCheck>("misc-must-use"); ---------------- PiotrZSL wrote:
I do not like check name, it's to short, and doesn't say what is not used (member, var, global, function, class ?). Second this should eb a bugprone check with preconfigured things like std::mutex, std::future, and probably few other. Third i personally got check called bugprone-unused-local-non-trivial-variable, that is implemented like this: ``` void BugproneUnusedLocalNonTrivialVariableCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(varDecl(unless(isExpansionInSystemHeader()), unless(isImplicit()), unless(parmVarDecl()), unless(decompositionDecl()), unless(isExceptionVariable()), hasLocalStorage(), isDefinition(), unless(hasType(namedDecl(matchesName(ExcludeTypeRegex)))), unless(hasType(qualType(references(namedDecl(matchesName(ExcludeTypeRegex)))))), decl().bind("var"), hasAncestor(functionDecl(unless(hasDescendant(declRefExpr(to(decl(equalsBoundNode("var")))))))) ).bind("var"), this); } void BugproneUnusedLocalNonTrivialVariableCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedDecl = Result.Nodes.getNodeAs<VarDecl>("var"); auto type = MatchedDecl->getType(); if (type.isTrivialType(*Result.Context) or type.isTriviallyCopyableType(*Result.Context)) return; diag(MatchedDecl->getLocation(), "unused local variable %0 of non trivial type %1, consider removing") << MatchedDecl << type; } It's not perfect, but what I'm thinking, is if this check and that shoudn't be a single check with inclusion/exclusion settings, so it could be configured to warn on all or just on some limited scope. ``` https://github.com/llvm/llvm-project/pull/76101 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits