Bug 1324239 - Refactor the clang plugin; r=mystor

This patch mostly just splits up clang-plugin.cpp into separate files for
different classes or helpers.
This commit is contained in:
Ehsan Akhgari
2016-12-17 16:35:53 -05:00
parent 9a97d11145
commit 8e6e79ff90
55 changed files with 2848 additions and 2268 deletions

View File

@@ -0,0 +1,24 @@
/* 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 "AssertAssignmentChecker.h"
#include "CustomMatchers.h"
void AssertAssignmentChecker::registerMatcher(MatchFinder& AstMatcher) {
AstMatcher.addMatcher(
callExpr(isAssertAssignmentTestFunc()).bind("funcCall"),
this);
}
void AssertAssignmentChecker::run(
const MatchFinder::MatchResult &Result) {
DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
unsigned AssignInsteadOfComp = Diag.getDiagnosticIDs()->getCustomDiagID(
DiagnosticIDs::Error, "Forbidden assignment in assert expression");
const CallExpr *FuncCall = Result.Nodes.getNodeAs<CallExpr>("funcCall");
if (FuncCall && hasSideEffectAssignment(FuncCall)) {
Diag.Report(FuncCall->getLocStart(), AssignInsteadOfComp);
}
}