File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed
clang/lib/StaticAnalyzer/Checkers Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -832,9 +832,18 @@ class NoMemOwnershipChangeVisitor final : public NoOwnershipChangeVisitor {
832
832
// / information.
833
833
bool doesFnIntendToHandleOwnership (const Decl *Callee,
834
834
ASTContext &ACtx) final {
835
- using namespace clang ::ast_matchers;
836
835
const FunctionDecl *FD = dyn_cast<FunctionDecl>(Callee);
837
836
837
+ // Given that the stack frame was entered, the body should always be
838
+ // theoretically obtainable. In case of body farms, the synthesized body
839
+ // is not attached to declaration, thus triggering the '!FD->hasBody()'
840
+ // branch. That said, would a synthesized body ever intend to handle
841
+ // ownership? As of today they don't. And if they did, how would we
842
+ // put notes inside it, given that it doesn't match any source locations?
843
+ if (!FD || !FD->hasBody ())
844
+ return false ;
845
+ using namespace clang ::ast_matchers;
846
+
838
847
auto Matches = match (findAll (stmt (anyOf (cxxDeleteExpr ().bind (" delete" ),
839
848
callExpr ().bind (" call" )))),
840
849
*FD->getBody (), ACtx);
Original file line number Diff line number Diff line change @@ -72,16 +72,6 @@ bool NoOwnershipChangeVisitor::wasModifiedInFunction(
72
72
const ExplodedNode *CallEnterN, const ExplodedNode *CallExitEndN) {
73
73
const Decl *Callee =
74
74
CallExitEndN->getFirstPred ()->getLocationContext ()->getDecl ();
75
- const FunctionDecl *FD = dyn_cast<FunctionDecl>(Callee);
76
-
77
- // Given that the stack frame was entered, the body should always be
78
- // theoretically obtainable. In case of body farms, the synthesized body
79
- // is not attached to declaration, thus triggering the '!FD->hasBody()'
80
- // branch. That said, would a synthesized body ever intend to handle
81
- // ownership? As of today they don't. And if they did, how would we
82
- // put notes inside it, given that it doesn't match any source locations?
83
- if (!FD || !FD->hasBody ())
84
- return false ;
85
75
if (!doesFnIntendToHandleOwnership (
86
76
Callee,
87
77
CallExitEndN->getState ()->getAnalysisManager ().getASTContext ()))
Original file line number Diff line number Diff line change @@ -755,9 +755,18 @@ class NoStreamStateChangeVisitor final : public NoOwnershipChangeVisitor {
755
755
756
756
bool doesFnIntendToHandleOwnership (const Decl *Callee,
757
757
ASTContext &ACtx) final {
758
- using namespace clang ::ast_matchers;
759
758
const FunctionDecl *FD = dyn_cast<FunctionDecl>(Callee);
760
759
760
+ // Given that the stack frame was entered, the body should always be
761
+ // theoretically obtainable. In case of body farms, the synthesized body
762
+ // is not attached to declaration, thus triggering the '!FD->hasBody()'
763
+ // branch. That said, would a synthesized body ever intend to handle
764
+ // ownership? As of today they don't. And if they did, how would we
765
+ // put notes inside it, given that it doesn't match any source locations?
766
+ if (!FD || !FD->hasBody ())
767
+ return false ;
768
+ using namespace clang ::ast_matchers;
769
+
761
770
auto Matches =
762
771
match (findAll (callExpr ().bind (" call" )), *FD->getBody (), ACtx);
763
772
for (BoundNodes Match : Matches) {
You can’t perform that action at this time.
0 commit comments