forked from OSchip/llvm-project
Reverting r347949-r347951 because they broke the test bots.
http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/440/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Aosobject-retain-release.cpp llvm-svn: 348020
This commit is contained in:
parent
4d80f199e8
commit
cd5115b74d
|
@ -29,8 +29,6 @@ cscope.out
|
|||
#==============================================================================#
|
||||
# Directories to ignore (do not add trailing '/'s, they skip symlinks).
|
||||
#==============================================================================#
|
||||
# Clang extra user tools, which is tracked independently (clang-tools-extra).
|
||||
tools/extra
|
||||
# Sphinx build products
|
||||
docs/_build
|
||||
docs/analyzer/_build
|
||||
|
|
|
@ -530,8 +530,6 @@ class RetainSummaryManager {
|
|||
/// Decrement the reference count on OS object.
|
||||
const RetainSummary *getOSSummaryReleaseRule(const FunctionDecl *FD);
|
||||
|
||||
/// Free the OS object.
|
||||
const RetainSummary *getOSSummaryFreeRule(const FunctionDecl *FD);
|
||||
|
||||
enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable };
|
||||
|
||||
|
|
|
@ -124,8 +124,10 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
|
|||
}
|
||||
|
||||
const IdentifierInfo *II = FD->getIdentifier();
|
||||
if (!II)
|
||||
return getDefaultSummary();
|
||||
|
||||
StringRef FName = II ? II->getName() : "";
|
||||
StringRef FName = II->getName();
|
||||
|
||||
// Strip away preceding '_'. Doing this here will effect all the checks
|
||||
// down below.
|
||||
|
@ -302,12 +304,6 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
|
|||
|
||||
if (FName == "retain")
|
||||
return getOSSummaryRetainRule(FD);
|
||||
|
||||
if (FName == "free")
|
||||
return getOSSummaryFreeRule(FD);
|
||||
|
||||
if (MD->getOverloadedOperator() == OO_New)
|
||||
return getOSSummaryCreateRule(MD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,11 +491,9 @@ RetainSummaryManager::getSummary(const CallEvent &Call,
|
|||
case CE_CXXConstructor:
|
||||
Summ = getFunctionSummary(cast<CXXConstructorCall>(Call).getDecl());
|
||||
break;
|
||||
case CE_CXXAllocator:
|
||||
Summ = getFunctionSummary(cast<CXXAllocatorCall>(Call).getDecl());
|
||||
break;
|
||||
case CE_Block:
|
||||
case CE_CXXDestructor:
|
||||
case CE_CXXAllocator:
|
||||
// FIXME: These calls are currently unsupported.
|
||||
return getPersistentStopSummary();
|
||||
case CE_ObjCMessage: {
|
||||
|
@ -624,14 +618,6 @@ RetainSummaryManager::getOSSummaryReleaseRule(const FunctionDecl *FD) {
|
|||
/*ThisEff=*/DecRef);
|
||||
}
|
||||
|
||||
const RetainSummary *
|
||||
RetainSummaryManager::getOSSummaryFreeRule(const FunctionDecl *FD) {
|
||||
return getPersistentSummary(RetEffect::MakeNoRet(),
|
||||
/*ReceiverEff=*/DoNothing,
|
||||
/*DefaultEff=*/DoNothing,
|
||||
/*ThisEff=*/Dealloc);
|
||||
}
|
||||
|
||||
const RetainSummary *
|
||||
RetainSummaryManager::getOSSummaryCreateRule(const FunctionDecl *FD) {
|
||||
return getPersistentSummary(RetEffect::MakeOwned(RetEffect::OS));
|
||||
|
|
|
@ -14,7 +14,6 @@ struct OSMetaClass;
|
|||
struct OSObject {
|
||||
virtual void retain();
|
||||
virtual void release() {};
|
||||
virtual void free();
|
||||
virtual ~OSObject(){}
|
||||
|
||||
unsigned int foo() { return 42; }
|
||||
|
@ -24,9 +23,6 @@ struct OSObject {
|
|||
static OSObject *getObject();
|
||||
static OSObject *GetObject();
|
||||
|
||||
|
||||
static void * operator new(unsigned long size);
|
||||
|
||||
static const OSMetaClass * const metaClass;
|
||||
};
|
||||
|
||||
|
@ -66,34 +62,6 @@ struct OSMetaClassBase {
|
|||
static OSObject *safeMetaCast(const OSObject *inst, const OSMetaClass *meta);
|
||||
};
|
||||
|
||||
void check_free_no_error() {
|
||||
OSArray *arr = OSArray::withCapacity(10);
|
||||
arr->retain();
|
||||
arr->retain();
|
||||
arr->retain();
|
||||
arr->free();
|
||||
}
|
||||
|
||||
void check_free_use_after_free() {
|
||||
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
|
||||
arr->retain(); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
|
||||
arr->free(); // expected-note{{Object released}}
|
||||
arr->retain(); // expected-warning{{Reference-counted object is used after it is released}}
|
||||
// expected-note@-1{{Reference-counted object is used after it is released}}
|
||||
}
|
||||
|
||||
unsigned int check_leak_explicit_new() {
|
||||
OSArray *arr = new OSArray; // expected-note{{Operator new returns an OSObject of type OSArray with a +1 retain count}}
|
||||
return arr->getCount(); // expected-note{{Object leaked: allocated object of type OSArray is not referenced later in this execution path and has a retain count of +1}}
|
||||
// expected-warning@-1{{Potential leak of an object of type OSArray}}
|
||||
}
|
||||
|
||||
unsigned int check_leak_factory() {
|
||||
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
|
||||
return arr->getCount(); // expected-note{{Object leaked: object allocated and stored into 'arr' is not referenced later in this execution path and has a retain count of +1}}
|
||||
// expected-warning@-1{{Potential leak of an object stored into 'arr'}}
|
||||
}
|
||||
|
||||
void check_get_object() {
|
||||
OSObject::getObject();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// The number of supported attributes should never go down!
|
||||
|
||||
// CHECK: #pragma clang attribute supports 133 attributes:
|
||||
// CHECK: #pragma clang attribute supports 132 attributes:
|
||||
// CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
|
||||
// CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
|
||||
// CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
|
||||
|
@ -86,8 +86,8 @@
|
|||
// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
|
||||
// CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
|
||||
// CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
|
||||
// CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
|
||||
// CHECK-NEXT: OSReturnsRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
|
||||
// CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method)
|
||||
// CHECK-NEXT: OSReturnsRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method)
|
||||
// CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
|
||||
// CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
|
||||
// CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
|
||||
|
|
Loading…
Reference in New Issue