This is an archive of the discontinued LLVM Phabricator instance.

[Analyzer] More granular special casing in RetainCountChecker
ClosedPublic

Authored by george.karpenkov on Oct 2 2017, 6:46 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

dcoughlin accepted this revision.Oct 2 2017, 9:09 PM

Looks good to me with the (minor) inline comments addressed.

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
1089 ↗(On Diff #117462)

__CFDictionary is technically an implementation detail. It is probably better to use RetTy.getAsString() == "CFMutableDictionaryRef"

test/Analysis/retain-release.mm
471 ↗(On Diff #117462)

Please add a // no-warning comment to this line to let future maintainers know that it is specifically not supposed to warn.

It is also probably worth explicitly extending the comment on IOBSDNameMatching() to say that we don't want to warn unless the return type is CFMutableDictionaryRef.

This revision is now accepted and ready to land.Oct 2 2017, 9:09 PM
NoQ accepted this revision.Oct 3 2017, 8:44 AM

Yep, looks good.

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
1066–1068 ↗(On Diff #117462)

A bit fancier and a common pattern here:

if (const IdentifierInfo *II = RetTy.getBaseTypeIdentifier()) {
  RetTyName = II->getName();
}

Adhered to review comments.

george.karpenkov marked 2 inline comments as done.Oct 3 2017, 11:12 AM
This revision was automatically updated to reflect the committed changes.

Hi,

I see a failure on retain-release.m with this patch. Revert it for now.

  • TEST 'Clang :: Analysis/retain-release.m' FAILED ****

Script:

rm -f /usr/local/google/home/timshen/src/llvm-build/tools/clang/test/Analysis/Output/retain-release.m.tmp.objc.plist /usr/local/google/home/timshen/src/llvm-build/tools/clang/test/Analysis/Output/retain-release.m.tmp.objcpp.plist
/usr/local/google/home/timshen/src/llvm-build/bin/clang -cc1 -internal-isystem /usr/local/google/home/timshen/src/llvm-build/lib/clang/6.0.0/include -nostdsysteminc -analyze -analyzer-constraints=range -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m -analyzer-output=plist -o /usr/local/google/home/timshen/src/llvm-build/tools/clang/test/Analysis/Output/retain-release.m.tmp.objc.plist

/usr/local/google/home/timshen/src/llvm-build/bin/clang -cc1 -internal-isystem /usr/local/google/home/timshen/src/llvm-build/lib/clang/6.0.0/include -nostdsysteminc -analyze -analyzer-constraints=range -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -std=gnu++98 -Wno-objc-root-class /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m -analyzer-output=plist -o /usr/local/google/home/timshen/src/llvm-build/tools/clang/test/Analysis/Output/retain-release.m.tmp.objcpp.plist

Exit Code: 1

Command Output (stderr):

error: 'warning' diagnostics expected but not seen:

File /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m Line 974: leak
File /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m Line 978: leak
File /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m Line 982: leak
File /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m Line 997: leak
File /usr/local/google/home/timshen/src/llvm-project/clang/test/Analysis/retain-release.m Line 1002: leak

5 errors generated.