summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
index 87c1ad9edb8..488cf6d3eb8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -502,25 +502,6 @@ static Optional<RefVal> refValFromRetEffect(RetEffect RE,
return None;
}
-static bool isPointerToObject(QualType QT) {
- QualType PT = QT->getPointeeType();
- if (!PT.isNull())
- if (PT->getAsCXXRecordDecl())
- return true;
- return false;
-}
-
-/// Whether the tracked value should be escaped on a given call.
-/// OSObjects are escaped when passed to void * / etc.
-static bool shouldEscapeArgumentOnCall(const CallEvent &CE, unsigned ArgIdx,
- const RefVal *TrackedValue) {
- if (TrackedValue->getObjKind() != RetEffect::OS)
- return false;
- if (ArgIdx >= CE.parameters().size())
- return false;
- return !isPointerToObject(CE.parameters()[ArgIdx]->getType());
-}
-
// We don't always get the exact modeling of the function with regards to the
// retain count checker even when the function is inlined. For example, we need
// to stop tracking the symbols which were marked with StopTrackingHard.
@@ -531,16 +512,11 @@ void RetainCountChecker::processSummaryOfInlined(const RetainSummary &Summ,
// Evaluate the effect of the arguments.
for (unsigned idx = 0, e = CallOrMsg.getNumArgs(); idx != e; ++idx) {
- SVal V = CallOrMsg.getArgSVal(idx);
-
- if (SymbolRef Sym = V.getAsLocSymbol()) {
- bool ShouldRemoveBinding = Summ.getArg(idx) == StopTrackingHard;
- if (const RefVal *T = getRefBinding(state, Sym))
- if (shouldEscapeArgumentOnCall(CallOrMsg, idx, T))
- ShouldRemoveBinding = true;
-
- if (ShouldRemoveBinding)
+ if (Summ.getArg(idx) == StopTrackingHard) {
+ SVal V = CallOrMsg.getArgSVal(idx);
+ if (SymbolRef Sym = V.getAsLocSymbol()) {
state = removeRefBinding(state, Sym);
+ }
}
}
@@ -598,6 +574,25 @@ static ProgramStateRef updateOutParameter(ProgramStateRef State,
return State;
}
+static bool isPointerToObject(QualType QT) {
+ QualType PT = QT->getPointeeType();
+ if (!PT.isNull())
+ if (PT->getAsCXXRecordDecl())
+ return true;
+ return false;
+}
+
+/// Whether the tracked value should be escaped on a given call.
+/// OSObjects are escaped when passed to void * / etc.
+static bool shouldEscapeArgumentOnCall(const CallEvent &CE, unsigned ArgIdx,
+ const RefVal *TrackedValue) {
+ if (TrackedValue->getObjKind() != RetEffect::OS)
+ return false;
+ if (ArgIdx >= CE.parameters().size())
+ return false;
+ return !isPointerToObject(CE.parameters()[ArgIdx]->getType());
+}
+
void RetainCountChecker::checkSummary(const RetainSummary &Summ,
const CallEvent &CallOrMsg,
CheckerContext &C) const {
OpenPOWER on IntegriCloud