Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / build / clang-plugin / TrivialDtorChecker.cpp
blobffcd2ae101029555ef32fd484a484194ed3e5bc0
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/. */
5 #include "TrivialDtorChecker.h"
6 #include "CustomMatchers.h"
8 void TrivialDtorChecker::registerMatchers(MatchFinder *AstMatcher) {
9 AstMatcher->addMatcher(cxxRecordDecl(hasTrivialDtor()).bind("node"), this);
12 void TrivialDtorChecker::check(const MatchFinder::MatchResult &Result) {
13 const char *Error = "class %0 must have a trivial destructor";
14 const CXXRecordDecl *Node = Result.Nodes.getNodeAs<CXXRecordDecl>("node");
16 if (!Node->hasDefinition()) {
17 return;
20 bool BadDtor = !Node->hasTrivialDestructor();
21 if (BadDtor)
22 diag(Node->getBeginLoc(), Error, DiagnosticIDs::Error) << Node;