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
20 lines
843 B
C++
20 lines
843 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 "TrivialDtorChecker.h"
|
|
#include "CustomMatchers.h"
|
|
|
|
void TrivialDtorChecker::registerMatchers(MatchFinder *AstMatcher) {
|
|
AstMatcher->addMatcher(cxxRecordDecl(hasTrivialDtor(), hasDefinition(),
|
|
unless(hasTrivialDestructor()))
|
|
.bind("node"),
|
|
this);
|
|
}
|
|
|
|
void TrivialDtorChecker::check(const MatchFinder::MatchResult &Result) {
|
|
const char *Error = "class %0 must have a trivial destructor";
|
|
const CXXRecordDecl *Node = Result.Nodes.getNodeAs<CXXRecordDecl>("node");
|
|
diag(Node->getBeginLoc(), Error, DiagnosticIDs::Error) << Node;
|
|
}
|