r193347 - Replaced duplicate code with calls to forwardInfo.
Chris Wailes
chris.wailes at gmail.com
Thu Oct 24 07:28:17 PDT 2013
Author: chris.wailes
Date: Thu Oct 24 09:28:17 2013
New Revision: 193347
URL: http://llvm.org/viewvc/llvm-project?rev=193347&view=rev
Log:
Replaced duplicate code with calls to forwardInfo.
Also made move constructor handling safer.
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=193347&r1=193346&r2=193347&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Oct 24 09:28:17 2013
@@ -592,12 +592,7 @@ void ConsumedStmtVisitor::VisitCallExpr(
// 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 @@ void ConsumedStmtVisitor::VisitCXXConstr
} 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();
-
- PropagationMap.insert(PairType(Call,
- PropagationInfo(StateMap->getState(Var), ThisType)));
-
- StateMap->setState(Var, consumed::CS_Consumed);
+ if (Entry != PropagationMap.end()) {
+ PropagationInfo PInfo = Entry->second;
- } 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::VisitCXXConstr
}
}
-
void ConsumedStmtVisitor::VisitCXXMemberCallExpr(
const CXXMemberCallExpr *Call) {
@@ -854,10 +847,7 @@ void ConsumedStmtVisitor::VisitDeclStmt(
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) {
More information about the cfe-commits
mailing list