[clang] d61ad66 - [Analyzer][WebKit] Check record definition is available in NoUncountedMembers checker
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 13:11:11 PDT 2020
Author: Jan Korous
Date: 2020-06-02T13:10:36-07:00
New Revision: d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc
URL: https://github.com/llvm/llvm-project/commit/d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc
DIFF: https://github.com/llvm/llvm-project/commit/d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc.diff
LOG: [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
Added:
clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp
Modified:
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
index 89caf602a17e..db53db1587d5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
@@ -75,7 +75,8 @@ class NoUncountedMemberChecker
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);
}
}
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp
new file mode 100644
index 000000000000..20e58e7926d8
--- /dev/null
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp
@@ -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;
+};
More information about the cfe-commits
mailing list