Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ bool tryToFindPtrOrigin(
if (auto *call = dyn_cast<CallExpr>(E)) {
if (auto *Callee = call->getCalleeDecl()) {
if (Callee->hasAttr<CFReturnsRetainedAttr>() ||
Callee->hasAttr<NSReturnsRetainedAttr>()) {
Callee->hasAttr<NSReturnsRetainedAttr>() ||
Callee->hasAttr<NSReturnsAutoreleasedAttr>()) {
return callback(E, true);
}
}
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,17 @@ void foo() {

} // namespace ns_retained_return_value

namespace autoreleased {

NSString *provideAutoreleased() __attribute__((ns_returns_autoreleased));
void consume(NSString *);

void foo() {
consume(provideAutoreleased());
}

} // autoreleased

@interface TestObject : NSObject
- (void)doWork:(NSString *)msg, ...;
- (void)doWorkOnSelf;
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/unretained-local-vars.mm
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ unsigned foo() {

} // namespace ns_retained_return_value

namespace autoreleased {

NSString *provideAutoreleased() __attribute__((ns_returns_autoreleased));
void consume(NSString *);

void foo() {
auto *string = provideAutoreleased();
consume(string);
}

} // autoreleased

bool doMoreWorkOpaque(OtherObj*);
SomeObj* provide();

Expand Down