Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:20

0001 //===--- RedundantVoidArgCheck.h - clang-tidy --------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 #include "clang/Lex/Token.h"
0014 
0015 #include <string>
0016 
0017 namespace clang::tidy::modernize {
0018 
0019 /// Find and remove redundant void argument lists.
0020 ///
0021 /// Examples:
0022 ///   `int f(void);`                    becomes `int f();`
0023 ///   `int (*f(void))(void);`           becomes `int (*f())();`
0024 ///   `typedef int (*f_t(void))(void);` becomes `typedef int (*f_t())();`
0025 ///   `void (C::*p)(void);`             becomes `void (C::*p)();`
0026 ///   `C::C(void) {}`                   becomes `C::C() {}`
0027 ///   `C::~C(void) {}`                  becomes `C::~C() {}`
0028 ///
0029 class RedundantVoidArgCheck : public ClangTidyCheck {
0030 public:
0031   RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
0032       : ClangTidyCheck(Name, Context) {}
0033 
0034   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0035     return LangOpts.CPlusPlus;
0036   }
0037 
0038   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0039 
0040   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0041 
0042 private:
0043   void processFunctionDecl(const ast_matchers::MatchFinder::MatchResult &Result,
0044                            const FunctionDecl *Function);
0045 
0046   void
0047   processTypedefNameDecl(const ast_matchers::MatchFinder::MatchResult &Result,
0048                          const TypedefNameDecl *Typedef);
0049 
0050   void processFieldDecl(const ast_matchers::MatchFinder::MatchResult &Result,
0051                         const FieldDecl *Member);
0052 
0053   void processVarDecl(const ast_matchers::MatchFinder::MatchResult &Result,
0054                       const VarDecl *Var);
0055 
0056   void
0057   processNamedCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
0058                        const CXXNamedCastExpr *NamedCast);
0059 
0060   void
0061   processExplicitCastExpr(const ast_matchers::MatchFinder::MatchResult &Result,
0062                           const ExplicitCastExpr *ExplicitCast);
0063 
0064   void processLambdaExpr(const ast_matchers::MatchFinder::MatchResult &Result,
0065                          const LambdaExpr *Lambda);
0066 
0067   void
0068   removeVoidArgumentTokens(const ast_matchers::MatchFinder::MatchResult &Result,
0069                            SourceRange Range, StringRef GrammarLocation);
0070 
0071   void removeVoidToken(Token VoidToken, StringRef Diagnostic);
0072 };
0073 
0074 } // namespace clang::tidy::modernize
0075 
0076 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_CHECK_H