mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 15:36:58 +00:00
[webkit.RefCntblBaseVirtualDtor] Add support for NoVirtualDestructorBase. (#132497)
This PR adds the support for WTF::NoVirtualDestructorBase, which signifies to the checker that the class is exempt from having a virtual destructor.
This commit is contained in:
parent
3386156b1e
commit
2b43ecd27b
@ -202,6 +202,13 @@ public:
|
||||
if (!C)
|
||||
continue;
|
||||
|
||||
bool isExempt = T.getAsString() == "NoVirtualDestructorBase" &&
|
||||
safeGetName(C->getParent()) == "WTF";
|
||||
if (isExempt || ExemptDecls.contains(C)) {
|
||||
ExemptDecls.insert(RD);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
|
||||
for (auto &Arg : CTSD->getTemplateArgs().asArray()) {
|
||||
if (Arg.getKind() != TemplateArgument::Type)
|
||||
@ -223,12 +230,13 @@ public:
|
||||
|
||||
llvm::SetVector<const CXXRecordDecl *> Decls;
|
||||
llvm::DenseSet<const CXXRecordDecl *> CRTPs;
|
||||
llvm::DenseSet<const CXXRecordDecl *> ExemptDecls;
|
||||
};
|
||||
|
||||
LocalVisitor visitor(this);
|
||||
visitor.TraverseDecl(const_cast<TranslationUnitDecl *>(TUD));
|
||||
for (auto *RD : visitor.Decls) {
|
||||
if (visitor.CRTPs.contains(RD))
|
||||
if (visitor.CRTPs.contains(RD) || visitor.ExemptDecls.contains(RD))
|
||||
continue;
|
||||
visitCXXRecordDecl(RD);
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor -verify %s
|
||||
|
||||
namespace WTF {
|
||||
|
||||
class NoVirtualDestructorBase { };
|
||||
|
||||
};
|
||||
|
||||
using WTF::NoVirtualDestructorBase;
|
||||
|
||||
struct RefCntblBase {
|
||||
void ref() {}
|
||||
void deref() {}
|
||||
@ -19,6 +27,15 @@ struct [[clang::suppress]] SuppressedDerivedWithVirtualDtor : RefCntblBase {
|
||||
virtual ~SuppressedDerivedWithVirtualDtor() {}
|
||||
};
|
||||
|
||||
class ClassWithoutVirtualDestructor : public NoVirtualDestructorBase {
|
||||
public:
|
||||
void ref() const;
|
||||
void deref() const;
|
||||
};
|
||||
|
||||
class DerivedClassWithoutVirtualDestructor : public ClassWithoutVirtualDestructor {
|
||||
};
|
||||
|
||||
// FIXME: Support attributes on base specifiers? Currently clang
|
||||
// doesn't support such attributes at all, even though it knows
|
||||
// how to parse them.
|
||||
|
Loading…
x
Reference in New Issue
Block a user