llvm-project/clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
Victor Chernyakin 43384913b6
[clang-tidy][NFC] Switch to new file header style (#158497)
As decided in #118553 and following up #153942.

`rename_check.py` has small logic changes, everything else is a
mechanical replacement.
2025-09-14 14:06:20 -06:00

35 lines
1.3 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "RedundantFunctionPtrDereferenceCheck.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
using namespace clang::ast_matchers;
namespace clang::tidy::readability {
void RedundantFunctionPtrDereferenceCheck::registerMatchers(
MatchFinder *Finder) {
Finder->addMatcher(
traverse(TK_AsIs, unaryOperator(hasOperatorName("*"),
has(implicitCastExpr(hasCastKind(
CK_FunctionToPointerDecay))))
.bind("op")),
this);
}
void RedundantFunctionPtrDereferenceCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Operator = Result.Nodes.getNodeAs<UnaryOperator>("op");
diag(Operator->getOperatorLoc(),
"redundant repeated dereference of function pointer")
<< FixItHint::CreateRemoval(Operator->getOperatorLoc());
}
} // namespace clang::tidy::readability