Skip to content

Commit 7262ab8

Browse files
committed
[WebKit Checkers] Treat a boxed value as a safe pointer origin (llvm#161133)
1 parent 34df013 commit 7262ab8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ bool tryToFindPtrOrigin(
209209
continue;
210210
}
211211
if (auto *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
212+
if (StopAtFirstRefCountedObj)
213+
return callback(BoxedExpr, true);
212214
E = BoxedExpr->getSubExpr();
213215
continue;
214216
}

clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,18 @@ void foo() {
397397
void baz(const NSDictionary *);
398398
void boo(NSNumber *);
399399
void boo(CFTypeRef);
400-
void foo() {
400+
401+
struct Details {
402+
int value;
403+
};
404+
405+
void foo(Details* details) {
401406
CFArrayCreateMutable(kCFAllocatorDefault, 10);
402407
bar(@[@"hello"]);
403408
baz(@{@"hello": @3});
404409
boo(@YES);
405410
boo(@NO);
411+
boo(@(details->value));
406412
}
407413
}
408414

0 commit comments

Comments
 (0)