[PATCH] Memory management cleanup in Consumed.cpp
Chris Wailes
chris.wailes at gmail.com
Thu Oct 24 08:05:06 PDT 2013
Hi delesley, dblaikie, aaron.ballman,
Used an OwningPtr to clean up some memory management code in Consumed.cpp.
http://llvm-reviews.chandlerc.com/D2016
Files:
lib/Analysis/Consumed.cpp
Index: lib/Analysis/Consumed.cpp
===================================================================
--- lib/Analysis/Consumed.cpp
+++ lib/Analysis/Consumed.cpp
@@ -27,6 +27,7 @@
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
@@ -1259,7 +1260,7 @@
bool ConsumedAnalyzer::splitState(const CFGBlock *CurrBlock,
const ConsumedStmtVisitor &Visitor) {
- ConsumedStateMap *FalseStates = new ConsumedStateMap(*CurrStates);
+ OwningPtr<ConsumedStateMap> FalseStates(new ConsumedStateMap(*CurrStates));
PropagationInfo PInfo;
if (const IfStmt *IfNode =
@@ -1274,15 +1275,15 @@
if (PInfo.isTest()) {
CurrStates->setSource(Cond);
FalseStates->setSource(Cond);
- splitVarStateForIf(IfNode, PInfo.getTest(), CurrStates, FalseStates);
+ splitVarStateForIf(IfNode, PInfo.getTest(), CurrStates,
+ FalseStates.get());
} else if (PInfo.isBinTest()) {
CurrStates->setSource(PInfo.testSourceNode());
FalseStates->setSource(PInfo.testSourceNode());
- splitVarStateForIfBinOp(PInfo, CurrStates, FalseStates);
+ splitVarStateForIfBinOp(PInfo, CurrStates, FalseStates.get());
} else {
- delete FalseStates;
return false;
}
@@ -1294,13 +1295,10 @@
if ((BinOp = dyn_cast_or_null<BinaryOperator>(BinOp->getLHS()))) {
PInfo = Visitor.getInfo(BinOp->getRHS());
- if (!PInfo.isTest()) {
- delete FalseStates;
+ if (!PInfo.isTest())
return false;
- }
} else {
- delete FalseStates;
return false;
}
}
@@ -1326,7 +1324,6 @@
}
} else {
- delete FalseStates;
return false;
}
@@ -1338,9 +1335,7 @@
delete CurrStates;
if (*++SI)
- BlockInfo.addInfo(*SI, FalseStates);
- else
- delete FalseStates;
+ BlockInfo.addInfo(*SI, FalseStates.take());
CurrStates = NULL;
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2016.1.patch
Type: text/x-patch
Size: 2200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131024/0cb2274f/attachment.bin>
More information about the cfe-commits
mailing list