https://github.com/rwlbuis updated https://github.com/llvm/llvm-project/pull/146369
>From 1a3c8e86d991c8b689176c1e0ecfdc494325c029 Mon Sep 17 00:00:00 2001 From: Rob Buis <rb...@igalia.com> Date: Mon, 30 Jun 2025 16:18:40 +0100 Subject: [PATCH 1/3] [alpha.webkit.UncountedCallArgsChecker] Treat CFEqual as a safe function CFEqual is a trivial function, so treat it as safe. --- .../Checkers/WebKit/RawPtrRefCallArgsChecker.cpp | 2 +- .../Checkers/WebKit/call-args-safe-functions.mm | 11 +++++++++++ clang/test/Analysis/Checkers/WebKit/objc-mock-types.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp index 6bc39ab565041..764e2c640feb8 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp @@ -294,7 +294,7 @@ class RawPtrRefCallArgsChecker if (name == "adoptRef" || name == "getPtr" || name == "WeakPtr" || name == "is" || name == "equal" || name == "hash" || name == "isType" || // FIXME: Most/all of these should be implemented via attributes. - name == "equalIgnoringASCIICase" || + name == "CFEqual" || name == "equalIgnoringASCIICase" || name == "equalIgnoringASCIICaseCommon" || name == "equalIgnoringNullity" || name == "toString") return true; diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm b/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm new file mode 100644 index 0000000000000..c1ce08d0b10f6 --- /dev/null +++ b/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm @@ -0,0 +1,11 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s + +#include "objc-mock-types.h" + +CGImageRef provideImage(); + +Boolean cfe(CFTypeRef obj) +{ + return CFEqual(obj, provideImage()); +} + diff --git a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h index 9e4356a71f1b5..cd2f53a8ec9c5 100644 --- a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h +++ b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h @@ -45,6 +45,7 @@ CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef CFDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict); CFIndex CFDictionaryGetCount(CFDictionaryRef theDict); Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key); +extern Boolean CFEqual(CFTypeRef, CFTypeRef); Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value); const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value); >From e3c6dab8f4a1014622929d4beac6f8260d748c9f Mon Sep 17 00:00:00 2001 From: Rob Buis <rb...@igalia.com> Date: Mon, 30 Jun 2025 19:26:14 +0100 Subject: [PATCH 2/3] Update call-args-safe-functions.mm --- clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm b/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm index c1ce08d0b10f6..7ccc0d61f0acf 100644 --- a/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm +++ b/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.mm @@ -1,4 +1,5 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s +// expected-no-diagnostics #include "objc-mock-types.h" >From c822ab040ed0952eb82854f07e86fcad460b1db9 Mon Sep 17 00:00:00 2001 From: Rob Buis <rb...@igalia.com> Date: Tue, 1 Jul 2025 08:15:47 +0100 Subject: [PATCH 3/3] Update objc-mock-types.h --- clang/test/Analysis/Checkers/WebKit/objc-mock-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h index cd2f53a8ec9c5..09b303961fd6a 100644 --- a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h +++ b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h @@ -45,7 +45,7 @@ CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef CFDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict); CFIndex CFDictionaryGetCount(CFDictionaryRef theDict); Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key); -extern Boolean CFEqual(CFTypeRef, CFTypeRef); +Boolean CFEqual(CFTypeRef, CFTypeRef); Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value); const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits