[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 29 08:50:01 PDT 2017
NoQ added inline comments.
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1104
+ // expression classes separately.
+ if (!isa<ObjCBoxedExpr>(Ex))
+ for (auto Child : Ex->children()) {
----------------
dcoughlin wrote:
> What is special about ObjCBoxedExpr here? Naively I would have expected that we'd want to keep the old behavior for ObjCArrayLiteral and ObjCDictionary as well.
Yeah, i got it all wrong initially.
If a `char *` is boxed into `NSString`, it doesn't escape, even though `Val` would be the string pointer - which is what i wanted to express here; we already had a test for that.
Similarly, if, say, a C struct is boxed, the pointer to the struct doesn't escape. However, contents of the struct do escape! Conveniently, `Val` here would be the (lazy) compound value, similarly to `std::initializer_list`, so we don't need to explicitly avoid escaping the struct pointer itself.
If a C integer is boxed, nothing escapes, of course, until we implement the mythical non-pointer escape (eg. file descriptor integers in stream checker should escape when they get boxed).
For `ObjC{Array,Dictionary}Expr`essions, contents of the array/dictionary do actually escape. However, because only `NSObject`s can be within such boxed literals, and `RetainCountChecker` ignores escapes, it is largely irrelevant how we behave in this case - i've even no idea how to test that, so i guess it could be fixed later.
Reference: https://clang.llvm.org/docs/ObjectiveCLiterals.html
https://reviews.llvm.org/D35216
More information about the cfe-commits
mailing list