Used OwningPtr to clean up some memory management in Consumed.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193414 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp
index c190271..e508674 100644
--- a/lib/Analysis/Consumed.cpp
+++ b/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;