[PATCH] D56072: [analyzer] [RetainCountChecker] Remove redundant enum UnarySummaryKind
George Karpenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 10 10:20:52 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350861: [analyzer] [RetainCountChecker] Remove redundant enum UnarySummaryKind (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D56072?vs=179485&id=181088#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56072/new/
https://reviews.llvm.org/D56072
Files:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
@@ -194,7 +194,7 @@
} else if(FName == "NSMakeCollectable") {
// Handle: id NSMakeCollectable(CFTypeRef)
AllowAnnotations = false;
- return RetTy->isObjCIdType() ? getUnarySummary(FT, cfmakecollectable)
+ return RetTy->isObjCIdType() ? getUnarySummary(FT, DoNothing)
: getPersistentStopSummary();
} else if (FName == "CMBufferQueueDequeueAndRetain" ||
FName == "CMBufferQueueDequeueIfDataReadyAndRetain") {
@@ -307,16 +307,16 @@
// We want to ignore such annotation.
AllowAnnotations = false;
- return getUnarySummary(FT, cfretain);
+ return getUnarySummary(FT, IncRef);
} else if (isAutorelease(FD, FName)) {
// The headers use cf_consumed, but we can fully model CFAutorelease
// ourselves.
AllowAnnotations = false;
- return getUnarySummary(FT, cfautorelease);
+ return getUnarySummary(FT, Autorelease);
} else if (isMakeCollectable(FName)) {
AllowAnnotations = false;
- return getUnarySummary(FT, cfmakecollectable);
+ return getUnarySummary(FT, DoNothing);
} else {
return getCFCreateGetRuleSummary(FD);
}
@@ -326,7 +326,7 @@
if (cocoa::isRefType(RetTy, "CG", FName) ||
cocoa::isRefType(RetTy, "CV", FName)) {
if (isRetain(FD, FName))
- return getUnarySummary(FT, cfretain);
+ return getUnarySummary(FT, IncRef);
else
return getCFCreateGetRuleSummary(FD);
}
@@ -350,7 +350,7 @@
FName = FName.substr(FName.startswith("CGCF") ? 4 : 2);
if (isRelease(FD, FName))
- return getUnarySummary(FT, cfrelease);
+ return getUnarySummary(FT, DecRef);
else {
assert(ScratchArgs.isEmpty());
// Remaining CoreFoundation and CoreGraphics functions.
@@ -644,11 +644,9 @@
return None;
}
-// TODO: UnaryFuncKind is a very funny enum, it really should not exist:
-// just pass the needed effect directly!
const RetainSummary *
RetainSummaryManager::getUnarySummary(const FunctionType* FT,
- UnaryFuncKind func) {
+ ArgEffectKind AE) {
// Unary functions have no arg effects by definition.
ArgEffects ScratchArgs(AF.getEmptyMap());
@@ -659,13 +657,7 @@
if (!FTP || FTP->getNumParams() != 1)
return getPersistentStopSummary();
- ArgEffect Effect(DoNothing, ObjKind::CF);
- switch (func) {
- case cfretain: Effect = Effect.withKind(IncRef); break;
- case cfrelease: Effect = Effect.withKind(DecRef); break;
- case cfautorelease: Effect = Effect.withKind(Autorelease); break;
- case cfmakecollectable: Effect = Effect.withKind(DoNothing); break;
- }
+ ArgEffect Effect(AE, ObjKind::CF);
ScratchArgs = AF.add(ScratchArgs, 0, Effect);
return getPersistentSummary(RetEffect::MakeNoRet(),
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
===================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
@@ -537,10 +537,8 @@
/// Free the OS object.
const RetainSummary *getOSSummaryFreeRule(const FunctionDecl *FD);
- enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable };
-
const RetainSummary *getUnarySummary(const FunctionType* FT,
- UnaryFuncKind func);
+ ArgEffectKind AE);
const RetainSummary *getCFSummaryCreateRule(const FunctionDecl *FD);
const RetainSummary *getCFSummaryGetRule(const FunctionDecl *FD);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56072.181088.patch
Type: text/x-patch
Size: 3960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190110/8241b8a7/attachment.bin>
More information about the llvm-commits
mailing list