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/. */
9 typedef MozContext ContextType
;
11 class BaseCheck
: public MatchFinder::MatchCallback
{
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
);
25 void run(const MatchFinder::MatchResult
&Result
) override
{
26 Context
= Result
.Context
;