clang-tools  4.0.0
NoMallocCheck.h
Go to the documentation of this file.
1 //===--- NoMallocCheck.h - clang-tidy----------------------------*- C++ -*-===//
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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NO_MALLOC_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NO_MALLOC_H
12 
13 #include "../ClangTidy.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/ASTMatchers/ASTMatchFinder.h"
16 
17 namespace clang {
18 namespace tidy {
19 namespace cppcoreguidelines {
20 
21 /// This checker is concerned with C-style memory management and suggest modern
22 /// alternatives to it.
23 /// The check is only enabled in C++. For analyzing malloc calls see Clang
24 /// Static Analyzer - unix.Malloc.
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-no-malloc.html
28 class NoMallocCheck : public ClangTidyCheck {
29 public:
30  NoMallocCheck(StringRef Name, ClangTidyContext *Context)
31  : ClangTidyCheck(Name, Context) {}
32 
33  /// Registering for malloc, calloc, realloc and free calls.
34  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
35 
36  /// Checks matched function calls and gives suggestion to modernize the code.
37  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
38 };
39 
40 } // namespace cppcoreguidelines
41 } // namespace tidy
42 } // namespace clang
43 
44 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NO_MALLOC_H
NoMallocCheck(StringRef Name, ClangTidyContext *Context)
Definition: NoMallocCheck.h:30
const std::string Name
Definition: USRFinder.cpp:164
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:262
This checker is concerned with C-style memory management and suggest modern alternatives to it...
Definition: NoMallocCheck.h:28
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
Checks matched function calls and gives suggestion to modernize the code.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Registering for malloc, calloc, realloc and free calls.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
const NamedDecl * Result
Definition: USRFinder.cpp:162