clang 19.0.0git
NoOwnershipChangeVisitor.h
Go to the documentation of this file.
1//===--------------------------------------------------------------*- C++ -*--//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12
13namespace clang {
14namespace ento {
15
17protected:
18 // The symbol whose (lack of) ownership change we are interested in.
21
22 LLVM_DUMP_METHOD static std::string
23 getFunctionName(const ExplodedNode *CallEnterN);
24
25 /// Heuristically guess whether the callee intended to free the resource. This
26 /// is done syntactically, because we are trying to argue about alternative
27 /// paths of execution, and as a consequence we don't have path-sensitive
28 /// information.
29 virtual bool doesFnIntendToHandleOwnership(const Decl *Callee,
30 ASTContext &ACtx) = 0;
31
32 virtual bool hasResourceStateChanged(ProgramStateRef CallEnterState,
33 ProgramStateRef CallExitEndState) = 0;
34
35 bool wasModifiedInFunction(const ExplodedNode *CallEnterN,
36 const ExplodedNode *CallExitEndN) final;
37
39
41 const ObjCMethodCall &Call,
42 const ExplodedNode *N) final {
43 // TODO: Implement.
44 return nullptr;
45 }
46
49 const ExplodedNode *N) final {
50 // TODO: Implement.
51 return nullptr;
52 }
53
54 // Set this to final, effectively dispatch to emitNote.
57 const ExplodedNode *N) final;
58
59public:
61
62private:
63 OwnerSet getOwnersAtNode(const ExplodedNode *N);
64
65public:
67 : NoStateChangeFuncVisitor(bugreporter::TrackingKind::Thorough), Sym(Sym),
68 Checker(*Checker) {}
69
70 void Profile(llvm::FoldingSetNodeID &ID) const override {
71 static int Tag = 0;
72 ID.AddPointer(&Tag);
73 ID.AddPointer(Sym);
74 }
75};
76} // namespace ento
77} // namespace clang
static char ID
Definition: Arena.cpp:183
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:186
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents a call to a C++ constructor.
Definition: CallEvent.h:979
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:153
static LLVM_DUMP_METHOD std::string getFunctionName(const ExplodedNode *CallEnterN)
PathDiagnosticPieceRef maybeEmitNoteForObjCSelf(PathSensitiveBugReport &R, const ObjCMethodCall &Call, const ExplodedNode *N) final
Consume the information on the non-modifying stack frame in order to either emit a note or not.
virtual bool doesFnIntendToHandleOwnership(const Decl *Callee, ASTContext &ACtx)=0
Heuristically guess whether the callee intended to free the resource.
PathDiagnosticPieceRef maybeEmitNoteForCXXThis(PathSensitiveBugReport &R, const CXXConstructorCall &Call, const ExplodedNode *N) final
Consume the information on the non-modifying stack frame in order to either emit a note or not.
void Profile(llvm::FoldingSetNodeID &ID) const override
bool wasModifiedInFunction(const ExplodedNode *CallEnterN, const ExplodedNode *CallExitEndN) final
PathDiagnosticPieceRef maybeEmitNoteForParameters(PathSensitiveBugReport &R, const CallEvent &Call, const ExplodedNode *N) final
Consume the information on the non-modifying stack frame in order to either emit a note or not.
NoOwnershipChangeVisitor(SymbolRef Sym, const CheckerBase *Checker)
virtual PathDiagnosticPieceRef emitNote(const ExplodedNode *N)=0
virtual bool hasResourceStateChanged(ProgramStateRef CallEnterState, ProgramStateRef CallExitEndState)=0
Put a diagnostic on return statement (or on } in its absence) of all inlined functions for which some...
Represents any expression that calls an Objective-C method.
Definition: CallEvent.h:1243
Symbolic value.
Definition: SymExpr.h:30
std::shared_ptr< PathDiagnosticPiece > PathDiagnosticPieceRef
The JSON file list parser is used to communicate input to InstallAPI.