llvm-project/clang/lib/StaticAnalyzer/Checkers
Kristóf Umann d832078904 [analyzer] Improve NoOwnershipChangeVisitor's understanding of deallocators
The problem with leak bug reports is that the most interesting event in the code
is likely the one that did not happen -- lack of ownership change and lack of
deallocation, which is often present within the same function that the analyzer
inlined anyway, but not on the path of execution on which the bug occured. We
struggle to understand that a function was responsible for freeing the memory,
but failed.

D105819 added a new visitor to improve memory leak bug reports. In addition to
inspecting the ExplodedNodes of the bug pat, the visitor tries to guess whether
the function was supposed to free memory, but failed to. Initially (in D108753),
this was done by checking whether a CXXDeleteExpr is present in the function. If
so, we assume that the function was at least party responsible, and prevent the
analyzer from pruning bug report notes in it. This patch improves this heuristic
by recognizing all deallocator functions that MallocChecker itself recognizes,
by reusing MallocChecker::isFreeingCall.

Differential Revision: https://reviews.llvm.org/D118880
2022-03-03 11:27:56 +01:00
..
MPI-Checker [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
RetainCountChecker [clang] Use isa instead of dyn_cast (NFC) 2021-11-14 09:32:40 -08:00
UninitializedObject [NFC] Use hasAnyName matcher in place of anyOf(hasName()...) 2020-07-07 14:31:04 +01:00
WebKit [clang] Remove unused forward declarations (NFC) 2022-01-08 11:56:40 -08:00
cert [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
AllocationState.h
AnalysisOrderChecker.cpp [analyzer] Enable constructor support in evalCall event. 2020-06-25 09:47:13 -07:00
AnalyzerStatsChecker.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
ArrayBoundChecker.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
ArrayBoundCheckerV2.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
BasicObjCFoundationChecks.cpp [analyzer][NFC] Demonstrate the use of CallDescriptionSet 2021-11-19 18:32:13 +01:00
BlockInCriticalSectionChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
BoolAssignmentChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
BuiltinFunctionChecker.cpp [Clang] Add __builtin_function_start 2021-12-20 12:55:33 -08:00
CMakeLists.txt [clang][analyzer] Add modeling of 'errno'. 2022-03-01 08:20:33 +01:00
CStringChecker.cpp [analyzer][NFCi] Use the correct BugType in CStringChecker. 2022-02-14 20:54:59 +05:30
CStringSyntaxChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
CXXSelfAssignmentChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
CallAndMessageChecker.cpp [analyzer][CallAndMessage] Add checker options for each bug type 2020-05-21 15:31:37 +02:00
CastSizeChecker.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
CastToStructChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
CastValueChecker.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
CheckObjCDealloc.cpp [analyzer] Simplify function SVal::getAsSymbolicExpression and similar ones 2020-08-03 15:03:35 +03:00
CheckObjCInstMethSignature.cpp Reapply commit b7425e956 2021-08-16 12:18:40 -07:00
CheckPlacementNew.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
CheckSecuritySyntaxOnly.cpp [Sema, StaticAnalyzer] Use StringRef::contains (NFC) 2021-10-20 08:02:36 -07:00
CheckSizeofPointer.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
CheckerDocumentation.cpp
ChrootChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
CloneChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ContainerModeling.cpp [analyzer][NFC] Use enum for CallDescription flags 2021-11-19 18:32:13 +01:00
ConversionChecker.cpp [analyzer] Expand conversion check to check more expressions for overflow and underflow 2021-12-15 11:41:34 +01:00
DeadStoresChecker.cpp [analyzer] Fix dead store checker false positive 2021-04-08 16:12:42 +03:00
DebugCheckers.cpp [clang] Use true/false instead of 1/0 (NFC) 2022-01-09 00:19:47 -08:00
DebugContainerModeling.cpp [analyzer][NFC] Use enum for CallDescription flags 2021-11-19 18:32:13 +01:00
DebugIteratorModeling.cpp [analyzer][NFC] Use enum for CallDescription flags 2021-11-19 18:32:13 +01:00
DeleteWithNonVirtualDtorChecker.cpp [analyzer][NFC] Introduce CXXDeallocatorCall, deploy it in MallocChecker 2020-05-19 00:18:38 +02:00
DereferenceChecker.cpp PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23 2021-07-08 13:37:57 -07:00
DirectIvarAssignment.cpp [Sema, StaticAnalyzer] Use StringRef::contains (NFC) 2021-10-20 08:02:36 -07:00
DivZeroChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
DynamicTypeChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
DynamicTypePropagation.cpp [clang] Use isa instead of dyn_cast (NFC) 2021-11-14 09:32:40 -08:00
EnumCastOutOfRangeChecker.cpp [clang][NFC] Inclusive terms: Replace uses of whitelist in clang/lib/StaticAnalyzer 2021-10-29 16:51:36 -04:00
ErrnoModeling.cpp [clang][analyzer] Add modeling of 'errno'. 2022-03-01 08:20:33 +01:00
ErrnoModeling.h [clang][analyzer] Add modeling of 'errno'. 2022-03-01 08:20:33 +01:00
ErrnoTesterChecker.cpp [clang][analyzer] Add modeling of 'errno'. 2022-03-01 08:20:33 +01:00
ExprInspectionChecker.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
FixedAddressChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
FuchsiaHandleChecker.cpp [NFC][analyzer] Return underlying strings directly instead of OS.str() 2021-12-09 16:05:46 -08:00
GCDAntipatternChecker.cpp [clang] Rename StringRef _lower() method calls to _insensitive() 2021-06-25 00:22:01 +03:00
GTestChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
GenericTaintChecker.cpp [analyzer] Add more sources to Taint analysis 2022-02-28 11:33:02 +01:00
IdenticalExprChecker.cpp [OPENMP50]Add initial support for OpenMP 5.0 iterator. 2020-04-02 08:28:15 -04:00
InnerPointerChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
InterCheckerAPI.h
InvalidatedIteratorChecker.cpp [Analyzer] Handle pointer implemented as iterators in iterator checkers 2020-07-01 09:04:28 +02:00
Iterator.cpp [clang] Rename StringRef _lower() method calls to _insensitive() 2021-06-25 00:22:01 +03:00
Iterator.h [Analyzer] Handle pointer implemented as iterators in iterator checkers 2020-07-01 09:04:28 +02:00
IteratorModeling.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
IteratorRangeChecker.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
IvarInvalidationChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
LLVMConventionsChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
LocalizationChecker.cpp [NFC] Don't pass temporary LangOptions to Lexer 2022-02-28 20:43:28 +01:00
MIGChecker.cpp [clang][NFC] Inclusive terms: replace some uses of sanity in clang 2021-11-19 14:58:35 -05:00
MacOSKeychainAPIChecker.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
MacOSXAPIChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
MallocChecker.cpp [analyzer] Improve NoOwnershipChangeVisitor's understanding of deallocators 2022-03-03 11:27:56 +01:00
MallocOverflowSecurityChecker.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
MallocSizeofChecker.cpp [analyzer] MallocSizeof: sizeof pointer type is compatible with void* 2021-05-30 09:51:41 +08:00
MismatchedIteratorChecker.cpp [Analyzer] Handle pointer implemented as iterators in iterator checkers 2020-07-01 09:04:28 +02:00
MmapWriteExecChecker.cpp [clang] Remove unused "using" (NFC) 2021-12-27 20:48:21 -08:00
Move.h
MoveChecker.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
NSAutoreleasePoolChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
NSErrorChecker.cpp Reapply commit b7425e956 2021-08-16 12:18:40 -07:00
NoReturnFunctionChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
NonNullParamChecker.cpp [analyzer] Fix crash for non-pointers annotated as nonnull 2020-05-13 13:36:49 +03:00
NonnullGlobalConstantsChecker.cpp Correct Doxygen syntax for inline code 2021-03-16 15:17:45 +01:00
NullabilityChecker.cpp [analyzer] Add forwarding `addVisitor` method 2021-06-03 17:10:16 +03:00
NumberObjectConversionChecker.cpp [clang][NFC] Add 'override' keyword to virtual function overrides 2020-07-14 08:59:57 -07:00
OSObjectCStyleCast.cpp [analyzer] Support allocClassWithName in OSObjectCStyleCast checker 2021-03-30 15:58:06 +03:00
ObjCAtSyncChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ObjCAutoreleaseWriteChecker.cpp Correct Doxygen syntax for inline code 2021-03-16 15:17:45 +01:00
ObjCContainersASTChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ObjCContainersChecker.cpp [analyzer] Refactor trackExpressionValue to accept TrackingOptions 2021-06-11 12:49:04 +03:00
ObjCMissingSuperCallChecker.cpp Upgrade SmallSets of pointer-like types to SmallPtrSet 2020-07-20 16:54:29 +02:00
ObjCPropertyChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ObjCSelfInitChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ObjCSuperDeallocChecker.cpp [analyzer] Track runtime types represented by Obj-C Class objects 2020-04-29 13:35:53 +03:00
ObjCUnusedIVarsChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
PaddingChecker.cpp [analyzer] Fix calculating offset for fields with an empty type 2021-07-04 06:57:11 +03:00
PointerArithChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
PointerIterationChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
PointerSortingChecker.cpp Add some explicit use of TK_AsIs 2020-05-23 01:04:44 +01:00
PointerSubChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
PthreadLockChecker.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
ReturnPointerRangeChecker.cpp [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange 2021-08-11 13:04:55 +02:00
ReturnUndefChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
ReturnValueChecker.cpp Remove redundant string initialization (NFC) 2021-12-26 09:39:26 -08:00
RunLoopAutoreleaseLeakChecker.cpp Correct Doxygen syntax for inline code 2021-03-16 15:17:45 +01:00
STLAlgorithmModeling.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
SimpleStreamChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
SmartPtr.h [StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC) 2021-12-25 00:35:41 -08:00
SmartPtrChecker.cpp [Analyzer] Support note tags for smart ptr checker 2020-08-11 23:27:16 +02:00
SmartPtrModeling.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
StackAddrEscapeChecker.cpp [analyzer] Catch leaking stack addresses via stack variables 2021-08-27 11:31:16 +02:00
StdLibraryFunctionsChecker.cpp [clang][NFC] Inclusive terms: replace some uses of sanity in clang 2021-11-19 14:58:35 -05:00
StreamChecker.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
StringChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
Taint.cpp [analyzer] Simplify function SVal::getAsSymbolicExpression and similar ones 2020-08-03 15:03:35 +03:00
Taint.h
TaintTesterChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
TestAfterDivZeroChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
TraversalChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
TrustNonnullChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
TrustReturnsNonnullChecker.cpp [analyzer] Add support for __attribute__((returns_nonnull)). 2022-02-02 11:46:52 -08:00
UndefBranchChecker.cpp [analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait 2020-09-11 15:58:48 +02:00
UndefCapturedBlockVarChecker.cpp [analyzer] Change FindLastStoreBRVisitor to use Tracker 2021-06-11 12:49:03 +03:00
UndefResultChecker.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
UndefinedArraySubscriptChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
UndefinedAssignmentChecker.cpp [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions 2020-03-27 14:34:09 +01:00
UnixAPIChecker.cpp [clang][NFC] Inclusive terms: replace some uses of sanity in clang 2021-11-19 14:58:35 -05:00
UnreachableCodeChecker.cpp [analyzer] Introduce common bug category "Unused code". 2021-03-17 20:58:27 -07:00
VLASizeChecker.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
ValistChecker.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
VforkChecker.cpp [clang][NFC] Inclusive terms: Replace uses of whitelist in clang/lib/StaticAnalyzer 2021-10-29 16:51:36 -04:00
VirtualCallChecker.cpp [clang][nearly-NFC] Remove some superfluous uses of NamedDecl::getNameAsString 2020-08-05 13:54:37 +01:00
Yaml.h [NFC] Fix endif comments to match with include guard 2022-01-07 15:52:59 +08:00