Debian Codegraph @

build/clang-plugin/AssertAssignmentChecker.cpp

raw
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 "AssertAssignmentChecker.h"
6 #include "CustomMatchers.h"
7
8 void AssertAssignmentChecker::registerMatchers(MatchFinder *AstMatcher) {
9 AstMatcher->addMatcher(
10 callExpr(isAssertAssignmentTestFunc()).bind("funcCall"), this);
11 }
12
13 void AssertAssignmentChecker::check(const MatchFinder::MatchResult &Result) {
14 const CallExpr *FuncCall = Result.Nodes.getNodeAs<CallExpr>("funcCall");
15
16 if (FuncCall && hasSideEffectAssignment(FuncCall)) {
17 diag(FuncCall->getBeginLoc(), "Forbidden assignment in assert expression",
18 DiagnosticIDs::Error);
19 }
20 }