14#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H 
   15#define LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H 
   22#include "llvm/ADT/DenseMap.h" 
   23#include "llvm/ADT/SmallVector.h" 
   24#include "llvm/ADT/StringRef.h" 
   53  using DelayedDiag = std::pair<PartialDiagnosticAt, OptionalNotes>;
 
   71                                       StringRef VariableName) {}
 
 
   83                                                  StringRef VariableName,
 
   84                                                  StringRef ExpectedState,
 
   85                                                  StringRef ObservedState) {}
 
 
   89                                            StringRef ExpectedState,
 
   90                                            StringRef ObservedState) {}
 
 
  112                                             StringRef ExpectedState,
 
  113                                             StringRef ObservedState) {}
 
 
  137                                       StringRef VariableName,
 
 
 
  143    using VarMapType = llvm::DenseMap<const VarDecl *, ConsumedState>;
 
  145        llvm::DenseMap<const CXXBindTemporaryExpr *, ConsumedState>;
 
 
  211    std::vector<std::unique_ptr<ConsumedStateMap>> StateMapsArray;
 
  212    std::vector<unsigned int> VisitOrder;
 
  218        : StateMapsArray(NumBlocks), VisitOrder(NumBlocks, 0) {
 
  219      unsigned int VisitOrderCounter = 0;
 
  220      for (
const auto BI : *SortedGraph)
 
  221        VisitOrder[BI->getBlockID()] = VisitOrderCounter++;
 
 
  228                 std::unique_ptr<ConsumedStateMap> &OwnedStateMap);
 
  230                 std::unique_ptr<ConsumedStateMap> StateMap);
 
 
  245    std::unique_ptr<ConsumedStateMap> CurrStates;
 
  251    bool splitState(
const CFGBlock *CurrBlock,
 
 
 
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
 
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
 
Defines the clang::SourceLocation class and associated facilities.
 
AnalysisDeclContext contains the context data for the function, method or block under analysis.
 
Represents a single basic block in a source-level CFG.
 
Represents binding an expression to a temporary.
 
Represents a function declaration or definition.
 
Encodes a location in the source.
 
Stmt - This represents one statement.
 
Represents a variable declaration or definition.
 
ConsumedWarningsHandlerBase & WarningsHandler
 
ConsumedState getExpectedReturnState() const
 
ConsumedAnalyzer(ConsumedWarningsHandlerBase &WarningsHandler)
 
void run(AnalysisDeclContext &AC)
Check a function's CFG for consumed violations.
 
ConsumedStateMap * borrowInfo(const CFGBlock *Block)
 
bool isBackEdgeTarget(const CFGBlock *Block)
 
ConsumedBlockInfo()=default
 
std::unique_ptr< ConsumedStateMap > getInfo(const CFGBlock *Block)
 
ConsumedBlockInfo(unsigned int NumBlocks, PostOrderCFGView *SortedGraph)
 
void addInfo(const CFGBlock *Block, ConsumedStateMap *StateMap, std::unique_ptr< ConsumedStateMap > &OwnedStateMap)
 
void discardInfo(const CFGBlock *Block)
 
bool allBackEdgesVisited(const CFGBlock *CurrBlock, const CFGBlock *TargetBlock)
 
bool isBackEdge(const CFGBlock *From, const CFGBlock *To)
 
bool isReachable() const
Return true if this block is reachable.
 
void clearTemporaries()
Clear the TmpMap.
 
ConsumedStateMap & operator=(const ConsumedStateMap &)=delete
 
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 ret...
 
void intersect(const ConsumedStateMap &Other)
Merge this state map with another map.
 
ConsumedState getState(const VarDecl *Var) const
Get the consumed state of a given variable.
 
void intersectAtLoopHead(const CFGBlock *LoopHead, const CFGBlock *LoopBack, const ConsumedStateMap *LoopBackStates, ConsumedWarningsHandlerBase &WarningsHandler)
 
void remove(const CXXBindTemporaryExpr *Tmp)
Remove the temporary value from our state map.
 
void markUnreachable()
Mark the block as unreachable.
 
bool operator!=(const ConsumedStateMap *Other) const
Tests to see if there is a mismatch in the states stored in two maps.
 
ConsumedStateMap()=default
 
ConsumedStateMap(const ConsumedStateMap &Other)
 
void setState(const VarDecl *Var, ConsumedState State)
Set the consumed state of a given variable.
 
void setSource(const Stmt *Source)
Set the source for a decision about the branching of states.
 
virtual void warnUseOfTempInInvalidState(StringRef MethodName, StringRef State, SourceLocation Loc)
Warn about use-while-consumed errors.
 
virtual void warnParamTypestateMismatch(SourceLocation LOC, StringRef ExpectedState, StringRef ObservedState)
 
virtual void warnLoopStateMismatch(SourceLocation Loc, StringRef VariableName)
Warn that a variable's state doesn't match at the entry and exit of a loop.
 
virtual void warnUseInInvalidState(StringRef MethodName, StringRef VariableName, StringRef State, SourceLocation Loc)
Warn about use-while-consumed errors.
 
virtual void emitDiagnostics()
Emit the warnings and notes left by the analysis.
 
virtual void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState, StringRef ObservedState)
Warn about return typestate mismatches.
 
virtual void warnReturnTypestateForUnconsumableType(SourceLocation Loc, StringRef TypeName)
Warn about return typestates set for unconsumable types.
 
virtual ~ConsumedWarningsHandlerBase()
 
virtual void warnParamReturnTypestateMismatch(SourceLocation Loc, StringRef VariableName, StringRef ExpectedState, StringRef ObservedState)
Warn about parameter typestate mismatches upon return.
 
std::list< DelayedDiag > DiagList
 
std::pair< PartialDiagnosticAt, OptionalNotes > DelayedDiag
 
SmallVector< PartialDiagnosticAt, 1 > OptionalNotes
 
The JSON file list parser is used to communicate input to InstallAPI.
 
@ Other
Other implicit parameter.