зеркало из https://github.com/microsoft/clang-1.git
Further cleanups to isTrackedObjectType().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69929 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
77a6be4826
Коммит
97d095f4e5
|
@ -784,18 +784,22 @@ RetainSummaryManager::getPersistentSummary(ArgEffects* AE, RetEffect RetEff,
|
|||
// Predicates.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
bool RetainSummaryManager::isTrackedObjectType(QualType T) {
|
||||
if (!Ctx.isObjCObjectPointerType(T))
|
||||
bool RetainSummaryManager::isTrackedObjectType(QualType Ty) {
|
||||
if (!Ctx.isObjCObjectPointerType(Ty))
|
||||
return false;
|
||||
|
||||
// Does it subclass NSObject?
|
||||
ObjCInterfaceType* OT = dyn_cast<ObjCInterfaceType>(T.getTypePtr());
|
||||
// We assume that id<..>, id, and "Class" all represent tracked objects.
|
||||
const PointerType *PT = Ty->getAsPointerType();
|
||||
if (PT == 0)
|
||||
return true;
|
||||
|
||||
const ObjCInterfaceType *OT = PT->getPointeeType()->getAsObjCInterfaceType();
|
||||
|
||||
// We assume that id<..>, id, and "Class" all represent tracked objects.
|
||||
if (!OT)
|
||||
return true;
|
||||
|
||||
// Does the object type subclass NSObject?
|
||||
|
||||
// Does the interface subclass NSObject?
|
||||
// FIXME: We can memoize here if this gets too expensive.
|
||||
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
|
||||
ObjCInterfaceDecl* ID = OT->getDecl();
|
||||
|
|
|
@ -251,3 +251,12 @@ void test_stringWithFormat() {
|
|||
[string release]; // expected-warning{{Incorrect decrement of the reference count}}
|
||||
}
|
||||
|
||||
// Test isTrackedObjectType()
|
||||
typedef NSString* WonkyTypedef;
|
||||
@interface TestIsTracked
|
||||
+ (WonkyTypedef)newString;
|
||||
@end
|
||||
|
||||
void test_isTrackedObjectType(void) {
|
||||
NSString *str = [TestIsTracked newString]; // expected-warning{{Potential leak}}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче