[Analyzer][WebKit] Check record definition is available in NoUncountedMembers checker

isRefCountable asserts that the record passed as an argument has a definition available.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=46142

Differential Revision: https://reviews.llvm.org/D81017
This commit is contained in:
Jan Korous 2020-06-02 10:17:01 -07:00
parent e31ccee1b0
commit d61ad66050
2 changed files with 11 additions and 1 deletions

View File

@ -75,7 +75,8 @@ public:
continue;
if (auto *MemberCXXRD = MemberType->getPointeeCXXRecordDecl()) {
if (isRefCountable(MemberCXXRD))
// If we don't see the definition we just don't know.
if (MemberCXXRD->hasDefinition() && isRefCountable(MemberCXXRD))
reportBug(Member, MemberType, MemberCXXRD, RD);
}
}

View File

@ -0,0 +1,9 @@
// regression test for https://bugs.llvm.org/show_bug.cgi?id=46142
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.WebKitNoUncountedMemberChecker -verify %s
// expected-no-diagnostics
class ClassWithoutADefinition;
class Foo {
const ClassWithoutADefinition *foo;
};