[static analyzer] Tweak RetainCountChecker's diagnostics to correctly indicate if a message was due to a property access. This can
potentially be refactored for other clients, and this is a regression from the refactoring of property acceses. llvm-svn: 144571
This commit is contained in:
parent
f2fc508d4d
commit
8e7fbcc3e4
|
@ -18,6 +18,7 @@
|
||||||
#include "clang/Basic/LangOptions.h"
|
#include "clang/Basic/LangOptions.h"
|
||||||
#include "clang/Basic/SourceManager.h"
|
#include "clang/Basic/SourceManager.h"
|
||||||
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
|
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
|
||||||
|
#include "clang/AST/ParentMap.h"
|
||||||
#include "clang/StaticAnalyzer/Core/Checker.h"
|
#include "clang/StaticAnalyzer/Core/Checker.h"
|
||||||
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
|
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
|
||||||
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
|
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
|
||||||
|
@ -1815,6 +1816,20 @@ static inline bool contains(const SmallVectorImpl<ArgEffect>& V,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isPropertyAccess(const Stmt *S, ParentMap &PM) {
|
||||||
|
unsigned maxDepth = 4;
|
||||||
|
while (S && maxDepth) {
|
||||||
|
if (const PseudoObjectExpr *PO = dyn_cast<PseudoObjectExpr>(S)) {
|
||||||
|
if (!isa<ObjCMessageExpr>(PO->getSyntacticForm()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
S = PM.getParent(S);
|
||||||
|
--maxDepth;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
|
PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
|
||||||
const ExplodedNode *PrevN,
|
const ExplodedNode *PrevN,
|
||||||
BugReporterContext &BRC,
|
BugReporterContext &BRC,
|
||||||
|
@ -1851,10 +1866,11 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
|
||||||
else
|
else
|
||||||
os << "function call";
|
os << "function call";
|
||||||
}
|
}
|
||||||
else if (isa<ObjCMessageExpr>(S)) {
|
else {
|
||||||
os << "Method";
|
assert(isa<ObjCMessageExpr>(S));
|
||||||
} else {
|
// The message expression may have between written directly or as
|
||||||
os << "Property";
|
// a property access. Lazily determine which case we are looking at.
|
||||||
|
os << (isPropertyAccess(S, N->getParentMap()) ? "Property" : "Method");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrV.getObjKind() == RetEffect::CF) {
|
if (CurrV.getObjKind() == RetEffect::CF) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// This actually still works after the pseudo-object refactor, it just
|
// This actually still works after the pseudo-object refactor, it just
|
||||||
// uses messages that say 'method' instead of 'property'. Ted wanted
|
// uses messages that say 'method' instead of 'property'. Ted wanted
|
||||||
// this xfailed and filed as a bug. rdar://problem/10402993
|
// this xfailed and filed as a bug. rdar://problem/10402993
|
||||||
// XFAIL: *
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
This file is for testing the path-sensitive notes for retain/release errors.
|
This file is for testing the path-sensitive notes for retain/release errors.
|
||||||
|
|
Loading…
Reference in New Issue