r350865 - [analyzer] [NFC] Reduce redundancy in RetainSummaryManager by using a function
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 10 10:15:30 PST 2019
Author: george.karpenkov
Date: Thu Jan 10 10:15:30 2019
New Revision: 350865
URL: http://llvm.org/viewvc/llvm-project?rev=350865&view=rev
Log:
[analyzer] [NFC] Reduce redundancy in RetainSummaryManager by using a function
Differential Revision: https://reviews.llvm.org/D56282
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350865&r1=350864&r2=350865&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 10 10:15:30 2019
@@ -641,10 +641,9 @@ class RetainSummaryManager {
/// Apply the annotation of {@code pd} in function {@code FD}
/// to the resulting summary stored in out-parameter {@code Template}.
/// \return whether an annotation was applied.
- bool applyFunctionParamAnnotationEffect(const ParmVarDecl *pd,
- unsigned parm_idx,
- const FunctionDecl *FD,
- RetainSummaryTemplate &Template);
+ bool applyParamAnnotationEffect(const ParmVarDecl *pd, unsigned parm_idx,
+ const NamedDecl *FD,
+ RetainSummaryTemplate &Template);
public:
RetainSummaryManager(ASTContext &ctx,
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350865&r1=350864&r2=350865&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 10:15:30 2019
@@ -811,8 +811,8 @@ RetainSummaryManager::getRetEffectFromAn
return None;
}
-bool RetainSummaryManager::applyFunctionParamAnnotationEffect(
- const ParmVarDecl *pd, unsigned parm_idx, const FunctionDecl *FD,
+bool RetainSummaryManager::applyParamAnnotationEffect(
+ const ParmVarDecl *pd, unsigned parm_idx, const NamedDecl *FD,
RetainSummaryTemplate &Template) {
QualType QT = pd->getType();
if (auto K =
@@ -832,7 +832,7 @@ bool RetainSummaryManager::applyFunction
if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
for (const auto *OD : MD->overridden_methods()) {
const ParmVarDecl *OP = OD->parameters()[parm_idx];
- if (applyFunctionParamAnnotationEffect(OP, parm_idx, OD, Template))
+ if (applyParamAnnotationEffect(OP, parm_idx, OD, Template))
return true;
}
}
@@ -853,10 +853,8 @@ RetainSummaryManager::updateSummaryFromA
// Effects on the parameters.
unsigned parm_idx = 0;
for (auto pi = FD->param_begin(),
- pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) {
- const ParmVarDecl *pd = *pi;
- applyFunctionParamAnnotationEffect(pd, parm_idx, FD, Template);
- }
+ pe = FD->param_end(); pi != pe; ++pi, ++parm_idx)
+ applyParamAnnotationEffect(*pi, parm_idx, FD, Template);
QualType RetTy = FD->getReturnType();
if (Optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, FD))
@@ -882,19 +880,9 @@ RetainSummaryManager::updateSummaryFromA
// Effects on the parameters.
unsigned parm_idx = 0;
for (auto pi = MD->param_begin(), pe = MD->param_end(); pi != pe;
- ++pi, ++parm_idx) {
- const ParmVarDecl *pd = *pi;
- QualType QT = pd->getType();
- if (auto K =
- hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr>(
- pd, QT)) {
- Template->addArg(AF, parm_idx, ArgEffect(DecRef, *K));
- } else if (auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr>(pd, QT)) {
- Template->addArg(AF, parm_idx, ArgEffect(RetainedOutParameter, *K));
- } else if (auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr>(pd, QT)) {
- Template->addArg(AF, parm_idx, ArgEffect(UnretainedOutParameter, *K));
- }
- }
+ ++pi, ++parm_idx)
+ applyParamAnnotationEffect(*pi, parm_idx, MD, Template);
+
QualType RetTy = MD->getReturnType();
if (Optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, MD))
Template->setRetEffect(*RetE);
More information about the cfe-commits
mailing list