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/. */
4 
5 #include "OverrideBaseCallUsageChecker.h"
6 #include "CustomMatchers.h"
7 
registerMatchers(MatchFinder * AstMatcher)8 void OverrideBaseCallUsageChecker::registerMatchers(MatchFinder *AstMatcher) {
9   AstMatcher->addMatcher(
10       cxxMethodDecl(isNonVirtual(), isRequiredBaseMethod()).bind("method"),
11       this);
12 }
13 
check(const MatchFinder::MatchResult & Result)14 void OverrideBaseCallUsageChecker::check(
15     const MatchFinder::MatchResult &Result) {
16   const char *Error =
17       "MOZ_REQUIRED_BASE_METHOD can be used only on virtual methods";
18   const CXXMethodDecl *Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
19 
20   diag(Method->getLocation(), Error, DiagnosticIDs::Error);
21 }
22