From 09c9cbaaf5af69f15f360880360c6dcc85addb09 Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Mon, 14 Jul 2025 13:58:23 -0700 Subject: [PATCH] WebKit checkers: recgonize @YES / @NO as safe constants --- clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp | 5 ++++- clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp index cfcc47c5e71c8..478bd85177143 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp @@ -177,7 +177,10 @@ bool tryToFindPtrOrigin( E = unaryOp->getSubExpr(); continue; } - + if (auto *BoxedExpr = dyn_cast(E)) { + E = BoxedExpr->getSubExpr(); + continue; + } break; } // Some other expression. diff --git a/clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm b/clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm index c33d53b047c2e..c69113c48806d 100644 --- a/clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm +++ b/clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm @@ -329,13 +329,17 @@ void foo() { } } +#define YES 1 + namespace call_with_cf_constant { void bar(const NSArray *); void baz(const NSDictionary *); + void boo(NSNumber *); void foo() { CFArrayCreateMutable(kCFAllocatorDefault, 10); bar(@[@"hello"]); baz(@{@"hello": @3}); + boo(@YES); } }