clang-tools 23.0.0git
RedundantVoidArgCheck.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANTVOIDARGCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANTVOIDARGCHECK_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang::tidy::modernize {
15
16/// Find and remove redundant void argument lists.
17///
18/// Examples:
19/// `int f(void);` becomes `int f();`
20/// `int (*f(void))(void);` becomes `int (*f())();`
21/// `typedef int (*f_t(void))(void);` becomes `typedef int (*f_t())();`
22/// `void (C::*p)(void);` becomes `void (C::*p)();`
23/// `C::C(void) {}` becomes `C::C() {}`
24/// `C::~C(void) {}` becomes `C::~C() {}`
25///
27public:
28 RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
29 : ClangTidyCheck(Name, Context) {}
30
31 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
32 return LangOpts.CPlusPlus || LangOpts.C23;
33 }
34 std::optional<TraversalKind> getCheckTraversalKind() const override {
35 return TK_IgnoreUnlessSpelledInSource;
36 }
37
38 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
39
40 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
41};
42
43} // namespace clang::tidy::modernize
44
45#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REDUNDANTVOIDARGCHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
RedundantVoidArgCheck(StringRef Name, ClangTidyContext *Context)
std::optional< TraversalKind > getCheckTraversalKind() const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
void registerMatchers(ast_matchers::MatchFinder *Finder) override