Bug 1857669 - Install libavcodec/libavutil for Selenium tests r=releng-reviewers...
[gecko.git] / build / clang-plugin / BaseCheck.h
blob867b82d2ad353e07b6beef8842e57cf12d81207f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef BaseCheck_h__
6 #define BaseCheck_h__
8 class MozContext {};
9 typedef MozContext ContextType;
11 class BaseCheck : public MatchFinder::MatchCallback {
12 public:
13 BaseCheck(StringRef CheckName, ContextType *Context) {}
14 virtual void registerMatchers(MatchFinder *Finder) {}
15 virtual void registerPPCallbacks(CompilerInstance &CI) {}
16 virtual void check(const MatchFinder::MatchResult &Result) {}
17 DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
18 DiagnosticIDs::Level Level = DiagnosticIDs::Warning) {
19 DiagnosticsEngine &Diag = Context->getDiagnostics();
20 unsigned ID = Diag.getDiagnosticIDs()->getCustomDiagID(Level, Description);
21 return Diag.Report(Loc, ID);
24 private:
25 void run(const MatchFinder::MatchResult &Result) override {
26 Context = Result.Context;
27 check(Result);
30 private:
31 ASTContext *Context;
34 #endif