Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / build / clang-plugin / NeedsNoVTableTypeChecker.cpp
blob9d5ad039baabe2c4054731dea8fdede93c7dfe1a
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 "NeedsNoVTableTypeChecker.h"
6 #include "CustomMatchers.h"
8 void NeedsNoVTableTypeChecker::registerMatchers(MatchFinder *AstMatcher) {
9 AstMatcher->addMatcher(
10 classTemplateSpecializationDecl(
11 allOf(hasAnyTemplateArgument(refersToType(hasVTable())),
12 hasNeedsNoVTableTypeAttr()))
13 .bind("node"),
14 this);
17 void NeedsNoVTableTypeChecker::check(const MatchFinder::MatchResult &Result) {
18 const ClassTemplateSpecializationDecl *Specialization =
19 Result.Nodes.getNodeAs<ClassTemplateSpecializationDecl>("node");
21 // Get the offending template argument
22 QualType Offender;
23 const TemplateArgumentList &Args =
24 Specialization->getTemplateInstantiationArgs();
25 for (unsigned i = 0; i < Args.size(); ++i) {
26 Offender = Args[i].getAsType();
27 if (typeHasVTable(Offender)) {
28 break;
32 diag(Specialization->getBeginLoc(),
33 "%0 cannot be instantiated because %1 has a VTable",
34 DiagnosticIDs::Error)
35 << Specialization << Offender;
36 diag(Specialization->getPointOfInstantiation(),
37 "bad instantiation of %0 requested here", DiagnosticIDs::Note)
38 << Specialization;