15 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H 16 #define LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H 40 typedef std::pair<PartialDiagnosticAt, OptionalNotes>
DelayedDiag;
60 StringRef VariableName) {}
72 StringRef VariableName,
73 StringRef ExpectedState,
74 StringRef ObservedState) {}
78 StringRef ExpectedState,
79 StringRef ObservedState) {}
89 StringRef TypeName) {}
101 StringRef ExpectedState,
102 StringRef ObservedState) {}
126 StringRef VariableName,
133 typedef llvm::DenseMap<const VarDecl *, ConsumedState> VarMapType;
134 typedef llvm::DenseMap<const CXXBindTemporaryExpr *, ConsumedState>
147 : Reachable(Other.Reachable), From(Other.From), VarMap(Other.VarMap),
156 void clearTemporaries();
167 void intersectAtLoopHead(
const CFGBlock *LoopHead,
const CFGBlock *LoopBack,
175 void markUnreachable();
199 std::vector<std::unique_ptr<ConsumedStateMap>> StateMapsArray;
200 std::vector<unsigned int> VisitOrder;
206 : StateMapsArray(NumBlocks), VisitOrder(NumBlocks, 0) {
207 unsigned int VisitOrderCounter = 0;
209 BE = SortedGraph->
end(); BI != BE; ++BI) {
210 VisitOrder[(*BI)->getBlockID()] = VisitOrderCounter++;
214 bool allBackEdgesVisited(
const CFGBlock *CurrBlock,
218 std::unique_ptr<ConsumedStateMap> &OwnedStateMap);
220 std::unique_ptr<ConsumedStateMap> StateMap);
224 void discardInfo(
const CFGBlock *Block);
229 bool isBackEdgeTarget(
const CFGBlock *Block);
236 std::unique_ptr<ConsumedStateMap> CurrStates;
242 bool splitState(
const CFGBlock *CurrBlock,
250 : WarningsHandler(WarningsHandler) {}
An instance of this class is created to represent a function declaration or definition.
virtual void warnReturnTypestateForUnconsumableType(SourceLocation Loc, StringRef TypeName)
Warn about return typestates set for unconsumable types.
Stmt - This represents one statement.
virtual void warnParamReturnTypestateMismatch(SourceLocation Loc, StringRef VariableName, StringRef ExpectedState, StringRef ObservedState)
Warn about parameter typestate mismatches upon return.
virtual void warnUseInInvalidState(StringRef MethodName, StringRef VariableName, StringRef State, SourceLocation Loc)
Warn about use-while-consumed errors.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
ConsumedState getExpectedReturnState() const
Defines the clang::Expr interface and subclasses for C++ expressions.
std::pair< PartialDiagnosticAt, OptionalNotes > DelayedDiag
AnalysisDeclContext contains the context data for the function or method under analysis.
Represents binding an expression to a temporary.
CFGBlock - Represents a single basic block in a source-level CFG.
virtual void warnLoopStateMismatch(SourceLocation Loc, StringRef VariableName)
Warn that a variable's state doesn't match at the entry and exit of a loop.
bool isReachable() const
Return true if this block is reachable.
virtual void emitDiagnostics()
Emit the warnings and notes left by the analysis.
Encodes a location in the source.
virtual void warnParamTypestateMismatch(SourceLocation LOC, StringRef ExpectedState, StringRef ObservedState)
virtual void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState, StringRef ObservedState)
Warn about return typestate mismatches.
ConsumedAnalyzer(ConsumedWarningsHandlerBase &WarningsHandler)
Dataflow Directional Tag Classes.
SmallVector< PartialDiagnosticAt, 1 > OptionalNotes
A class that handles the analysis of uniqueness violations.
ConsumedBlockInfo(unsigned int NumBlocks, PostOrderCFGView *SortedGraph)
ConsumedWarningsHandlerBase & WarningsHandler
std::list< DelayedDiag > DiagList
std::vector< const CFGBlock * >::reverse_iterator iterator
static const TypeInfo & getInfo(unsigned id)
ConsumedStateMap(const ConsumedStateMap &Other)
virtual ~ConsumedWarningsHandlerBase()
void setSource(const Stmt *Source)
Set the source for a decision about the branching of states.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Defines the clang::SourceLocation class and associated facilities.
bool operator!=(CanQual< T > x, CanQual< U > y)
virtual void warnUseOfTempInInvalidState(StringRef MethodName, StringRef State, SourceLocation Loc)
Warn about use-while-consumed errors.