clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ProTypeConstCastCheck.cpp
Go to the documentation of this file.
1 //===--- ProTypeConstCastCheck.cpp - clang-tidy----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "ProTypeConstCastCheck.h"
11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
13
14 using namespace clang::ast_matchers;
15
16 namespace clang {
17 namespace tidy {
18
19 void ProTypeConstCastCheck::registerMatchers(MatchFinder *Finder) {
20 if (!getLangOpts().CPlusPlus)
21 return;
22
23 Finder->addMatcher(cxxConstCastExpr().bind("cast"), this);
24 }
25
26 void ProTypeConstCastCheck::check(const MatchFinder::MatchResult &Result) {
27 const auto *MatchedCast = Result.Nodes.getNodeAs<CXXConstCastExpr>("cast");
28 diag(MatchedCast->getOperatorLoc(), "do not use const_cast");
29 }
30
31 } // namespace tidy
32 } // namespace clang
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:188
ProTypeConstCastCheck.h
Result
const NamedDecl * Result
Definition: USRFinder.cpp:121