Replaced duplicate code with calls to forwardInfo.
Also made move constructor handling safer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193347 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp
index ed806ce..c190271 100644
--- a/lib/Analysis/Consumed.cpp
+++ b/lib/Analysis/Consumed.cpp
@@ -592,12 +592,7 @@
// Special case for the std::move function.
// TODO: Make this more specific. (Deferred)
if (FunDecl->getNameAsString() == "move") {
- InfoEntry Entry = PropagationMap.find(Call->getArg(0));
-
- if (Entry != PropagationMap.end()) {
- PropagationMap.insert(PairType(Call, Entry->second));
- }
-
+ forwardInfo(Call->getArg(0), Call);
return;
}
@@ -690,26 +685,25 @@
} else if (Constructor->isMoveConstructor()) {
- PropagationInfo PInfo =
- PropagationMap.find(Call->getArg(0))->second;
+ InfoEntry Entry = PropagationMap.find(Call->getArg(0));
- if (PInfo.isVar()) {
- const VarDecl* Var = PInfo.getVar();
+ if (Entry != PropagationMap.end()) {
+ PropagationInfo PInfo = Entry->second;
- PropagationMap.insert(PairType(Call,
- PropagationInfo(StateMap->getState(Var), ThisType)));
-
- StateMap->setState(Var, consumed::CS_Consumed);
-
- } else {
- PropagationMap.insert(PairType(Call, PInfo));
+ if (PInfo.isVar()) {
+ const VarDecl* Var = PInfo.getVar();
+
+ PropagationMap.insert(PairType(Call,
+ PropagationInfo(StateMap->getState(Var), ThisType)));
+
+ StateMap->setState(Var, consumed::CS_Consumed);
+
+ } else {
+ PropagationMap.insert(PairType(Call, PInfo));
+ }
}
-
} else if (Constructor->isCopyConstructor()) {
- MapType::iterator Entry = PropagationMap.find(Call->getArg(0));
-
- if (Entry != PropagationMap.end())
- PropagationMap.insert(PairType(Call, Entry->second));
+ forwardInfo(Call->getArg(0), Call);
} else {
ConsumedState RetState = mapConsumableAttrState(ThisType);
@@ -717,7 +711,6 @@
}
}
-
void ConsumedStmtVisitor::VisitCXXMemberCallExpr(
const CXXMemberCallExpr *Call) {
@@ -854,10 +847,7 @@
void ConsumedStmtVisitor::VisitMaterializeTemporaryExpr(
const MaterializeTemporaryExpr *Temp) {
- InfoEntry Entry = PropagationMap.find(Temp->GetTemporaryExpr());
-
- if (Entry != PropagationMap.end())
- PropagationMap.insert(PairType(Temp, Entry->second));
+ forwardInfo(Temp->GetTemporaryExpr(), Temp);
}
void ConsumedStmtVisitor::VisitMemberExpr(const MemberExpr *MExpr) {