clang 20.0.0git
|
#include "AllocationState.h"
#include "InterCheckerAPI.h"
#include "NoOwnershipChangeVisitor.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ParentMap.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Analysis/ProgramPoint.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Lexer.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Checkers/Taint.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <functional>
#include <optional>
#include <utility>
Go to the source code of this file.
Namespaces | |
namespace | clang |
The JSON file list parser is used to communicate input to InstallAPI. | |
namespace | clang::ento |
namespace | clang::ento::allocation_state |
Macros | |
#define | CASE(ID) case ID: OS << #ID; break; |
#define | CHECK_FN(NAME) |
#define | REGISTER_CHECKER(name) |
Functions | |
static bool | printMemFnName (raw_ostream &os, CheckerContext &C, const Expr *E) |
Print names of allocators and deallocators. | |
static void | printExpectedAllocName (raw_ostream &os, AllocationFamily Family) |
Print expected name of an allocator based on the deallocator's family derived from the DeallocExpr. | |
static void | printExpectedDeallocName (raw_ostream &os, AllocationFamily Family) |
Print expected name of a deallocator based on the allocator's family. | |
static bool | isReleased (SymbolRef Sym, CheckerContext &C) |
Check if the memory associated with this symbol was released. | |
static ProgramStateRef | MallocUpdateRefState (CheckerContext &C, const Expr *E, ProgramStateRef State, AllocationFamily Family, std::optional< SVal > RetVal=std::nullopt) |
Update the RefState to reflect the new memory allocation. | |
static bool | isStandardNew (const FunctionDecl *FD) |
static bool | isStandardNew (const CallEvent &Call) |
static bool | isStandardDelete (const FunctionDecl *FD) |
static bool | isStandardDelete (const CallEvent &Call) |
template<typename T > | |
static bool | isStandardNewDelete (const T &FD) |
Tells if the callee is one of the builtin new/delete operators, including placement operators and other standard overloads. | |
static bool | isStandardRealloc (const CallEvent &Call) |
static bool | isGRealloc (const CallEvent &Call) |
static bool | isFromStdNamespace (const CallEvent &Call) |
static QualType | getDeepPointeeType (QualType T) |
static bool | hasNonTrivialConstructorCall (const CXXNewExpr *NE) |
static bool | isKnownDeallocObjCMethodName (const ObjCMethodCall &Call) |
static std::optional< bool > | getFreeWhenDoneArg (const ObjCMethodCall &Call) |
static bool | didPreviousFreeFail (ProgramStateRef State, SymbolRef Sym, SymbolRef &RetStatusSymbol) |
Checks if the previous call to free on the given symbol failed - if free failed, returns true. | |
static void | printOwnershipTakesList (raw_ostream &os, CheckerContext &C, const Expr *E) |
static bool | checkIfNewOrNewArrayFamily (const RefState *RS) |
static SymbolRef | findFailedReallocSymbol (ProgramStateRef currState, ProgramStateRef prevState) |
static bool | isReferenceCountingPointerDestructor (const CXXDestructorDecl *DD) |
ProgramStateRef | clang::ento::allocation_state::markReleased (ProgramStateRef State, SymbolRef Sym, const Expr *Origin) |
#define CHECK_FN | ( | NAME | ) |
Definition at line 418 of file MallocChecker.cpp.
#define REGISTER_CHECKER | ( | name | ) |
Definition at line 3931 of file MallocChecker.cpp.
|
static |
Definition at line 3571 of file MallocChecker.cpp.
|
static |
Checks if the previous call to free on the given symbol failed - if free failed, returns true.
Also, returns the corresponding return value symbol.
Definition at line 2010 of file MallocChecker.cpp.
References clang::ento::ConditionTruthVal::isConstrainedTrue(), and clang::ento::ConstraintManager::isNull().
|
static |
Definition at line 3614 of file MallocChecker.cpp.
Definition at line 1674 of file MallocChecker.cpp.
References clang::Type::getPointeeType(), and clang::T.
Referenced by hasNonTrivialConstructorCall().
|
static |
Definition at line 1769 of file MallocChecker.cpp.
References clang::Call.
|
static |
NE
has an argument of a pointer/reference to a record type. Definition at line 1685 of file MallocChecker.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::CXXConstructExpr::getConstructor(), getDeepPointeeType(), clang::Type::getPointeeType(), clang::QualType::isNull(), and clang::FunctionDecl::parameters().
Definition at line 1458 of file MallocChecker.cpp.
References clang::Call, and clang::Decl::isInStdNamespace().
Definition at line 1290 of file MallocChecker.cpp.
References clang::Call, clang::Decl::getASTContext(), clang::FunctionDecl::getDeclaredReturnType(), clang::QualType::getDesugaredType(), clang::FunctionDecl::getParamDecl(), and clang::ValueDecl::getType().
|
static |
Definition at line 1757 of file MallocChecker.cpp.
References clang::Call.
|
static |
Definition at line 3628 of file MallocChecker.cpp.
References clang::NamedDecl::getIdentifier(), clang::IdentifierInfo::getName(), and clang::CXXMethodDecl::getParent().
|
static |
Check if the memory associated with this symbol was released.
Definition at line 3266 of file MallocChecker.cpp.
References clang::C.
Definition at line 326 of file MallocChecker.cpp.
References clang::Call, and isStandardDelete().
|
static |
Definition at line 1086 of file MallocChecker.cpp.
References clang::Decl::getASTContext(), clang::Decl::getLocation(), clang::FunctionDecl::getOverloadedOperator(), clang::ASTContext::getSourceManager(), clang::FunctionDecl::hasBody(), clang::SourceLocation::isInvalid(), and SM.
Referenced by isStandardDelete(), and isStandardNewDelete().
Definition at line 319 of file MallocChecker.cpp.
References clang::Call, and isStandardNew().
|
static |
Definition at line 1070 of file MallocChecker.cpp.
References clang::Decl::getASTContext(), clang::Decl::getLocation(), clang::FunctionDecl::getOverloadedOperator(), clang::ASTContext::getSourceManager(), clang::SourceManager::isInSystemHeader(), and clang::SourceLocation::isValid().
Referenced by isStandardNew(), and isStandardNewDelete().
|
static |
Tells if the callee is one of the builtin new/delete operators, including placement operators and other standard overloads.
Definition at line 334 of file MallocChecker.cpp.
References isStandardDelete(), and isStandardNew().
Definition at line 1279 of file MallocChecker.cpp.
References clang::Call, clang::Decl::getASTContext(), clang::FunctionDecl::getDeclaredReturnType(), clang::QualType::getDesugaredType(), clang::FunctionDecl::getParamDecl(), and clang::ValueDecl::getType().
|
static |
Update the RefState to reflect the new memory allocation.
The optional RetVal
parameter specifies the newly allocated pointer value; if unspecified, the value of expression E
is used.
Definition at line 1941 of file MallocChecker.cpp.
|
static |
Print expected name of an allocator based on the deallocator's family derived from the DeallocExpr.
Definition at line 2086 of file MallocChecker.cpp.
|
static |
Print expected name of a deallocator based on the allocator's family.
Definition at line 2113 of file MallocChecker.cpp.
|
static |
Print names of allocators and deallocators.
Definition at line 2044 of file MallocChecker.cpp.
References E, clang::getOperatorSpelling(), clang::FunctionDecl::isOverloadedOperator(), and clang::Decl::print().
|
static |
Definition at line 2023 of file MallocChecker.cpp.
References E, clang::CallExpr::getDirectCallee(), clang::NamedDecl::getName(), and clang::Decl::specific_attrs().