clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 ///
32 class RedundantVoidArgCheck : public ClangTidyCheck {
33 public:
34 RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
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 processTypedefDecl(const ast_matchers::MatchFinder::MatchResult &Result,
46 const TypedefDecl *Typedef);
47
48 void processFieldDecl(const ast_matchers::MatchFinder::MatchResult &Result,
49 const FieldDecl *Member);
50
51 void processVarDecl(const ast_matchers::MatchFinder::MatchResult &Result,
52 const VarDecl *Var);
53
54 void
55 processNamedCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
56 const CXXNamedCastExpr *NamedCast);
57
58 void
59 processExplicitCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
60 const ExplicitCastExpr *ExplicitCast);
61
62 void processLambdaExpr(const ast_matchers::MatchFinder::MatchResult &Result,
63 const LambdaExpr *Lambda);
64
65 void
66 removeVoidArgumentTokens(const ast_matchers::MatchFinder::MatchResult &Result,
67 SourceRange Range, StringRef GrammarLocation);
68
69 void removeVoidToken(Token VoidToken, StringRef Diagnostic);
70 };
71
72 } // namespace modernize
73 } // namespace tidy
74 } // namespace clang
75
76 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:188
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:102
clang::tidy::modernize::RedundantVoidArgCheck::RedundantVoidArgCheck
RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
Definition: RedundantVoidArgCheck.h:34
clang::tidy::modernize::RedundantVoidArgCheck
Find and remove redundant void argument lists.
Definition: RedundantVoidArgCheck.h:32
clang::tidy::modernize::RedundantVoidArgCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
Definition: RedundantVoidArgCheck.cpp:48
clang::tidy::modernize::RedundantVoidArgCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: RedundantVoidArgCheck.cpp:87
Range
CharSourceRange Range
SourceRange for the file name.
Definition: IncludeOrderCheck.cpp:35
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:124
Result
const NamedDecl * Result
Definition: USRFinder.cpp:121