2016-12-18 00:35:53 +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/. */
|
|
|
|
|
|
|
|
#include "OverrideBaseCallUsageChecker.h"
|
|
|
|
#include "CustomMatchers.h"
|
|
|
|
|
2017-10-20 20:11:50 +03:00
|
|
|
void OverrideBaseCallUsageChecker::registerMatchers(MatchFinder *AstMatcher) {
|
2016-12-18 05:14:37 +03:00
|
|
|
AstMatcher->addMatcher(
|
2016-12-18 00:35:53 +03:00
|
|
|
cxxMethodDecl(isNonVirtual(), isRequiredBaseMethod()).bind("method"),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
2016-12-18 05:14:37 +03:00
|
|
|
void OverrideBaseCallUsageChecker::check(
|
2016-12-18 00:35:53 +03:00
|
|
|
const MatchFinder::MatchResult &Result) {
|
2017-10-20 20:11:50 +03:00
|
|
|
const char *Error =
|
2016-12-18 05:14:37 +03:00
|
|
|
"MOZ_REQUIRED_BASE_METHOD can be used only on virtual methods";
|
2016-12-18 00:35:53 +03:00
|
|
|
const CXXMethodDecl *Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
|
|
|
|
|
2016-12-18 05:14:37 +03:00
|
|
|
diag(Method->getLocation(), Error, DiagnosticIDs::Error);
|
2016-12-18 00:35:53 +03:00
|
|
|
}
|