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()))
17 void NeedsNoVTableTypeChecker::check(const MatchFinder::MatchResult
&Result
) {
18 const ClassTemplateSpecializationDecl
*Specialization
=
19 Result
.Nodes
.getNodeAs
<ClassTemplateSpecializationDecl
>("node");
21 // Get the offending template argument
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
)) {
32 diag(Specialization
->getBeginLoc(),
33 "%0 cannot be instantiated because %1 has a VTable",
35 << Specialization
<< Offender
;
36 diag(Specialization
->getPointOfInstantiation(),
37 "bad instantiation of %0 requested here", DiagnosticIDs::Note
)