forked from OSchip/llvm-project
More attribute renaming:
- Rename 'ns_returns_owned' -> 'ns_returns_retained'. - Rename 'cf_returns_owned' -> 'cf_returns_retained'. llvm-svn: 71182
This commit is contained in:
parent
0d451813f9
commit
ba53fe98e7
|
@ -78,11 +78,11 @@ public:
|
||||||
AT_objc_exception,
|
AT_objc_exception,
|
||||||
AT_cf_releases, // Clang-specific.
|
AT_cf_releases, // Clang-specific.
|
||||||
AT_cf_retains, // Clang-specific.
|
AT_cf_retains, // Clang-specific.
|
||||||
AT_cf_returns_owned, // Clang-specific.
|
AT_cf_returns_retained, // Clang-specific.
|
||||||
AT_ns_autoreleases, // Clang-specific.
|
AT_ns_autoreleases, // Clang-specific.
|
||||||
AT_ns_releases, // Clang-specific.
|
AT_ns_releases, // Clang-specific.
|
||||||
AT_ns_retains, // Clang-specific.
|
AT_ns_retains, // Clang-specific.
|
||||||
AT_ns_returns_owned, // Clang-specific.
|
AT_ns_returns_retained, // Clang-specific.
|
||||||
AT_objc_gc,
|
AT_objc_gc,
|
||||||
AT_overloadable, // Clang-specific.
|
AT_overloadable, // Clang-specific.
|
||||||
AT_packed,
|
AT_packed,
|
||||||
|
|
|
@ -525,6 +525,65 @@ public:
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#if 0
|
||||||
|
class VISIBILITY_HIDDEN TrackValueBRVisitor : public BugReporterVisitor {
|
||||||
|
SVal V;
|
||||||
|
Stmt *S;
|
||||||
|
const MemRegion *R;
|
||||||
|
public:
|
||||||
|
TrackValueBRVisitor(SVal v, Stmt *s) : V(v), S(s), R(0) {}
|
||||||
|
|
||||||
|
PathDiagnosticPiece* VisitNode(const ExplodedNode<GRState> *N,
|
||||||
|
const ExplodedNode<GRState> *PrevN,
|
||||||
|
BugReporterContext& BRC) {
|
||||||
|
|
||||||
|
// Not at a expression?
|
||||||
|
if (!isa<PostStmt>(N->getLocation())) {
|
||||||
|
S = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S)
|
||||||
|
return VisitNodeExpr(N, PrevN, BRC);
|
||||||
|
else if (R)
|
||||||
|
return VisitNodeRegion(N, PrevN, BRC);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PathDiagnosticPiece* VisitNodeExpr(const ExplodedNode<GRState> *N,
|
||||||
|
const ExplodedNode<GRState> *PrevN,
|
||||||
|
BugReporterContext& BRC) {
|
||||||
|
|
||||||
|
assert(S);
|
||||||
|
PostStmt P = cast<PostStmt>(N->getLocation());
|
||||||
|
Stmt *X = P.getStmt();
|
||||||
|
|
||||||
|
// Generate the subexpression path.
|
||||||
|
llvm::SmallVector<Stmt*, 4> SubExprPath;
|
||||||
|
ParentMap &PM = BRC.getParentMap();
|
||||||
|
|
||||||
|
for ( ; X && X != S ; X = X.getParent(X)) {
|
||||||
|
if (isa<ParenExpr>(X))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SubExprPath.push_back(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lost track? (X is not a subexpression of S).
|
||||||
|
if (X != S) {
|
||||||
|
S = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now go down the subexpression path!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class VISIBILITY_HIDDEN TrackConstraintBRVisitor : public BugReporterVisitor {
|
class VISIBILITY_HIDDEN TrackConstraintBRVisitor : public BugReporterVisitor {
|
||||||
SVal Constraint;
|
SVal Constraint;
|
||||||
const bool Assumption;
|
const bool Assumption;
|
||||||
|
@ -533,8 +592,8 @@ public:
|
||||||
TrackConstraintBRVisitor(SVal constraint, bool assumption)
|
TrackConstraintBRVisitor(SVal constraint, bool assumption)
|
||||||
: Constraint(constraint), Assumption(assumption), isSatisfied(false) {}
|
: Constraint(constraint), Assumption(assumption), isSatisfied(false) {}
|
||||||
|
|
||||||
PathDiagnosticPiece* VisitNode(const ExplodedNode<GRState>* N,
|
PathDiagnosticPiece* VisitNode(const ExplodedNode<GRState> *N,
|
||||||
const ExplodedNode<GRState>* PrevN,
|
const ExplodedNode<GRState> *PrevN,
|
||||||
BugReporterContext& BRC) {
|
BugReporterContext& BRC) {
|
||||||
if (isSatisfied)
|
if (isSatisfied)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -624,7 +683,7 @@ static void registerTrackNullValue(BugReporterContext& BRC,
|
||||||
// base value that was dereferenced.
|
// base value that was dereferenced.
|
||||||
// assert(!V.isUnknownOrUndef());
|
// assert(!V.isUnknownOrUndef());
|
||||||
|
|
||||||
// For now just track when a symbolic value became null.
|
// Is it a symbolic value?
|
||||||
if (loc::MemRegionVal *L = dyn_cast<loc::MemRegionVal>(&V)) {
|
if (loc::MemRegionVal *L = dyn_cast<loc::MemRegionVal>(&V)) {
|
||||||
const SubRegion *R = cast<SubRegion>(L->getRegion());
|
const SubRegion *R = cast<SubRegion>(L->getRegion());
|
||||||
while (R && !isa<SymbolicRegion>(R)) {
|
while (R && !isa<SymbolicRegion>(R)) {
|
||||||
|
@ -634,8 +693,13 @@ static void registerTrackNullValue(BugReporterContext& BRC,
|
||||||
if (R) {
|
if (R) {
|
||||||
assert(isa<SymbolicRegion>(R));
|
assert(isa<SymbolicRegion>(R));
|
||||||
registerTrackConstraint(BRC, loc::MemRegionVal(R), false);
|
registerTrackConstraint(BRC, loc::MemRegionVal(R), false);
|
||||||
|
// registerTrackValue(BRC, S, V, N);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Was it a hard integer?
|
||||||
|
// if (isa<nonloc::ConcreteInt>(V))
|
||||||
|
// registerTrackValue(BRC, S, V, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -131,10 +131,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
|
||||||
if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type;
|
if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type;
|
||||||
if (!memcmp(Str, "ns_autoreleases", 15)) return AT_ns_autoreleases;
|
if (!memcmp(Str, "ns_autoreleases", 15)) return AT_ns_autoreleases;
|
||||||
break;
|
break;
|
||||||
case 16:
|
|
||||||
if (!memcmp(Str, "ns_returns_owned", 16)) return AT_ns_returns_owned;
|
|
||||||
if (!memcmp(Str, "cf_returns_owned", 16)) return AT_cf_returns_owned;
|
|
||||||
break;
|
|
||||||
case 17:
|
case 17:
|
||||||
if (!memcmp(Str, "transparent_union", 17)) return AT_transparent_union;
|
if (!memcmp(Str, "transparent_union", 17)) return AT_transparent_union;
|
||||||
if (!memcmp(Str, "analyzer_noreturn", 17)) return AT_analyzer_noreturn;
|
if (!memcmp(Str, "analyzer_noreturn", 17)) return AT_analyzer_noreturn;
|
||||||
|
@ -142,6 +138,10 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
|
||||||
case 18:
|
case 18:
|
||||||
if (!memcmp(Str, "warn_unused_result", 18)) return AT_warn_unused_result;
|
if (!memcmp(Str, "warn_unused_result", 18)) return AT_warn_unused_result;
|
||||||
break;
|
break;
|
||||||
|
case 19:
|
||||||
|
if (!memcmp(Str, "ns_returns_retained", 19)) return AT_ns_returns_retained;
|
||||||
|
if (!memcmp(Str, "cf_returns_retained", 19)) return AT_cf_returns_retained;
|
||||||
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
if (!memcmp(Str, "no_instrument_function", 22))
|
if (!memcmp(Str, "no_instrument_function", 22))
|
||||||
return AT_no_instrument_function;
|
return AT_no_instrument_function;
|
||||||
|
|
|
@ -1557,10 +1557,10 @@ static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid ownership attribute");
|
assert(0 && "invalid ownership attribute");
|
||||||
return;
|
return;
|
||||||
case AttributeList::AT_cf_returns_owned:
|
case AttributeList::AT_cf_returns_retained:
|
||||||
name = "cf_returns_owned"; break;
|
name = "cf_returns_retained"; break;
|
||||||
case AttributeList::AT_ns_returns_owned:
|
case AttributeList::AT_ns_returns_retained:
|
||||||
name = "ns_returns_owned"; break;
|
name = "ns_returns_retained"; break;
|
||||||
};
|
};
|
||||||
|
|
||||||
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
|
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
|
||||||
|
@ -1572,10 +1572,10 @@ static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid ownership attribute");
|
assert(0 && "invalid ownership attribute");
|
||||||
return;
|
return;
|
||||||
case AttributeList::AT_cf_returns_owned:
|
case AttributeList::AT_cf_returns_retained:
|
||||||
d->addAttr(::new (S.Context) CFOwnershipReturnsAttr());
|
d->addAttr(::new (S.Context) CFOwnershipReturnsAttr());
|
||||||
return;
|
return;
|
||||||
case AttributeList::AT_ns_returns_owned:
|
case AttributeList::AT_ns_returns_retained:
|
||||||
d->addAttr(::new (S.Context) NSOwnershipReturnsAttr());
|
d->addAttr(::new (S.Context) NSOwnershipReturnsAttr());
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -1676,8 +1676,8 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
|
||||||
case AttributeList::AT_ns_releases:
|
case AttributeList::AT_ns_releases:
|
||||||
case AttributeList::AT_ns_retains:
|
case AttributeList::AT_ns_retains:
|
||||||
HandleNSOwnershipAttr(D, Attr, S, true); break;
|
HandleNSOwnershipAttr(D, Attr, S, true); break;
|
||||||
case AttributeList::AT_ns_returns_owned:
|
case AttributeList::AT_ns_returns_retained:
|
||||||
case AttributeList::AT_cf_returns_owned:
|
case AttributeList::AT_cf_returns_retained:
|
||||||
HandleNSOwnershipReturnsAttr(D, Attr, S); break;
|
HandleNSOwnershipReturnsAttr(D, Attr, S); break;
|
||||||
|
|
||||||
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
|
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
|
||||||
|
|
|
@ -129,8 +129,8 @@ void f3() {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@interface TestOwnershipAttr : NSObject
|
@interface TestOwnershipAttr : NSObject
|
||||||
- (NSString*) returnsAnOwnedString __attribute__((ns_returns_owned));
|
- (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained));
|
||||||
- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_owned));
|
- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_retained));
|
||||||
- (void) myRetain:(id)__attribute__((ns_retains))obj;
|
- (void) myRetain:(id)__attribute__((ns_retains))obj;
|
||||||
- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
|
- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
|
||||||
- (void) myRelease:(id)__attribute__((ns_releases))obj;
|
- (void) myRelease:(id)__attribute__((ns_releases))obj;
|
||||||
|
|
|
@ -431,8 +431,8 @@ void rdar6704930(unsigned char *s, unsigned int length) {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@interface TestOwnershipAttr : NSObject
|
@interface TestOwnershipAttr : NSObject
|
||||||
- (NSString*) returnsAnOwnedString __attribute__((ns_returns_owned));
|
- (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained));
|
||||||
- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_owned));
|
- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_retained));
|
||||||
- (void) myRetain:(id)__attribute__((ns_retains))obj;
|
- (void) myRetain:(id)__attribute__((ns_retains))obj;
|
||||||
- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
|
- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
|
||||||
- (void) myRelease:(id)__attribute__((ns_releases))obj;
|
- (void) myRelease:(id)__attribute__((ns_releases))obj;
|
||||||
|
@ -445,7 +445,7 @@ void rdar6704930(unsigned char *s, unsigned int length) {
|
||||||
|
|
||||||
@interface TestAttrHelper : NSObject
|
@interface TestAttrHelper : NSObject
|
||||||
- (NSString*) createString:(TestOwnershipAttr*)X;
|
- (NSString*) createString:(TestOwnershipAttr*)X;
|
||||||
- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_returns_owned));
|
- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_returns_retained));
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation TestAttrHelper
|
@implementation TestAttrHelper
|
||||||
|
@ -465,7 +465,7 @@ void test_attr_1b(TestOwnershipAttr *X) {
|
||||||
NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
|
NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((ns_returns_owned))
|
__attribute__((ns_returns_retained))
|
||||||
NSString* test_attr_1c(TestOwnershipAttr *X) {
|
NSString* test_attr_1c(TestOwnershipAttr *X) {
|
||||||
NSString *str = [X returnsAnOwnedString]; // no-warning
|
NSString *str = [X returnsAnOwnedString]; // no-warning
|
||||||
return str;
|
return str;
|
||||||
|
@ -473,7 +473,7 @@ NSString* test_attr_1c(TestOwnershipAttr *X) {
|
||||||
|
|
||||||
void test_attr_1d_helper(NSString* str __attribute__((ns_retains)));
|
void test_attr_1d_helper(NSString* str __attribute__((ns_retains)));
|
||||||
|
|
||||||
__attribute__((ns_returns_owned))
|
__attribute__((ns_returns_retained))
|
||||||
NSString* test_attr_1d(TestOwnershipAttr *X) {
|
NSString* test_attr_1d(TestOwnershipAttr *X) {
|
||||||
NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
|
NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
|
||||||
test_attr_1d_helper(str);
|
test_attr_1d_helper(str);
|
||||||
|
|
Loading…
Reference in New Issue