r193414 - Used OwningPtr to clean up some memory management in Consumed.cpp.
Chris Wailes
chris.wailes at gmail.com
Fri Oct 25 08:33:28 PDT 2013
Author: chris.wailes
Date: Fri Oct 25 10:33:28 2013
New Revision: 193414
URL: http://llvm.org/viewvc/llvm-project?rev=193414&view=rev
Log:
Used OwningPtr to clean up some memory management in Consumed.cpp.
Modified:
cfe/trunk/lib/Analysis/Consumed.cpp
Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=193414&r1=193413&r2=193414&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Fri Oct 25 10:33:28 2013
@@ -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 @@ void ConsumedAnalyzer::determineExpected
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 @@ bool ConsumedAnalyzer::splitState(const
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 @@ bool ConsumedAnalyzer::splitState(const
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 @@ bool ConsumedAnalyzer::splitState(const
}
} else {
- delete FalseStates;
return false;
}
@@ -1338,9 +1335,7 @@ bool ConsumedAnalyzer::splitState(const
delete CurrStates;
if (*++SI)
- BlockInfo.addInfo(*SI, FalseStates);
- else
- delete FalseStates;
+ BlockInfo.addInfo(*SI, FalseStates.take());
CurrStates = NULL;
return true;
More information about the cfe-commits
mailing list