clang  7.0.0svn
Namespaces | Macros | Enumerations | Functions
MallocChecker.cpp File Reference
#include "ClangSACheckers.h"
#include "InterCheckerAPI.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ParentMap.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.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/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "AllocationState.h"
#include <climits>
#include <utility>
Include dependency graph for MallocChecker.cpp:

Go to the source code of this file.


 Dataflow Directional Tag Classes.


#define CASE(ID)   case ID: OS << #ID; break;
#define REGISTER_CHECKER(name)


enum  AllocationFamily
enum  ReallocPairKind


static QualType getDeepPointeeType (QualType T)
static bool treatUnusedNewEscaped (const CXXNewExpr *NE)
static bool isKnownDeallocObjCMethodName (const ObjCMethodCall &Call)
static Optional< boolgetFreeWhenDoneArg (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. More...
static bool retTrue (const RefState *RS)
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)

Macro Definition Documentation


#define CASE (   ID)    case ID: OS << #ID; break;


#define REGISTER_CHECKER (   name)
void ento::register##name(CheckerManager &mgr) { \
registerCStringCheckerBasic(mgr); \
MallocChecker *checker = mgr.registerChecker<MallocChecker>(); \
checker->IsOptimistic = mgr.getAnalyzerOptions().getBooleanOption( \
"Optimistic", false, checker); \
checker->ChecksEnabled[MallocChecker::CK_##name] = true; \
checker->CheckNames[MallocChecker::CK_##name] = mgr.getCurrentCheckName(); \
CheckName getCurrentCheckName() const
bool getBooleanOption(StringRef Name, bool DefaultVal, const ento::CheckerBase *C=nullptr, bool SearchInParents=false)
Interprets an option&#39;s string value as a boolean.
CHECKER * registerChecker()
Used to register checkers.
AnalyzerOptions & getAnalyzerOptions()

Definition at line 3033 of file MallocChecker.cpp.

Enumeration Type Documentation

◆ AllocationFamily

Definition at line 43 of file MallocChecker.cpp.

◆ ReallocPairKind

Definition at line 130 of file MallocChecker.cpp.

Function Documentation

◆ checkIfNewOrNewArrayFamily()

static bool checkIfNewOrNewArrayFamily ( const RefState *  RS)

Definition at line 2769 of file MallocChecker.cpp.

References clang::ento::PSK_DirectEscapeOnCall, retTrue(), and State.

◆ didPreviousFreeFail()

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.

Also, returns the corresponding return value symbol.

Definition at line 1365 of file MallocChecker.cpp.

References clang::ento::ConditionTruthVal::isConstrainedTrue(), and clang::ento::ConstraintManager::isNull().

◆ findFailedReallocSymbol()

static SymbolRef findFailedReallocSymbol ( ProgramStateRef  currState,
ProgramStateRef  prevState 

Definition at line 2823 of file MallocChecker.cpp.

Referenced by isReferenceCountingPointerDestructor().

◆ getDeepPointeeType()

static QualType getDeepPointeeType ( QualType  T)

Definition at line 1042 of file MallocChecker.cpp.

References clang::Type::getPointeeType(), and clang::T.

Referenced by treatUnusedNewEscaped().

◆ getFreeWhenDoneArg()

static Optional<bool> getFreeWhenDoneArg ( const ObjCMethodCall Call)

Definition at line 1194 of file MallocChecker.cpp.

◆ isKnownDeallocObjCMethodName()

static bool isKnownDeallocObjCMethodName ( const ObjCMethodCall Call)

◆ isReferenceCountingPointerDestructor()

static bool isReferenceCountingPointerDestructor ( const CXXDestructorDecl DD)

◆ retTrue()

static bool retTrue ( const RefState *  RS)

Definition at line 2765 of file MallocChecker.cpp.

Referenced by checkIfNewOrNewArrayFamily().

◆ treatUnusedNewEscaped()

static bool treatUnusedNewEscaped ( const CXXNewExpr NE)