clang-tools  3.9.0
RedundantVoidArgCheck.h
Go to the documentation of this file.
1 //===--- RedundantVoidArgCheck.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_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
12 
13 #include "../ClangTidy.h"
14 #include "clang/Lex/Token.h"
15 
16 #include <string>
17 
18 namespace clang {
19 namespace tidy {
20 namespace modernize {
21 
22 /// \brief Find and remove redundant void argument lists.
23 ///
24 /// Examples:
25 /// `int f(void);` becomes `int f();`
26 /// `int (*f(void))(void);` becomes `int (*f())();`
27 /// `typedef int (*f_t(void))(void);` becomes `typedef int (*f_t())();`
28 /// `void (C::*p)(void);` becomes `void (C::*p)();`
29 /// `C::C(void) {}` becomes `C::C() {}`
30 /// `C::~C(void) {}` becomes `C::~C() {}`
31 ///
33 public:
35  : ClangTidyCheck(Name, Context) {}
36 
37  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38 
39  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
40 
41 private:
42  void processFunctionDecl(const ast_matchers::MatchFinder::MatchResult &Result,
43  const FunctionDecl *Function);
44 
45  void
46  processTypedefNameDecl(const ast_matchers::MatchFinder::MatchResult &Result,
47  const TypedefNameDecl *Typedef);
48 
49  void processFieldDecl(const ast_matchers::MatchFinder::MatchResult &Result,
50  const FieldDecl *Member);
51 
52  void processVarDecl(const ast_matchers::MatchFinder::MatchResult &Result,
53  const VarDecl *Var);
54 
55  void
56  processNamedCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
57  const CXXNamedCastExpr *NamedCast);
58 
59  void
60  processExplicitCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
61  const ExplicitCastExpr *ExplicitCast);
62 
63  void processLambdaExpr(const ast_matchers::MatchFinder::MatchResult &Result,
64  const LambdaExpr *Lambda);
65 
66  void
67  removeVoidArgumentTokens(const ast_matchers::MatchFinder::MatchResult &Result,
68  SourceRange Range, StringRef GrammarLocation);
69 
70  void removeVoidToken(Token VoidToken, StringRef Diagnostic);
71 };
72 
73 } // namespace modernize
74 } // namespace tidy
75 } // namespace clang
76 
77 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
const std::string Name
Definition: USRFinder.cpp:140
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:210
Base class for all clang-tidy checks.
Definition: ClangTidy.h:110
RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
Find and remove redundant void argument lists.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
CharSourceRange Range
SourceRange for the file name.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
const NamedDecl * Result
Definition: USRFinder.cpp:137