[clang] a95c08d - [Analyzer][NoUncountedMembersChecker] Fix crash for C structs
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 15:57:33 PDT 2020
Author: Jan Korous
Date: 2020-06-04T15:57:19-07:00
New Revision: a95c08db122ef33576cd8f35094afcd1ea668d68
URL: https://github.com/llvm/llvm-project/commit/a95c08db122ef33576cd8f35094afcd1ea668d68
DIFF: https://github.com/llvm/llvm-project/commit/a95c08db122ef33576cd8f35094afcd1ea668d68.diff
LOG: [Analyzer][NoUncountedMembersChecker] Fix crash for C structs
Fixes https://bugs.llvm.org/show_bug.cgi?id=46177
Fixes second bug reported in https://bugs.llvm.org/show_bug.cgi?id=46142
Added:
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 db53db1587d5..2deefab96255 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
@@ -109,7 +109,11 @@ class NoUncountedMemberChecker
// Ref-counted smartpointers actually have raw-pointer to uncounted type as
// a member but we trust them to handle it correctly.
- return isRefCounted(llvm::dyn_cast_or_null<CXXRecordDecl>(RD));
+ auto CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(RD);
+ if (CXXRD)
+ return isRefCounted(CXXRD);
+
+ return false;
}
void reportBug(const FieldDecl *Member, const Type *MemberType,
More information about the cfe-commits
mailing list