Skip to content

Commit 635cba1

Browse files
committed
[StaticAnalyzer] Add a reproducer for a bug in VisitObjCForCollectionStmt
The bug in VisitObjCForCollectionStmt seems have been there for a long time and can be very rarely triggered. The adding test is reduced from a crash observed downstream that reproduces the bug. (#124477) (rdar://143280254)
1 parent 95d993a commit 635cba1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core,apiModeling,nullability.NullableDereferenced,nullability.NullabilityBase -x objective-c %s
2+
/*
3+
This test is reduced from a static analyzer crash. The bug causing
4+
the crash is explained in #124477. It can only be triggered in some
5+
rare cases so please do not modify this reproducer.
6+
*/
7+
8+
#pragma clang assume_nonnull begin
9+
# 15 "some-sys-header.h" 1 3
10+
@class NSArray, NSObject;
11+
12+
@interface Base
13+
@property (readonly, copy) NSArray *array;
14+
@end
15+
16+
#pragma clang assume_nonnull end
17+
# 8 "this-file.m" 2
18+
19+
20+
@interface Test : Base
21+
22+
@property (readwrite, copy, nullable) NSObject *label;
23+
@property (readwrite, strong, nullable) Test * field;
24+
25+
- (void)f;
26+
27+
@end
28+
29+
@implementation Test
30+
- (void)f
31+
{
32+
NSObject * X;
33+
34+
for (NSObject *ele in self.field.array) {}
35+
self.label = X;
36+
}
37+
@end
38+
39+

0 commit comments

Comments
 (0)