llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)

<details>
<summary>Changes</summary>

UIResponderStandardEditActions defines (void)copy:(id)sender but this selector 
should not be treated as a copy operation since it's a "copy" in the sense of 
application triggering copy &amp; paste for the system pasteboard.

---
Full diff: https://github.com/llvm/llvm-project/pull/179713.diff


3 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp (+8-1) 
- (modified) 
clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm (+14) 
- (modified) clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm 
(+14) 


``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index 15971168934b5..f9d35c595682b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -337,8 +337,15 @@ bool isAllocInit(const Expr *E, const Expr **InnerExpr) {
   auto NameForFirstSlot = Selector.getNameForSlot(0);
   if (NameForFirstSlot.starts_with("alloc") ||
       NameForFirstSlot.starts_with("copy") ||
-      NameForFirstSlot.starts_with("mutableCopy"))
+      NameForFirstSlot.starts_with("mutableCopy")) {
+    if (auto *MD = ObjCMsgExpr->getMethodDecl()) {
+      if (auto *T = MD->getReturnType().getTypePtrOrNull()) {
+        if (T->isVoidType())
+          return false;
+      }
+    }
     return true;
+  }
   if (!NameForFirstSlot.starts_with("init") &&
       !NameForFirstSlot.starts_with("_init"))
     return false;
diff --git 
a/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm 
b/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm
index 47203cbd27355..609b274ce63b4 100644
--- a/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm
+++ b/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm
@@ -69,6 +69,9 @@ - (SomeObj *)copyWithValue:(int)value {
   return copy;
 }
 
+- (void)copy:(id)sender {
+}
+
 - (void)doWork {
   _number = [[NSNumber alloc] initWithInt:5];
 }
@@ -99,6 +102,17 @@ - (void)setValue:(NSNumber *)value {
 
 @end;
 
+@interface SubObj : SomeObj
+@end
+
+@implementation SubObj
+
+- (void)copy:(id)sender {
+  [super copy:sender];
+}
+
+@end
+
 RetainPtr<CVPixelBufferRef> cf_out_argument() {
   auto surface = adoptCF(IOSurfaceCreate(nullptr));
   CVPixelBufferRef rawBuffer = nullptr;
diff --git a/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm 
b/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm
index 427affdbbd601..20f951b27a149 100644
--- a/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm
+++ b/clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm
@@ -76,6 +76,9 @@ - (SomeObj *)copyWithValue:(int)value {
   return copy;
 }
 
+- (void)copy:(id)sender {
+}
+
 - (void)doWork {
   _number = [[NSNumber alloc] initWithInt:5];
 }
@@ -114,6 +117,17 @@ - (id)copyWithZone:(NSZone *)zone {
 
 @end;
 
+@interface SubObj : SomeObj
+@end
+
+@implementation SubObj
+
+- (void)copy:(id)sender {
+  [super copy:sender];
+}
+
+@end
+
 RetainPtr<CVPixelBufferRef> cf_out_argument() {
   auto surface = adoptCF(IOSurfaceCreate(nullptr));
   CVPixelBufferRef rawBuffer = nullptr;

``````````

</details>


https://github.com/llvm/llvm-project/pull/179713
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to