Skip to content

Commit cd5115b

Browse files
committed
1 parent 4d80f19 commit cd5115b

File tree

5 files changed

+7
-57
lines changed

5 files changed

+7
-57
lines changed

clang/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ cscope.out
2929
#==============================================================================#
3030
# Directories to ignore (do not add trailing '/'s, they skip symlinks).
3131
#==============================================================================#
32-
# Clang extra user tools, which is tracked independently (clang-tools-extra).
33-
tools/extra
3432
# Sphinx build products
3533
docs/_build
3634
docs/analyzer/_build

clang/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ class RetainSummaryManager {
530530
/// Decrement the reference count on OS object.
531531
const RetainSummary *getOSSummaryReleaseRule(const FunctionDecl *FD);
532532

533-
/// Free the OS object.
534-
const RetainSummary *getOSSummaryFreeRule(const FunctionDecl *FD);
535533

536534
enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable };
537535

clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
124124
}
125125

126126
const IdentifierInfo *II = FD->getIdentifier();
127+
if (!II)
128+
return getDefaultSummary();
127129

128-
StringRef FName = II ? II->getName() : "";
130+
StringRef FName = II->getName();
129131

130132
// Strip away preceding '_'. Doing this here will effect all the checks
131133
// down below.
@@ -302,12 +304,6 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
302304

303305
if (FName == "retain")
304306
return getOSSummaryRetainRule(FD);
305-
306-
if (FName == "free")
307-
return getOSSummaryFreeRule(FD);
308-
309-
if (MD->getOverloadedOperator() == OO_New)
310-
return getOSSummaryCreateRule(MD);
311307
}
312308
}
313309

@@ -495,11 +491,9 @@ RetainSummaryManager::getSummary(const CallEvent &Call,
495491
case CE_CXXConstructor:
496492
Summ = getFunctionSummary(cast<CXXConstructorCall>(Call).getDecl());
497493
break;
498-
case CE_CXXAllocator:
499-
Summ = getFunctionSummary(cast<CXXAllocatorCall>(Call).getDecl());
500-
break;
501494
case CE_Block:
502495
case CE_CXXDestructor:
496+
case CE_CXXAllocator:
503497
// FIXME: These calls are currently unsupported.
504498
return getPersistentStopSummary();
505499
case CE_ObjCMessage: {
@@ -624,14 +618,6 @@ RetainSummaryManager::getOSSummaryReleaseRule(const FunctionDecl *FD) {
624618
/*ThisEff=*/DecRef);
625619
}
626620

627-
const RetainSummary *
628-
RetainSummaryManager::getOSSummaryFreeRule(const FunctionDecl *FD) {
629-
return getPersistentSummary(RetEffect::MakeNoRet(),
630-
/*ReceiverEff=*/DoNothing,
631-
/*DefaultEff=*/DoNothing,
632-
/*ThisEff=*/Dealloc);
633-
}
634-
635621
const RetainSummary *
636622
RetainSummaryManager::getOSSummaryCreateRule(const FunctionDecl *FD) {
637623
return getPersistentSummary(RetEffect::MakeOwned(RetEffect::OS));

clang/test/Analysis/osobject-retain-release.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct OSMetaClass;
1414
struct OSObject {
1515
virtual void retain();
1616
virtual void release() {};
17-
virtual void free();
1817
virtual ~OSObject(){}
1918

2019
unsigned int foo() { return 42; }
@@ -24,9 +23,6 @@ struct OSObject {
2423
static OSObject *getObject();
2524
static OSObject *GetObject();
2625

27-
28-
static void * operator new(unsigned long size);
29-
3026
static const OSMetaClass * const metaClass;
3127
};
3228

@@ -66,34 +62,6 @@ struct OSMetaClassBase {
6662
static OSObject *safeMetaCast(const OSObject *inst, const OSMetaClass *meta);
6763
};
6864

69-
void check_free_no_error() {
70-
OSArray *arr = OSArray::withCapacity(10);
71-
arr->retain();
72-
arr->retain();
73-
arr->retain();
74-
arr->free();
75-
}
76-
77-
void check_free_use_after_free() {
78-
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
79-
arr->retain(); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
80-
arr->free(); // expected-note{{Object released}}
81-
arr->retain(); // expected-warning{{Reference-counted object is used after it is released}}
82-
// expected-note@-1{{Reference-counted object is used after it is released}}
83-
}
84-
85-
unsigned int check_leak_explicit_new() {
86-
OSArray *arr = new OSArray; // expected-note{{Operator new returns an OSObject of type OSArray with a +1 retain count}}
87-
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}}
88-
// expected-warning@-1{{Potential leak of an object of type OSArray}}
89-
}
90-
91-
unsigned int check_leak_factory() {
92-
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
93-
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}}
94-
// expected-warning@-1{{Potential leak of an object stored into 'arr'}}
95-
}
96-
9765
void check_get_object() {
9866
OSObject::getObject();
9967
}

clang/test/Misc/pragma-attribute-supported-attributes-list.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// The number of supported attributes should never go down!
44

5-
// CHECK: #pragma clang attribute supports 133 attributes:
5+
// CHECK: #pragma clang attribute supports 132 attributes:
66
// CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
77
// CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
88
// CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -86,8 +86,8 @@
8686
// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
8787
// CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
8888
// CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
89-
// CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
90-
// CHECK-NEXT: OSReturnsRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
89+
// CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method)
90+
// CHECK-NEXT: OSReturnsRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method)
9191
// CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
9292
// CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
9393
// CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)

0 commit comments

Comments
 (0)