-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEarlyExitTidyModule.h
31 lines (23 loc) · 1.11 KB
/
EarlyExitTidyModule.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2022 Cory Fields
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef EARLY_EXIT_TIDY_MODULE_H
#define EARLY_EXIT_TIDY_MODULE_H
#include <clang-tidy/ClangTidyCheck.h>
namespace bitcoin {
class PropagateEarlyExitCheck final : public clang::tidy::ClangTidyCheck {
public:
PropagateEarlyExitCheck(clang::StringRef Name, clang::tidy::ClangTidyContext *Context)
: clang::tidy::ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const clang::LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
void registerMatchers(clang::ast_matchers::MatchFinder *Finder) override;
void check(const clang::ast_matchers::MatchFinder::MatchResult &Result) override;
private:
void recursiveChangeType(const clang::FunctionDecl*, clang::DiagnosticBuilder&);
void addReturn(const clang::Stmt*, clang::DiagnosticBuilder&, const clang::SourceManager&);
void updateReturn(const clang::ReturnStmt*, clang::DiagnosticBuilder&);
};
} // namespace bitcoin
#endif // EARLY_EXIT_TIDY_MODULE_H