[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

Malhar Thakkar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 22:03:04 PDT 2017


malhar1995 added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2521-2523
+  deriveAllocLocation(Ctx, sym);
+  if (!AllocBinding)
+    deriveParamLocation(Ctx, sym);
----------------
I'm not sure what difference it will make if I change the ordering of the invocations of `deriveAllocLocation` and 'deriveParamLocation`.


================
Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2683
 
+  DefaultBool PerformCalleeSideParameterChecking;
+
----------------
This might be used in the future in case callee side parameter checking is added for Core Foundation and Objective-C objects.


================
Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3960-3971
+  for (unsigned idx = 0, e = FD->getNumParams(); idx != e; ++idx) {
+    const ParmVarDecl *Param = FD->getParamDecl(idx);
+    SymbolRef Sym = state->getSVal(state->getRegion(Param, LCtx)).getAsSymbol();
+
+    QualType Ty = Param->getType();
+    if (hasRCAnnotation(Param, "rc_ownership_consumed"))
+      state = setRefBinding(state, Sym,
----------------
Getting function summary and checking for `ArgEffects` doesn't seem like an option to me as currently there is no way to differentiate between Core Foundation and Generalized objects just by looking at their ArgEffects.

However, this loop results in `check-clang-analysis` failure in `retain-release.m` on lines `1140` and `2237`.


Repository:
  rL LLVM

https://reviews.llvm.org/D36441





More information about the cfe-commits mailing list