This should save memory and compilation time by not creating an unused context. It also clearly conveys the pattern caught by the pass. Concerning compilation speed, let's take the example of `Unified_cpp_js_src_jit5.cpp`. Without clang-plugin, it takes: 10.603 s ± 0.183 s to compile. With clang-plugin, before this patch: 14.188 s ± 0.230 s to compile With clang-plugin, after this patch: 14.108 s ± 0.772 s to compile So that's roughly 3.59s spent into the plugin, down to 3.51 with this patch, a marginal 2% speedup on the plugin efficiency. Differential Revision: https://phabricator.services.mozilla.com/D285008
22 lines
911 B
C++
22 lines
911 B
C++
/* 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::registerMatchers(MatchFinder *AstMatcher) {
|
|
AstMatcher->addMatcher(
|
|
callExpr(callee(functionDecl(hasName("MOZ_AssertAssignmentTest"))),
|
|
anyOf(hasDescendant(cxxOperatorCallExpr(isAssignmentOperator())),
|
|
hasDescendant(binaryOperator(isAssignmentOperator()))))
|
|
.bind("funcCall"),
|
|
this);
|
|
}
|
|
|
|
void AssertAssignmentChecker::check(const MatchFinder::MatchResult &Result) {
|
|
const CallExpr *FuncCall = Result.Nodes.getNodeAs<CallExpr>("funcCall");
|
|
diag(FuncCall->getBeginLoc(), "Forbidden assignment in assert expression",
|
|
DiagnosticIDs::Error);
|
|
}
|