[clang-tidy] Fix warnings caused by "new check" template (#80537)

This commit is contained in:
Danny Mösch 2024-02-03 13:49:54 +01:00 committed by GitHub
parent 260fe032c2
commit 514d0691f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,7 +131,6 @@ def write_implementation(module_path, module, namespace, check_name_camel):
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "%(check_name)s.h" #include "%(check_name)s.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchFinder.h"
using namespace clang::ast_matchers; using namespace clang::ast_matchers;
@ -146,7 +145,7 @@ void %(check_name)s::registerMatchers(MatchFinder *Finder) {
void %(check_name)s::check(const MatchFinder::MatchResult &Result) { void %(check_name)s::check(const MatchFinder::MatchResult &Result) {
// FIXME: Add callback implementation. // FIXME: Add callback implementation.
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x"); const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x");
if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_")) if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().starts_with("awesome_"))
return; return;
diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome") diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
<< MatchedDecl << MatchedDecl