[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Thu May 23 18:10:39 PDT 2024
================
@@ -51,92 +169,137 @@ class RefCntblBaseVirtualDtorChecker
bool shouldVisitImplicitCode() const { return false; }
bool VisitCXXRecordDecl(const CXXRecordDecl *RD) {
- Checker->visitCXXRecordDecl(RD);
+ if (!RD->hasDefinition())
+ return true;
+
+ Decls.insert(RD);
+
+ for (auto &Base : RD->bases()) {
+ const auto AccSpec = Base.getAccessSpecifier();
+ if (AccSpec == AS_protected || AccSpec == AS_private ||
+ (AccSpec == AS_none && RD->isClass()))
+ continue;
+
+ QualType T = Base.getType();
+ if (T.isNull())
+ continue;
+
+ const CXXRecordDecl *C = T->getAsCXXRecordDecl();
+ if (!C)
+ continue;
+
+ if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
+ auto &Args = CTSD->getTemplateArgs();
+ for (unsigned i = 0; i < Args.size(); ++i) {
----------------
haoNoQ wrote:
If you like you can do a `CTSD->getTemplateArgs().asArray()` and do a range-based loop. It's going to be an `llvm::ArrayRef` so you can store it by value too.
https://github.com/llvm/llvm-project/pull/92837
More information about the cfe-commits
mailing list