Created
April 20, 2015 01:38
-
-
Save daniel-beard/6b25a5cf29b7dcb31700 to your computer and use it in GitHub Desktop.
OCLint if matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "oclint/AbstractASTMatcherRule.h" | |
#include "oclint/RuleSet.h" | |
using namespace std; | |
using namespace clang; | |
using namespace clang::ast_matchers; | |
using namespace oclint; | |
class AllIfStatementsRule : public AbstractASTMatcherRule | |
{ | |
public: | |
virtual const string name() const override | |
{ | |
return "all if statements"; | |
} | |
virtual int priority() const override | |
{ | |
return 3; | |
} | |
virtual void callback(const MatchFinder::MatchResult &result) override | |
{ | |
const IfStmt *ifStmt = result.Nodes.getNodeAs<IfStmt>("ifStmt"); | |
if (ifStmt) { | |
addViolation(ifStmt->getCond(), this, "if statement found"); | |
} | |
} | |
virtual void setUpMatcher() override | |
{ | |
addMatcher(ifStmt().bind("ifStmt")); | |
} | |
}; | |
static RuleSet rules(new AllIfStatementsRule()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment