2016-12-18 05:14:37 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2016-12-29 05:19:30 +03:00
|
|
|
#ifndef BaseCheck_h__
|
|
|
|
#define BaseCheck_h__
|
2016-12-18 05:14:37 +03:00
|
|
|
|
|
|
|
class MozContext {};
|
|
|
|
typedef MozContext ContextType;
|
|
|
|
|
2016-12-29 05:19:30 +03:00
|
|
|
class BaseCheck : public MatchFinder::MatchCallback {
|
2016-12-18 05:14:37 +03:00
|
|
|
public:
|
2017-10-20 20:11:50 +03:00
|
|
|
BaseCheck(StringRef CheckName, ContextType *Context) {}
|
2016-12-18 05:14:37 +03:00
|
|
|
virtual void registerMatchers(MatchFinder *Finder) {}
|
2017-10-20 20:11:50 +03:00
|
|
|
virtual void registerPPCallbacks(CompilerInstance &CI) {}
|
2016-12-18 05:14:37 +03:00
|
|
|
virtual void check(const MatchFinder::MatchResult &Result) {}
|
|
|
|
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
|
|
|
|
DiagnosticIDs::Level Level = DiagnosticIDs::Warning) {
|
|
|
|
DiagnosticsEngine &Diag = Context->getDiagnostics();
|
|
|
|
unsigned ID = Diag.getDiagnosticIDs()->getCustomDiagID(Level, Description);
|
|
|
|
return Diag.Report(Loc, ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void run(const MatchFinder::MatchResult &Result) override {
|
|
|
|
Context = Result.Context;
|
|
|
|
check(Result);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-10-20 20:11:50 +03:00
|
|
|
ASTContext *Context;
|
2016-12-18 05:14:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|