r189278 - Consumed analyis: Renamed *PStatus to *PInfo.
DeLesley Hutchins
delesley at google.com
Mon Aug 26 13:35:00 PDT 2013
Author: delesley
Date: Mon Aug 26 15:34:59 2013
New Revision: 189278
URL: http://llvm.org/viewvc/llvm-project?rev=189278&view=rev
Log:
Consumed analyis: Renamed *PStatus to *PInfo.
The change was made for readability, as the PropagationInfo objects don't
always contain a status. This is submitted as a separate patch because it
touches a lot of lines and I don't want it cluttering up the next patch.
Patch by chris.wailes at gmail.com.
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=189278&r1=189277&r2=189278&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Mon Aug 26 15:34:59 2013
@@ -108,7 +108,7 @@ class ConsumedStmtVisitor : public Const
ConsumedStateMap *StateMap;
MapType PropagationMap;
- void checkCallability(const PropagationInfo &PState,
+ void checkCallability(const PropagationInfo &PInfo,
const FunctionDecl *FunDecl,
const CallExpr *Call);
void forwardInfo(const Stmt *From, const Stmt *To);
@@ -142,14 +142,14 @@ public:
// TODO: When we support CallableWhenConsumed this will have to check for
// the different attributes and change the behavior bellow. (Deferred)
-void ConsumedStmtVisitor::checkCallability(const PropagationInfo &PState,
+void ConsumedStmtVisitor::checkCallability(const PropagationInfo &PInfo,
const FunctionDecl *FunDecl,
const CallExpr *Call) {
if (!FunDecl->hasAttr<CallableWhenUnconsumedAttr>()) return;
- if (PState.IsVar) {
- const VarDecl *Var = PState.getVar();
+ if (PInfo.IsVar) {
+ const VarDecl *Var = PInfo.getVar();
switch (StateMap->getState(Var)) {
case CS_Consumed:
@@ -170,7 +170,7 @@ void ConsumedStmtVisitor::checkCallabili
}
} else {
- switch (PState.getState()) {
+ switch (PInfo.getState()) {
case CS_Consumed:
Analyzer.WarningsHandler.warnUseOfTempWhileConsumed(
FunDecl->getNameAsString(), Call->getExprLoc());
@@ -254,20 +254,20 @@ void ConsumedStmtVisitor::VisitCallExpr(
continue;
}
- PropagationInfo PState = Entry->second;
+ PropagationInfo PInfo = Entry->second;
if (ParamType->isRValueReferenceType() ||
(ParamType->isLValueReferenceType() &&
!cast<LValueReferenceType>(*ParamType).isSpelledAsLValue())) {
- StateMap->setState(PState.getVar(), consumed::CS_Consumed);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Consumed);
} else if (!(ParamType.isConstQualified() ||
((ParamType->isReferenceType() ||
ParamType->isPointerType()) &&
ParamType->getPointeeType().isConstQualified()))) {
- StateMap->setState(PState.getVar(), consumed::CS_Unknown);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Unknown);
}
}
}
@@ -295,11 +295,11 @@ void ConsumedStmtVisitor::VisitCXXConstr
} else if (Constructor->isMoveConstructor()) {
- PropagationInfo PState =
+ PropagationInfo PInfo =
PropagationMap.find(Call->getArg(0))->second;
- if (PState.IsVar) {
- const VarDecl* Var = PState.getVar();
+ if (PInfo.IsVar) {
+ const VarDecl* Var = PInfo.getVar();
PropagationMap.insert(PairType(Call,
PropagationInfo(StateMap->getState(Var))));
@@ -307,7 +307,7 @@ void ConsumedStmtVisitor::VisitCXXConstr
StateMap->setState(Var, consumed::CS_Consumed);
} else {
- PropagationMap.insert(PairType(Call, PState));
+ PropagationMap.insert(PairType(Call, PInfo));
}
} else if (Constructor->isCopyConstructor()) {
@@ -331,16 +331,16 @@ void ConsumedStmtVisitor::VisitCXXMember
InfoEntry Entry = PropagationMap.find(Call->getCallee()->IgnoreParens());
if (Entry != PropagationMap.end()) {
- PropagationInfo PState = Entry->second;
+ PropagationInfo PInfo = Entry->second;
const CXXMethodDecl *MethodDecl = Call->getMethodDecl();
- checkCallability(PState, MethodDecl, Call);
+ checkCallability(PInfo, MethodDecl, Call);
- if (PState.IsVar) {
+ if (PInfo.IsVar) {
if (MethodDecl->hasAttr<ConsumesAttr>())
- StateMap->setState(PState.getVar(), consumed::CS_Consumed);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Consumed);
else if (!MethodDecl->isConst())
- StateMap->setState(PState.getVar(), consumed::CS_Unknown);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Unknown);
}
}
}
@@ -359,46 +359,46 @@ void ConsumedStmtVisitor::VisitCXXOperat
InfoEntry LEntry = PropagationMap.find(Call->getArg(0));
InfoEntry REntry = PropagationMap.find(Call->getArg(1));
- PropagationInfo LPState, RPState;
+ PropagationInfo LPInfo, RPInfo;
if (LEntry != PropagationMap.end() &&
REntry != PropagationMap.end()) {
- LPState = LEntry->second;
- RPState = REntry->second;
+ LPInfo = LEntry->second;
+ RPInfo = REntry->second;
- if (LPState.IsVar && RPState.IsVar) {
- StateMap->setState(LPState.getVar(),
- StateMap->getState(RPState.getVar()));
+ if (LPInfo.IsVar && RPInfo.IsVar) {
+ StateMap->setState(LPInfo.getVar(),
+ StateMap->getState(RPInfo.getVar()));
- StateMap->setState(RPState.getVar(), consumed::CS_Consumed);
+ StateMap->setState(RPInfo.getVar(), consumed::CS_Consumed);
- PropagationMap.insert(PairType(Call, LPState));
+ PropagationMap.insert(PairType(Call, LPInfo));
- } else if (LPState.IsVar && !RPState.IsVar) {
- StateMap->setState(LPState.getVar(), RPState.getState());
+ } else if (LPInfo.IsVar && !RPInfo.IsVar) {
+ StateMap->setState(LPInfo.getVar(), RPInfo.getState());
- PropagationMap.insert(PairType(Call, LPState));
+ PropagationMap.insert(PairType(Call, LPInfo));
- } else if (!LPState.IsVar && RPState.IsVar) {
+ } else if (!LPInfo.IsVar && RPInfo.IsVar) {
PropagationMap.insert(PairType(Call,
- PropagationInfo(StateMap->getState(RPState.getVar()))));
+ PropagationInfo(StateMap->getState(RPInfo.getVar()))));
- StateMap->setState(RPState.getVar(), consumed::CS_Consumed);
+ StateMap->setState(RPInfo.getVar(), consumed::CS_Consumed);
} else {
- PropagationMap.insert(PairType(Call, RPState));
+ PropagationMap.insert(PairType(Call, RPInfo));
}
} else if (LEntry != PropagationMap.end() &&
REntry == PropagationMap.end()) {
- LPState = LEntry->second;
+ LPInfo = LEntry->second;
- if (LPState.IsVar) {
- StateMap->setState(LPState.getVar(), consumed::CS_Unknown);
+ if (LPInfo.IsVar) {
+ StateMap->setState(LPInfo.getVar(), consumed::CS_Unknown);
- PropagationMap.insert(PairType(Call, LPState));
+ PropagationMap.insert(PairType(Call, LPInfo));
} else {
PropagationMap.insert(PairType(Call,
@@ -408,10 +408,10 @@ void ConsumedStmtVisitor::VisitCXXOperat
} else if (LEntry == PropagationMap.end() &&
REntry != PropagationMap.end()) {
- RPState = REntry->second;
+ RPInfo = REntry->second;
- if (RPState.IsVar) {
- const VarDecl *Var = RPState.getVar();
+ if (RPInfo.IsVar) {
+ const VarDecl *Var = RPInfo.getVar();
PropagationMap.insert(PairType(Call,
PropagationInfo(StateMap->getState(Var))));
@@ -419,7 +419,7 @@ void ConsumedStmtVisitor::VisitCXXOperat
StateMap->setState(Var, consumed::CS_Consumed);
} else {
- PropagationMap.insert(PairType(Call, RPState));
+ PropagationMap.insert(PairType(Call, RPInfo));
}
}
@@ -430,20 +430,20 @@ void ConsumedStmtVisitor::VisitCXXOperat
InfoEntry Entry = PropagationMap.find(Call->getArg(0));
if (Entry != PropagationMap.end()) {
- PropagationInfo PState = Entry->second;
+ PropagationInfo PInfo = Entry->second;
- checkCallability(PState, FunDecl, Call);
+ checkCallability(PInfo, FunDecl, Call);
- if (PState.IsVar) {
+ if (PInfo.IsVar) {
if (FunDecl->hasAttr<ConsumesAttr>()) {
// Handle consuming operators.
- StateMap->setState(PState.getVar(), consumed::CS_Consumed);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Consumed);
} else if (const CXXMethodDecl *MethodDecl =
dyn_cast_or_null<CXXMethodDecl>(FunDecl)) {
// Handle non-constant member operators.
if (!MethodDecl->isConst())
- StateMap->setState(PState.getVar(), consumed::CS_Unknown);
+ StateMap->setState(PInfo.getVar(), consumed::CS_Unknown);
}
}
}
@@ -492,11 +492,11 @@ void ConsumedStmtVisitor::VisitUnaryOper
void ConsumedStmtVisitor::VisitVarDecl(const VarDecl *Var) {
if (Analyzer.isConsumableType(Var->getType())) {
- PropagationInfo PState =
+ PropagationInfo PInfo =
PropagationMap.find(Var->getInit())->second;
- StateMap->setState(Var, PState.IsVar ?
- StateMap->getState(PState.getVar()) : PState.getState());
+ StateMap->setState(Var, PInfo.IsVar ?
+ StateMap->getState(PInfo.getVar()) : PInfo.getState());
}
}
} // end anonymous::ConsumedStmtVisitor
More information about the cfe-commits
mailing list