clang-tools 22.0.0git
ProTypeReinterpretCastCheck.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "clang/ASTMatchers/ASTMatchFinder.h"
11
12using namespace clang::ast_matchers;
13
15
17 Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
18}
19
21 const MatchFinder::MatchResult &Result) {
22 const auto *MatchedCast =
23 Result.Nodes.getNodeAs<CXXReinterpretCastExpr>("cast");
24 diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
25}
26
27} // namespace clang::tidy::cppcoreguidelines
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
void registerMatchers(ast_matchers::MatchFinder *Finder) override