Skip to content

Commit

Permalink
register module
Browse files Browse the repository at this point in the history
  • Loading branch information
motemen committed Jul 19, 2023
1 parent d22beb8 commit 6f239a1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion AwesomeFunctionNamesCheck.cpp
Expand Up @@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//

#include "AwesomeFunctionNamesCheck.h"
#include "clang-tidy/ClangTidyModule.h"
#include "clang-tidy/ClangTidyModuleRegistry.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

Expand All @@ -22,7 +24,8 @@ void AwesomeFunctionNamesCheck::registerMatchers(MatchFinder *Finder) {
void AwesomeFunctionNamesCheck::check(const MatchFinder::MatchResult &Result) {
// FIXME: Add callback implementation.
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x");
if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_"))
if (!MatchedDecl->getIdentifier() ||
MatchedDecl->getName().startswith("awesome_"))
return;
diag(MatchedDecl->getLocation(), "function %0 is insufficiently awesome")
<< MatchedDecl
Expand All @@ -31,3 +34,18 @@ void AwesomeFunctionNamesCheck::check(const MatchFinder::MatchResult &Result) {
}

} // namespace clang::tidy::readability

namespace clang::tidy {

class ExtraModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<readability::AwesomeFunctionNamesCheck>(
"readability-awesome-function-names");
}
};

static ClangTidyModuleRegistry::Add<ExtraModule> X("extra-module",
"Adds extra lint checks.");

} // namespace clang::tidy

0 comments on commit 6f239a1

Please sign in to comment.