mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 08:57:43 +08:00
Enhance reference-count checker to correctly identify CG "release" functions. This fixes <rdar://problem/6303488>.
llvm-svn: 57997
This commit is contained in:
@@ -704,8 +704,12 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
|
||||
}
|
||||
}
|
||||
|
||||
if (FName[0] == 'C' && FName[1] == 'F')
|
||||
S = getCFSummary(FD, FName);
|
||||
if (FName[0] == 'C') {
|
||||
if (FName[1] == 'F')
|
||||
S = getCFSummary(FD, FName);
|
||||
else if (FName[1] == 'G')
|
||||
S = getCGSummary(FD, FName);
|
||||
}
|
||||
else if (FName[0] == 'N' && FName[1] == 'S')
|
||||
S = getNSSummary(FD, FName);
|
||||
}
|
||||
@@ -834,10 +838,14 @@ RetainSummary* RetainSummaryManager::getCFSummaryCreateRule(FunctionDecl* FD) {
|
||||
|
||||
FunctionType* FT =
|
||||
dyn_cast<FunctionType>(FD->getType().getTypePtr());
|
||||
|
||||
if (FT && !isCFRefType(FT->getResultType()))
|
||||
return getPersistentSummary(RetEffect::MakeNoRet());
|
||||
|
||||
if (FT) {
|
||||
QualType ResTy = FT->getResultType();
|
||||
|
||||
if (!isCFRefType(ResTy) && !isCGRefType(ResTy))
|
||||
return getPersistentSummary(RetEffect::MakeNoRet());
|
||||
}
|
||||
|
||||
assert (ScratchArgs.empty());
|
||||
|
||||
if (FD->getIdentifier() == CFDictionaryCreateII) {
|
||||
|
||||
18
clang/test/Analysis/CGColorSpace.c
Normal file
18
clang/test/Analysis/CGColorSpace.c
Normal file
@@ -0,0 +1,18 @@
|
||||
// clang -checker-cfref -verify %s
|
||||
|
||||
typedef struct CGColorSpace *CGColorSpaceRef;
|
||||
extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
|
||||
extern CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef space);
|
||||
extern void CGColorSpaceRelease(CGColorSpaceRef space);
|
||||
|
||||
void f() {
|
||||
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
|
||||
CGColorSpaceRetain(X); // expected-warning{{leak}}
|
||||
}
|
||||
|
||||
void fb() {
|
||||
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
|
||||
CGColorSpaceRetain(X);
|
||||
CGColorSpaceRelease(X);
|
||||
CGColorSpaceRelease(X); // no-warning
|
||||
}
|
||||
Reference in New Issue
Block a user