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:
24
build/clang-plugin/AssertAssignmentChecker.cpp
Normal file
24
build/clang-plugin/AssertAssignmentChecker.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user