clang 8.0.0

Public Member Functions | Protected Attributes | List of all members
clang::consumed::ConsumedStateMap Class Reference

`#include "clang/Analysis/Analyses/Consumed.h"`

Collaboration diagram for clang::consumed::ConsumedStateMap:
[legend]

## Public Member Functions
| ConsumedStateMap ()=default
| ConsumedStateMap (const ConsumedStateMap &Other)
void | checkParamsForReturnTypestate (SourceLocation BlameLoc, ConsumedWarningsHandlerBase &WarningsHandler) const
| Warn if any of the parameters being tracked are not in the state they were declared to be in upon return from a function. More...
void | clearTemporaries ()
| Clear the TmpMap. More...
ConsumedState | getState (const VarDecl *Var) const
| Get the consumed state of a given variable. More...
ConsumedState | getState (const CXXBindTemporaryExpr *Tmp) const
| Get the consumed state of a given temporary value. More...
void | intersect (const ConsumedStateMap &Other)
| Merge this state map with another map. More...
void | intersectAtLoopHead (const CFGBlock *LoopHead, const CFGBlock *LoopBack, const ConsumedStateMap *LoopBackStates, ConsumedWarningsHandlerBase &WarningsHandler)
bool | isReachable () const
| Return true if this block is reachable. More...
void | markUnreachable ()
| Mark the block as unreachable. More...
void | setSource (const Stmt *Source)
| Set the source for a decision about the branching of states. More...
void | setState (const VarDecl *Var, ConsumedState State)
| Set the consumed state of a given variable. More...
void | setState (const CXXBindTemporaryExpr *Tmp, ConsumedState State)
| Set the consumed state of a given temporary value. More...
void | remove (const CXXBindTemporaryExpr *Tmp)
| Remove the temporary value from our state map. More...
bool | operator!= (const ConsumedStateMap *Other) const
| Tests to see if there is a mismatch in the states stored in two maps. More...

## Protected Attributes
bool | Reachable = true
const Stmt * | From = nullptr
VarMapType | VarMap
TmpMapType | TmpMap

## Detailed Description

Definition at line 143 of file Consumed.h.

## Constructor & Destructor Documentation

## ◆ ConsumedStateMap() [1/2]

clang::consumed::ConsumedStateMap::ConsumedStateMap | ( |  | ) |
| default

## ◆ ConsumedStateMap() [2/2]

clang::consumed::ConsumedStateMap::ConsumedStateMap | ( | const ConsumedStateMap & | Other | ) |
| inline

Definition at line 156 of file Consumed.h.

## Member Function Documentation

## ◆ checkParamsForReturnTypestate()

void ConsumedStateMap::checkParamsForReturnTypestate | ( | SourceLocation | BlameLoc,
|  | ConsumedWarningsHandlerBase & | WarningsHandler
| ) |  | const

Warn if any of the parameters being tracked are not in the state they were declared to be in upon return from a function.

Definition at line 1090 of file Consumed.cpp.

References mapReturnTypestateAttrState(), stateToString(), and clang::consumed::ConsumedWarningsHandlerBase::warnParamReturnTypestateMismatch().

## ◆ clearTemporaries()

void ConsumedStateMap::clearTemporaries | ( |  | ) |

Clear the TmpMap.

Definition at line 1110 of file Consumed.cpp.

## ◆ getState() [1/2]

ConsumedState ConsumedStateMap::getState | ( | const VarDecl * | Var | ) | const

Get the consumed state of a given variable.

Definition at line 1114 of file Consumed.cpp.

References clang::consumed::CS_None.

Referenced by clang::consumed::PropagationInfo::getAsState(), splitVarStateForIf(), and splitVarStateForIfBinOp().

## ◆ getState() [2/2]

ConsumedState ConsumedStateMap::getState | ( | const CXXBindTemporaryExpr * | Tmp | ) | const

Get the consumed state of a given temporary value.

Definition at line 1124 of file Consumed.cpp.

References clang::consumed::CS_None.

## ◆ intersect()

void ConsumedStateMap::intersect | ( | const ConsumedStateMap & | Other | ) |

Merge this state map with another map.

Definition at line 1133 of file Consumed.cpp.

References clang::consumed::CS_None, clang::consumed::CS_Unknown, From, Reachable, and VarMap.

## ◆ intersectAtLoopHead()

void ConsumedStateMap::intersectAtLoopHead | ( | const CFGBlock * | LoopHead,
|  | const CFGBlock * | LoopBack,
|  | const ConsumedStateMap * | LoopBackStates,
|  | ConsumedWarningsHandlerBase & | WarningsHandler
| ) |  |

Definition at line 1152 of file Consumed.cpp.

References clang::consumed::CS_None, clang::consumed::CS_Unknown, getLastStmtLoc(), VarMap, and clang::consumed::ConsumedWarningsHandlerBase::warnLoopStateMismatch().

## ◆ isReachable()

bool clang::consumed::ConsumedStateMap::isReachable | ( |  | ) | const
| inline

Return true if this block is reachable.

Definition at line 182 of file Consumed.h.

## ◆ markUnreachable()

void ConsumedStateMap::markUnreachable | ( |  | ) |

Mark the block as unreachable.

Definition at line 1173 of file Consumed.cpp.

Referenced by splitVarStateForIf(), and splitVarStateForIfBinOp().

## ◆ operator!=()

bool ConsumedStateMap::operator!= | ( | const ConsumedStateMap * | Other | ) | const

Tests to see if there is a mismatch in the states stored in two maps.

Parameters

  Other | – The second map to compare against.

Definition at line 1192 of file Consumed.cpp.

References clang::consumed::CS_None, clang::consumed::CS_Unknown, clang::Type::getAsCXXRecordDecl(), clang::QualType::getAsString(), clang::Decl::getAttr(), clang::FunctionDecl::getCallResultType(), clang::CFGTerminator::getStmt(), clang::CFGBlock::getTerminator(), clang::consumed::PropagationInfo::getVarTest(), clang::Decl::hasAttr(), invertConsumedUnconsumed(), isAutoCastType(), clang::consumed::PropagationInfo::isBinTest(), isConsumableType(), clang::consumed::PropagationInfo::isValid(), clang::consumed::PropagationInfo::isVarTest(), mapConsumableAttrState(), mapReturnTypestateAttrState(), splitVarStateForIf(), splitVarStateForIfBinOp(), clang::CFGBlock::succ_begin(), clang::consumed::PropagationInfo::testSourceNode(), and VarMap.

## ◆ remove()

void ConsumedStateMap::remove | ( | const CXXBindTemporaryExpr * | Tmp | ) |

Remove the temporary value from our state map.

Definition at line 1188 of file Consumed.cpp.

## ◆ setSource()

void clang::consumed::ConsumedStateMap::setSource | ( | const Stmt * | Source | ) |
| inline

Set the source for a decision about the branching of states.

Parameters

  Source | – The statement that was the origin of a branching decision.

Definition at line 190 of file Consumed.h.

References clang::operator!=(), and State.

## ◆ setState() [1/2]

void ConsumedStateMap::setState | ( | const VarDecl * | Var,
|  | ConsumedState | State
| ) |  |

Set the consumed state of a given variable.

Definition at line 1179 of file Consumed.cpp.

References State.

Referenced by setStateForVarOrTmp(), splitVarStateForIf(), and splitVarStateForIfBinOp().

## ◆ setState() [2/2]

void ConsumedStateMap::setState | ( | const CXXBindTemporaryExpr * | Tmp,
|  | ConsumedState | State
| ) |  |

Set the consumed state of a given temporary value.

Definition at line 1183 of file Consumed.cpp.

References State.

## Member Data Documentation

## ◆ From

const Stmt* clang::consumed::ConsumedStateMap::From = nullptr
| protected

Definition at line 150 of file Consumed.h.

Referenced by intersect().

## ◆ Reachable

bool clang::consumed::ConsumedStateMap::Reachable = true
| protected

Definition at line 149 of file Consumed.h.

Referenced by intersect().

## ◆ TmpMap

TmpMapType clang::consumed::ConsumedStateMap::TmpMap
| protected

Definition at line 152 of file Consumed.h.

## ◆ VarMap

VarMapType clang::consumed::ConsumedStateMap::VarMap
| protected

Definition at line 151 of file Consumed.h.

Referenced by intersect(), intersectAtLoopHead(), and operator!=().

The documentation for this class was generated from the following files:

- include/clang/Analysis/Analyses/Consumed.h
- lib/Analysis/Consumed.cpp