================
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-objc-arc
+
+@interface NSObject
+@end
+
+@interface NSString : NSObject
+@end
+
+@interface NSURL : NSObject
+- (NSString *)absoluteString;
+@end
+
+@interface NSArray : NSObject
+@end
+
+// ObjC for-in loop variables should not be flagged, as they are initialized
+// by the loop itself. Previously, the check would incorrectly try to insert
+// '= nullptr' at the wrong source location, corrupting the following 
statement.
+void objc_for_in_no_false_positive(NSArray *urls) {
+  for (NSURL *url in urls) {
+    // 'url' should NOT be flagged - it is a for-in loop variable.
+    NSString *urlString = [url absoluteString];
+    // 'urlString' should NOT be flagged - it has an initializer.
+    (void)urlString;
+  }
+}
----------------
sstepashka wrote:

PTAL.

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

Reply via email to