2009-11-12 16:38:56 +08:00
|
|
|
//=== MallocChecker.cpp - A malloc/free checker -------------------*- C++ -*--//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines malloc/free checker, which checks for potential memory
|
|
|
|
// leaks, double free, and use-after-free problems.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-02-09 06:30:11 +08:00
|
|
|
#include "ExperimentalChecks.h"
|
2011-02-10 09:03:03 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/GRState.h"
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
|
2009-11-12 16:38:56 +08:00
|
|
|
#include "llvm/ADT/ImmutableMap.h"
|
|
|
|
using namespace clang;
|
2010-12-23 15:20:52 +08:00
|
|
|
using namespace ento;
|
2009-11-12 16:38:56 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2009-12-11 08:55:44 +08:00
|
|
|
class RefState {
|
2010-08-07 05:12:55 +08:00
|
|
|
enum Kind { AllocateUnchecked, AllocateFailed, Released, Escaped,
|
|
|
|
Relinquished } K;
|
2009-11-17 15:54:15 +08:00
|
|
|
const Stmt *S;
|
|
|
|
|
2009-12-11 08:55:44 +08:00
|
|
|
public:
|
2009-11-17 15:54:15 +08:00
|
|
|
RefState(Kind k, const Stmt *s) : K(k), S(s) {}
|
|
|
|
|
2009-12-31 14:13:07 +08:00
|
|
|
bool isAllocated() const { return K == AllocateUnchecked; }
|
2010-09-03 12:34:38 +08:00
|
|
|
//bool isFailed() const { return K == AllocateFailed; }
|
2009-11-17 15:54:15 +08:00
|
|
|
bool isReleased() const { return K == Released; }
|
2010-09-03 12:34:38 +08:00
|
|
|
//bool isEscaped() const { return K == Escaped; }
|
|
|
|
//bool isRelinquished() const { return K == Relinquished; }
|
2009-11-17 15:54:15 +08:00
|
|
|
|
|
|
|
bool operator==(const RefState &X) const {
|
|
|
|
return K == X.K && S == X.S;
|
|
|
|
}
|
|
|
|
|
2009-12-31 14:13:07 +08:00
|
|
|
static RefState getAllocateUnchecked(const Stmt *s) {
|
|
|
|
return RefState(AllocateUnchecked, s);
|
|
|
|
}
|
|
|
|
static RefState getAllocateFailed() {
|
|
|
|
return RefState(AllocateFailed, 0);
|
|
|
|
}
|
2009-11-17 15:54:15 +08:00
|
|
|
static RefState getReleased(const Stmt *s) { return RefState(Released, s); }
|
|
|
|
static RefState getEscaped(const Stmt *s) { return RefState(Escaped, s); }
|
2010-08-07 05:12:55 +08:00
|
|
|
static RefState getRelinquished(const Stmt *s) {
|
|
|
|
return RefState(Relinquished, s);
|
|
|
|
}
|
2009-11-17 15:54:15 +08:00
|
|
|
|
|
|
|
void Profile(llvm::FoldingSetNodeID &ID) const {
|
|
|
|
ID.AddInteger(K);
|
|
|
|
ID.AddPointer(S);
|
|
|
|
}
|
2009-11-12 16:38:56 +08:00
|
|
|
};
|
|
|
|
|
2009-11-28 14:07:30 +08:00
|
|
|
class RegionState {};
|
2009-11-12 16:38:56 +08:00
|
|
|
|
2009-11-28 14:07:30 +08:00
|
|
|
class MallocChecker : public CheckerVisitor<MallocChecker> {
|
2009-11-12 16:38:56 +08:00
|
|
|
BuiltinBug *BT_DoubleFree;
|
2009-11-13 15:48:11 +08:00
|
|
|
BuiltinBug *BT_Leak;
|
2010-03-10 12:58:55 +08:00
|
|
|
BuiltinBug *BT_UseFree;
|
2010-07-31 09:52:11 +08:00
|
|
|
BuiltinBug *BT_UseRelinquished;
|
2010-06-08 03:32:37 +08:00
|
|
|
BuiltinBug *BT_BadFree;
|
2010-06-01 11:01:33 +08:00
|
|
|
IdentifierInfo *II_malloc, *II_free, *II_realloc, *II_calloc;
|
2009-11-12 16:38:56 +08:00
|
|
|
|
|
|
|
public:
|
2009-12-12 20:29:38 +08:00
|
|
|
MallocChecker()
|
2010-08-07 05:12:55 +08:00
|
|
|
: BT_DoubleFree(0), BT_Leak(0), BT_UseFree(0), BT_UseRelinquished(0),
|
|
|
|
BT_BadFree(0),
|
2010-06-01 11:01:33 +08:00
|
|
|
II_malloc(0), II_free(0), II_realloc(0), II_calloc(0) {}
|
2009-11-12 16:38:56 +08:00
|
|
|
static void *getTag();
|
2010-12-02 05:57:22 +08:00
|
|
|
bool evalCallExpr(CheckerContext &C, const CallExpr *CE);
|
|
|
|
void evalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper);
|
2011-01-11 10:34:45 +08:00
|
|
|
void evalEndPath(EndOfFunctionNodeBuilder &B, void *tag, ExprEngine &Eng);
|
2009-11-17 16:58:18 +08:00
|
|
|
void PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S);
|
2010-12-02 05:57:22 +08:00
|
|
|
const GRState *evalAssume(const GRState *state, SVal Cond, bool Assumption,
|
2010-08-04 15:10:57 +08:00
|
|
|
bool *respondsToCallback);
|
2011-01-12 03:45:13 +08:00
|
|
|
void visitLocation(CheckerContext &C, const Stmt *S, SVal l, bool isLoad);
|
2010-09-02 08:56:20 +08:00
|
|
|
virtual void PreVisitBind(CheckerContext &C, const Stmt *StoreE,
|
|
|
|
SVal location, SVal val);
|
2009-12-31 14:13:07 +08:00
|
|
|
|
2009-11-13 15:25:27 +08:00
|
|
|
private:
|
2009-11-12 16:38:56 +08:00
|
|
|
void MallocMem(CheckerContext &C, const CallExpr *CE);
|
2010-08-07 05:12:55 +08:00
|
|
|
void MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE,
|
|
|
|
const OwnershipAttr* Att);
|
2009-12-12 20:29:38 +08:00
|
|
|
const GRState *MallocMemAux(CheckerContext &C, const CallExpr *CE,
|
2010-06-01 11:01:33 +08:00
|
|
|
const Expr *SizeEx, SVal Init,
|
|
|
|
const GRState *state) {
|
|
|
|
return MallocMemAux(C, CE, state->getSVal(SizeEx), Init, state);
|
|
|
|
}
|
|
|
|
const GRState *MallocMemAux(CheckerContext &C, const CallExpr *CE,
|
|
|
|
SVal SizeEx, SVal Init,
|
|
|
|
const GRState *state);
|
|
|
|
|
2009-11-12 16:38:56 +08:00
|
|
|
void FreeMem(CheckerContext &C, const CallExpr *CE);
|
2010-08-12 16:54:03 +08:00
|
|
|
void FreeMemAttr(CheckerContext &C, const CallExpr *CE,
|
|
|
|
const OwnershipAttr* Att);
|
2009-12-12 20:29:38 +08:00
|
|
|
const GRState *FreeMemAux(CheckerContext &C, const CallExpr *CE,
|
2010-07-31 09:52:11 +08:00
|
|
|
const GRState *state, unsigned Num, bool Hold);
|
2009-12-12 20:29:38 +08:00
|
|
|
|
|
|
|
void ReallocMem(CheckerContext &C, const CallExpr *CE);
|
2010-06-01 11:01:33 +08:00
|
|
|
void CallocMem(CheckerContext &C, const CallExpr *CE);
|
2010-06-08 03:32:37 +08:00
|
|
|
|
|
|
|
bool SummarizeValue(llvm::raw_ostream& os, SVal V);
|
|
|
|
bool SummarizeRegion(llvm::raw_ostream& os, const MemRegion *MR);
|
|
|
|
void ReportBadFree(CheckerContext &C, SVal ArgVal, SourceRange range);
|
2009-11-12 16:38:56 +08:00
|
|
|
};
|
2009-11-28 14:07:30 +08:00
|
|
|
} // end anonymous namespace
|
2009-11-12 16:38:56 +08:00
|
|
|
|
2009-12-31 14:13:07 +08:00
|
|
|
typedef llvm::ImmutableMap<SymbolRef, RefState> RegionStateTy;
|
|
|
|
|
2009-11-12 16:38:56 +08:00
|
|
|
namespace clang {
|
2010-12-23 15:20:52 +08:00
|
|
|
namespace ento {
|
2009-11-17 15:54:15 +08:00
|
|
|
template <>
|
2009-11-12 16:38:56 +08:00
|
|
|
struct GRStateTrait<RegionState>
|
2010-08-18 12:26:59 +08:00
|
|
|
: public GRStatePartialTrait<RegionStateTy> {
|
2009-11-12 16:38:56 +08:00
|
|
|
static void *GDMIndex() { return MallocChecker::getTag(); }
|
|
|
|
};
|
|
|
|
}
|
2010-12-23 02:53:20 +08:00
|
|
|
}
|
2009-11-12 16:38:56 +08:00
|
|
|
|
2010-12-23 15:20:52 +08:00
|
|
|
void ento::RegisterMallocChecker(ExprEngine &Eng) {
|
2009-11-13 15:25:27 +08:00
|
|
|
Eng.registerCheck(new MallocChecker());
|
|
|
|
}
|
|
|
|
|
2009-11-12 16:38:56 +08:00
|
|
|
void *MallocChecker::getTag() {
|
|
|
|
static int x;
|
|
|
|
return &x;
|
|
|
|
}
|
|
|
|
|
2010-12-02 05:57:22 +08:00
|
|
|
bool MallocChecker::evalCallExpr(CheckerContext &C, const CallExpr *CE) {
|
2009-12-11 11:09:01 +08:00
|
|
|
const GRState *state = C.getState();
|
|
|
|
const Expr *Callee = CE->getCallee();
|
2010-02-09 00:18:51 +08:00
|
|
|
SVal L = state->getSVal(Callee);
|
2009-12-11 11:09:01 +08:00
|
|
|
|
|
|
|
const FunctionDecl *FD = L.getAsFunctionDecl();
|
2009-11-12 16:38:56 +08:00
|
|
|
if (!FD)
|
2009-12-11 11:09:01 +08:00
|
|
|
return false;
|
2009-11-12 16:38:56 +08:00
|
|
|
|
|
|
|
ASTContext &Ctx = C.getASTContext();
|
|
|
|
if (!II_malloc)
|
|
|
|
II_malloc = &Ctx.Idents.get("malloc");
|
|
|
|
if (!II_free)
|
2009-11-13 15:48:11 +08:00
|
|
|
II_free = &Ctx.Idents.get("free");
|
2009-12-12 20:29:38 +08:00
|
|
|
if (!II_realloc)
|
|
|
|
II_realloc = &Ctx.Idents.get("realloc");
|
2010-06-01 11:01:33 +08:00
|
|
|
if (!II_calloc)
|
|
|
|
II_calloc = &Ctx.Idents.get("calloc");
|
2009-11-12 16:38:56 +08:00
|
|
|
|
|
|
|
if (FD->getIdentifier() == II_malloc) {
|
|
|
|
MallocMem(C, CE);
|
2009-12-11 11:09:01 +08:00
|
|
|
return true;
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FD->getIdentifier() == II_free) {
|
|
|
|
FreeMem(C, CE);
|
2009-12-11 11:09:01 +08:00
|
|
|
return true;
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
2009-12-11 11:09:01 +08:00
|
|
|
|
2009-12-12 20:29:38 +08:00
|
|
|
if (FD->getIdentifier() == II_realloc) {
|
|
|
|
ReallocMem(C, CE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-01 11:01:33 +08:00
|
|
|
if (FD->getIdentifier() == II_calloc) {
|
|
|
|
CallocMem(C, CE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-31 09:52:11 +08:00
|
|
|
// Check all the attributes, if there are any.
|
|
|
|
// There can be multiple of these attributes.
|
|
|
|
bool rv = false;
|
|
|
|
if (FD->hasAttrs()) {
|
2010-08-19 07:23:40 +08:00
|
|
|
for (specific_attr_iterator<OwnershipAttr>
|
|
|
|
i = FD->specific_attr_begin<OwnershipAttr>(),
|
|
|
|
e = FD->specific_attr_end<OwnershipAttr>();
|
|
|
|
i != e; ++i) {
|
|
|
|
switch ((*i)->getOwnKind()) {
|
|
|
|
case OwnershipAttr::Returns: {
|
|
|
|
MallocMemReturnsAttr(C, CE, *i);
|
2010-08-12 16:54:03 +08:00
|
|
|
rv = true;
|
|
|
|
break;
|
2010-08-19 07:23:40 +08:00
|
|
|
}
|
|
|
|
case OwnershipAttr::Takes:
|
|
|
|
case OwnershipAttr::Holds: {
|
|
|
|
FreeMemAttr(C, CE, *i);
|
2010-08-12 16:54:03 +08:00
|
|
|
rv = true;
|
|
|
|
break;
|
2010-08-19 07:23:40 +08:00
|
|
|
}
|
2010-08-12 16:54:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
2010-07-31 09:52:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MallocChecker::MallocMem(CheckerContext &C, const CallExpr *CE) {
|
2010-06-01 11:01:33 +08:00
|
|
|
const GRState *state = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(),
|
|
|
|
C.getState());
|
2009-12-12 20:29:38 +08:00
|
|
|
C.addTransition(state);
|
|
|
|
}
|
|
|
|
|
2010-07-31 09:52:11 +08:00
|
|
|
void MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE,
|
|
|
|
const OwnershipAttr* Att) {
|
2010-08-19 07:23:40 +08:00
|
|
|
if (Att->getModule() != "malloc")
|
2010-07-31 09:52:11 +08:00
|
|
|
return;
|
|
|
|
|
2010-08-19 07:23:40 +08:00
|
|
|
OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
|
2010-07-31 09:52:11 +08:00
|
|
|
if (I != E) {
|
|
|
|
const GRState *state =
|
|
|
|
MallocMemAux(C, CE, CE->getArg(*I), UndefinedVal(), C.getState());
|
|
|
|
C.addTransition(state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const GRState *state = MallocMemAux(C, CE, UnknownVal(), UndefinedVal(),
|
|
|
|
C.getState());
|
|
|
|
C.addTransition(state);
|
|
|
|
}
|
|
|
|
|
2009-12-12 20:29:38 +08:00
|
|
|
const GRState *MallocChecker::MallocMemAux(CheckerContext &C,
|
|
|
|
const CallExpr *CE,
|
2010-06-01 11:01:33 +08:00
|
|
|
SVal Size, SVal Init,
|
2009-12-12 20:29:38 +08:00
|
|
|
const GRState *state) {
|
2009-12-11 11:09:01 +08:00
|
|
|
unsigned Count = C.getNodeBuilder().getCurrentBlockCount();
|
2010-12-02 15:49:45 +08:00
|
|
|
SValBuilder &svalBuilder = C.getSValBuilder();
|
2009-12-11 11:09:01 +08:00
|
|
|
|
2010-07-04 08:00:41 +08:00
|
|
|
// Set the return value.
|
2010-12-02 15:49:45 +08:00
|
|
|
SVal retVal = svalBuilder.getConjuredSymbolVal(NULL, CE, CE->getType(), Count);
|
|
|
|
state = state->BindExpr(CE, retVal);
|
2009-12-11 11:09:01 +08:00
|
|
|
|
2010-07-04 08:00:41 +08:00
|
|
|
// Fill the region with the initialization value.
|
2010-12-02 15:49:45 +08:00
|
|
|
state = state->bindDefault(retVal, Init);
|
2010-06-01 11:01:33 +08:00
|
|
|
|
2010-07-04 08:00:41 +08:00
|
|
|
// Set the region's extent equal to the Size parameter.
|
2010-12-02 15:49:45 +08:00
|
|
|
const SymbolicRegion *R = cast<SymbolicRegion>(retVal.getAsRegion());
|
|
|
|
DefinedOrUnknownSVal Extent = R->getExtent(svalBuilder);
|
2010-07-04 08:00:41 +08:00
|
|
|
DefinedOrUnknownSVal DefinedSize = cast<DefinedOrUnknownSVal>(Size);
|
2010-12-02 15:49:45 +08:00
|
|
|
DefinedOrUnknownSVal extentMatchesSize =
|
2010-12-02 05:57:22 +08:00
|
|
|
svalBuilder.evalEQ(state, Extent, DefinedSize);
|
2010-07-04 08:00:41 +08:00
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
state = state->assume(extentMatchesSize, true);
|
|
|
|
assert(state);
|
|
|
|
|
|
|
|
SymbolRef Sym = retVal.getAsLocSymbol();
|
2009-11-12 16:38:56 +08:00
|
|
|
assert(Sym);
|
2010-12-02 15:49:45 +08:00
|
|
|
|
2009-11-12 16:38:56 +08:00
|
|
|
// Set the symbol's state to Allocated.
|
2009-12-31 14:13:07 +08:00
|
|
|
return state->set<RegionState>(Sym, RefState::getAllocateUnchecked(CE));
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) {
|
2010-07-31 09:52:11 +08:00
|
|
|
const GRState *state = FreeMemAux(C, CE, C.getState(), 0, false);
|
2009-12-12 20:29:38 +08:00
|
|
|
|
|
|
|
if (state)
|
|
|
|
C.addTransition(state);
|
|
|
|
}
|
|
|
|
|
2010-07-31 09:52:11 +08:00
|
|
|
void MallocChecker::FreeMemAttr(CheckerContext &C, const CallExpr *CE,
|
2010-08-12 16:54:03 +08:00
|
|
|
const OwnershipAttr* Att) {
|
2010-08-19 07:23:40 +08:00
|
|
|
if (Att->getModule() != "malloc")
|
2010-07-31 09:52:11 +08:00
|
|
|
return;
|
|
|
|
|
2010-08-19 07:23:40 +08:00
|
|
|
for (OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
|
|
|
|
I != E; ++I) {
|
|
|
|
const GRState *state = FreeMemAux(C, CE, C.getState(), *I,
|
|
|
|
Att->getOwnKind() == OwnershipAttr::Holds);
|
|
|
|
if (state)
|
|
|
|
C.addTransition(state);
|
2010-07-31 09:52:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-12 20:29:38 +08:00
|
|
|
const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE,
|
2010-07-31 09:52:11 +08:00
|
|
|
const GRState *state, unsigned Num,
|
|
|
|
bool Hold) {
|
|
|
|
const Expr *ArgExpr = CE->getArg(Num);
|
2010-06-08 03:32:37 +08:00
|
|
|
SVal ArgVal = state->getSVal(ArgExpr);
|
2010-02-14 14:49:48 +08:00
|
|
|
|
2010-07-31 09:52:11 +08:00
|
|
|
DefinedOrUnknownSVal location = cast<DefinedOrUnknownSVal>(ArgVal);
|
|
|
|
|
|
|
|
// Check for null dereferences.
|
|
|
|
if (!isa<Loc>(location))
|
2010-02-14 14:49:48 +08:00
|
|
|
return state;
|
2010-07-31 09:52:11 +08:00
|
|
|
|
|
|
|
// FIXME: Technically using 'Assume' here can result in a path
|
|
|
|
// bifurcation. In such cases we need to return two states, not just one.
|
|
|
|
const GRState *notNullState, *nullState;
|
2010-12-02 06:16:56 +08:00
|
|
|
llvm::tie(notNullState, nullState) = state->assume(location);
|
2010-07-31 09:52:11 +08:00
|
|
|
|
|
|
|
// The explicit NULL case, no operation is performed.
|
|
|
|
if (nullState && !notNullState)
|
|
|
|
return nullState;
|
|
|
|
|
|
|
|
assert(notNullState);
|
|
|
|
|
2010-06-08 03:32:37 +08:00
|
|
|
// Unknown values could easily be okay
|
|
|
|
// Undefined values are handled elsewhere
|
|
|
|
if (ArgVal.isUnknownOrUndef())
|
2010-07-31 09:52:11 +08:00
|
|
|
return notNullState;
|
2010-02-14 14:49:48 +08:00
|
|
|
|
2010-06-08 03:32:37 +08:00
|
|
|
const MemRegion *R = ArgVal.getAsRegion();
|
|
|
|
|
|
|
|
// Nonlocs can't be freed, of course.
|
|
|
|
// Non-region locations (labels and fixed addresses) also shouldn't be freed.
|
|
|
|
if (!R) {
|
|
|
|
ReportBadFree(C, ArgVal, ArgExpr->getSourceRange());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
R = R->StripCasts();
|
|
|
|
|
|
|
|
// Blocks might show up as heap data, but should not be free()d
|
|
|
|
if (isa<BlockDataRegion>(R)) {
|
|
|
|
ReportBadFree(C, ArgVal, ArgExpr->getSourceRange());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const MemSpaceRegion *MS = R->getMemorySpace();
|
|
|
|
|
|
|
|
// Parameters, locals, statics, and globals shouldn't be freed.
|
|
|
|
if (!(isa<UnknownSpaceRegion>(MS) || isa<HeapSpaceRegion>(MS))) {
|
|
|
|
// FIXME: at the time this code was written, malloc() regions were
|
|
|
|
// represented by conjured symbols, which are all in UnknownSpaceRegion.
|
|
|
|
// This means that there isn't actually anything from HeapSpaceRegion
|
|
|
|
// that should be freed, even though we allow it here.
|
|
|
|
// Of course, free() can work on memory allocated outside the current
|
|
|
|
// function, so UnknownSpaceRegion is always a possibility.
|
|
|
|
// False negatives are better than false positives.
|
|
|
|
|
|
|
|
ReportBadFree(C, ArgVal, ArgExpr->getSourceRange());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R);
|
2010-05-13 16:26:32 +08:00
|
|
|
// Various cases could lead to non-symbol values here.
|
2010-06-08 03:32:37 +08:00
|
|
|
// For now, ignore them.
|
|
|
|
if (!SR)
|
2010-07-31 09:52:11 +08:00
|
|
|
return notNullState;
|
2009-11-12 16:38:56 +08:00
|
|
|
|
2010-06-08 03:32:37 +08:00
|
|
|
SymbolRef Sym = SR->getSymbol();
|
2009-11-12 16:38:56 +08:00
|
|
|
const RefState *RS = state->get<RegionState>(Sym);
|
2010-01-18 11:27:34 +08:00
|
|
|
|
|
|
|
// If the symbol has not been tracked, return. This is possible when free() is
|
|
|
|
// called on a pointer that does not get its pointee directly from malloc().
|
|
|
|
// Full support of this requires inter-procedural analysis.
|
|
|
|
if (!RS)
|
2010-07-31 09:52:11 +08:00
|
|
|
return notNullState;
|
2009-11-12 16:38:56 +08:00
|
|
|
|
|
|
|
// Check double free.
|
2009-11-17 15:54:15 +08:00
|
|
|
if (RS->isReleased()) {
|
2010-12-21 05:19:09 +08:00
|
|
|
if (ExplodedNode *N = C.generateSink()) {
|
2009-11-12 16:38:56 +08:00
|
|
|
if (!BT_DoubleFree)
|
2010-07-31 09:52:11 +08:00
|
|
|
BT_DoubleFree
|
|
|
|
= new BuiltinBug("Double free",
|
2009-11-12 16:38:56 +08:00
|
|
|
"Try to free a memory block that has been released");
|
|
|
|
// FIXME: should find where it's freed last time.
|
|
|
|
BugReport *R = new BugReport(*BT_DoubleFree,
|
2009-11-14 20:08:24 +08:00
|
|
|
BT_DoubleFree->getDescription(), N);
|
2009-11-12 16:38:56 +08:00
|
|
|
C.EmitReport(R);
|
|
|
|
}
|
2009-12-12 20:29:38 +08:00
|
|
|
return NULL;
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Normal free.
|
2010-07-31 09:52:11 +08:00
|
|
|
if (Hold)
|
|
|
|
return notNullState->set<RegionState>(Sym, RefState::getRelinquished(CE));
|
|
|
|
return notNullState->set<RegionState>(Sym, RefState::getReleased(CE));
|
2009-12-12 20:29:38 +08:00
|
|
|
}
|
|
|
|
|
2010-06-08 03:32:37 +08:00
|
|
|
bool MallocChecker::SummarizeValue(llvm::raw_ostream& os, SVal V) {
|
|
|
|
if (nonloc::ConcreteInt *IntVal = dyn_cast<nonloc::ConcreteInt>(&V))
|
|
|
|
os << "an integer (" << IntVal->getValue() << ")";
|
|
|
|
else if (loc::ConcreteInt *ConstAddr = dyn_cast<loc::ConcreteInt>(&V))
|
|
|
|
os << "a constant address (" << ConstAddr->getValue() << ")";
|
|
|
|
else if (loc::GotoLabel *Label = dyn_cast<loc::GotoLabel>(&V))
|
|
|
|
os << "the address of the label '"
|
|
|
|
<< Label->getLabel()->getID()->getName()
|
|
|
|
<< "'";
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MallocChecker::SummarizeRegion(llvm::raw_ostream& os,
|
|
|
|
const MemRegion *MR) {
|
|
|
|
switch (MR->getKind()) {
|
|
|
|
case MemRegion::FunctionTextRegionKind: {
|
|
|
|
const FunctionDecl *FD = cast<FunctionTextRegion>(MR)->getDecl();
|
|
|
|
if (FD)
|
|
|
|
os << "the address of the function '" << FD << "'";
|
|
|
|
else
|
|
|
|
os << "the address of a function";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case MemRegion::BlockTextRegionKind:
|
|
|
|
os << "block text";
|
|
|
|
return true;
|
|
|
|
case MemRegion::BlockDataRegionKind:
|
|
|
|
// FIXME: where the block came from?
|
|
|
|
os << "a block";
|
|
|
|
return true;
|
|
|
|
default: {
|
|
|
|
const MemSpaceRegion *MS = MR->getMemorySpace();
|
|
|
|
|
|
|
|
switch (MS->getKind()) {
|
|
|
|
case MemRegion::StackLocalsSpaceRegionKind: {
|
|
|
|
const VarRegion *VR = dyn_cast<VarRegion>(MR);
|
|
|
|
const VarDecl *VD;
|
|
|
|
if (VR)
|
|
|
|
VD = VR->getDecl();
|
|
|
|
else
|
|
|
|
VD = NULL;
|
|
|
|
|
|
|
|
if (VD)
|
|
|
|
os << "the address of the local variable '" << VD->getName() << "'";
|
|
|
|
else
|
|
|
|
os << "the address of a local stack variable";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case MemRegion::StackArgumentsSpaceRegionKind: {
|
|
|
|
const VarRegion *VR = dyn_cast<VarRegion>(MR);
|
|
|
|
const VarDecl *VD;
|
|
|
|
if (VR)
|
|
|
|
VD = VR->getDecl();
|
|
|
|
else
|
|
|
|
VD = NULL;
|
|
|
|
|
|
|
|
if (VD)
|
|
|
|
os << "the address of the parameter '" << VD->getName() << "'";
|
|
|
|
else
|
|
|
|
os << "the address of a parameter";
|
|
|
|
return true;
|
|
|
|
}
|
2010-07-02 04:16:50 +08:00
|
|
|
case MemRegion::NonStaticGlobalSpaceRegionKind:
|
|
|
|
case MemRegion::StaticGlobalSpaceRegionKind: {
|
2010-06-08 03:32:37 +08:00
|
|
|
const VarRegion *VR = dyn_cast<VarRegion>(MR);
|
|
|
|
const VarDecl *VD;
|
|
|
|
if (VR)
|
|
|
|
VD = VR->getDecl();
|
|
|
|
else
|
|
|
|
VD = NULL;
|
|
|
|
|
|
|
|
if (VD) {
|
|
|
|
if (VD->isStaticLocal())
|
|
|
|
os << "the address of the static variable '" << VD->getName() << "'";
|
|
|
|
else
|
|
|
|
os << "the address of the global variable '" << VD->getName() << "'";
|
|
|
|
} else
|
|
|
|
os << "the address of a global variable";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MallocChecker::ReportBadFree(CheckerContext &C, SVal ArgVal,
|
|
|
|
SourceRange range) {
|
2010-12-21 05:19:09 +08:00
|
|
|
if (ExplodedNode *N = C.generateSink()) {
|
2010-06-08 03:32:37 +08:00
|
|
|
if (!BT_BadFree)
|
|
|
|
BT_BadFree = new BuiltinBug("Bad free");
|
|
|
|
|
|
|
|
llvm::SmallString<100> buf;
|
|
|
|
llvm::raw_svector_ostream os(buf);
|
|
|
|
|
|
|
|
const MemRegion *MR = ArgVal.getAsRegion();
|
|
|
|
if (MR) {
|
|
|
|
while (const ElementRegion *ER = dyn_cast<ElementRegion>(MR))
|
|
|
|
MR = ER->getSuperRegion();
|
|
|
|
|
|
|
|
// Special case for alloca()
|
|
|
|
if (isa<AllocaRegion>(MR))
|
|
|
|
os << "Argument to free() was allocated by alloca(), not malloc()";
|
|
|
|
else {
|
|
|
|
os << "Argument to free() is ";
|
|
|
|
if (SummarizeRegion(os, MR))
|
|
|
|
os << ", which is not memory allocated by malloc()";
|
|
|
|
else
|
|
|
|
os << "not memory allocated by malloc()";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
os << "Argument to free() is ";
|
|
|
|
if (SummarizeValue(os, ArgVal))
|
|
|
|
os << ", which is not memory allocated by malloc()";
|
|
|
|
else
|
|
|
|
os << "not memory allocated by malloc()";
|
|
|
|
}
|
|
|
|
|
2010-06-09 06:59:01 +08:00
|
|
|
EnhancedBugReport *R = new EnhancedBugReport(*BT_BadFree, os.str(), N);
|
2010-06-08 03:32:37 +08:00
|
|
|
R->addRange(range);
|
|
|
|
C.EmitReport(R);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-12 20:29:38 +08:00
|
|
|
void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) {
|
|
|
|
const GRState *state = C.getState();
|
2010-12-02 15:49:45 +08:00
|
|
|
const Expr *arg0Expr = CE->getArg(0);
|
|
|
|
DefinedOrUnknownSVal arg0Val
|
|
|
|
= cast<DefinedOrUnknownSVal>(state->getSVal(arg0Expr));
|
2009-12-12 20:29:38 +08:00
|
|
|
|
2010-12-02 05:28:31 +08:00
|
|
|
SValBuilder &svalBuilder = C.getSValBuilder();
|
2009-12-12 20:29:38 +08:00
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
DefinedOrUnknownSVal PtrEQ =
|
|
|
|
svalBuilder.evalEQ(state, arg0Val, svalBuilder.makeNull());
|
2009-12-12 20:29:38 +08:00
|
|
|
|
|
|
|
// If the ptr is NULL, the call is equivalent to malloc(size).
|
2010-12-02 06:16:56 +08:00
|
|
|
if (const GRState *stateEqual = state->assume(PtrEQ, true)) {
|
2009-12-12 20:29:38 +08:00
|
|
|
// Hack: set the NULL symbolic region to released to suppress false warning.
|
|
|
|
// In the future we should add more states for allocated regions, e.g.,
|
|
|
|
// CheckedNull, CheckedNonNull.
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
SymbolRef Sym = arg0Val.getAsLocSymbol();
|
2009-12-12 20:29:38 +08:00
|
|
|
if (Sym)
|
|
|
|
stateEqual = stateEqual->set<RegionState>(Sym, RefState::getReleased(CE));
|
|
|
|
|
2010-06-01 11:01:33 +08:00
|
|
|
const GRState *stateMalloc = MallocMemAux(C, CE, CE->getArg(1),
|
|
|
|
UndefinedVal(), stateEqual);
|
2009-12-12 20:29:38 +08:00
|
|
|
C.addTransition(stateMalloc);
|
|
|
|
}
|
|
|
|
|
2010-12-02 06:16:56 +08:00
|
|
|
if (const GRState *stateNotEqual = state->assume(PtrEQ, false)) {
|
2009-12-12 20:29:38 +08:00
|
|
|
const Expr *Arg1 = CE->getArg(1);
|
|
|
|
DefinedOrUnknownSVal Arg1Val =
|
2010-02-09 00:18:51 +08:00
|
|
|
cast<DefinedOrUnknownSVal>(stateNotEqual->getSVal(Arg1));
|
2010-12-02 15:49:45 +08:00
|
|
|
DefinedOrUnknownSVal SizeZero =
|
|
|
|
svalBuilder.evalEQ(stateNotEqual, Arg1Val,
|
|
|
|
svalBuilder.makeIntValWithPtrWidth(0, false));
|
2009-12-12 20:29:38 +08:00
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
if (const GRState *stateSizeZero = stateNotEqual->assume(SizeZero, true))
|
|
|
|
if (const GRState *stateFree = FreeMemAux(C, CE, stateSizeZero, 0, false))
|
2009-12-12 20:29:38 +08:00
|
|
|
C.addTransition(stateFree->BindExpr(CE, UndefinedVal(), true));
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
if (const GRState *stateSizeNotZero = stateNotEqual->assume(SizeZero,false))
|
|
|
|
if (const GRState *stateFree = FreeMemAux(C, CE, stateSizeNotZero,
|
|
|
|
0, false)) {
|
2009-12-12 20:29:38 +08:00
|
|
|
// FIXME: We should copy the content of the original buffer.
|
2010-01-18 16:54:31 +08:00
|
|
|
const GRState *stateRealloc = MallocMemAux(C, CE, CE->getArg(1),
|
2010-06-01 11:01:33 +08:00
|
|
|
UnknownVal(), stateFree);
|
2009-12-12 20:29:38 +08:00
|
|
|
C.addTransition(stateRealloc);
|
|
|
|
}
|
|
|
|
}
|
2009-11-12 16:38:56 +08:00
|
|
|
}
|
2009-11-13 15:25:27 +08:00
|
|
|
|
2010-06-01 11:01:33 +08:00
|
|
|
void MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE) {
|
|
|
|
const GRState *state = C.getState();
|
2010-12-02 05:28:31 +08:00
|
|
|
SValBuilder &svalBuilder = C.getSValBuilder();
|
2010-06-01 11:01:33 +08:00
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
SVal count = state->getSVal(CE->getArg(0));
|
|
|
|
SVal elementSize = state->getSVal(CE->getArg(1));
|
|
|
|
SVal TotalSize = svalBuilder.evalBinOp(state, BO_Mul, count, elementSize,
|
|
|
|
svalBuilder.getContext().getSizeType());
|
|
|
|
SVal zeroVal = svalBuilder.makeZeroVal(svalBuilder.getContext().CharTy);
|
2010-06-01 11:01:33 +08:00
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
C.addTransition(MallocMemAux(C, CE, TotalSize, zeroVal, state));
|
2010-06-01 11:01:33 +08:00
|
|
|
}
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
void MallocChecker::evalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper)
|
|
|
|
{
|
2010-08-15 16:19:57 +08:00
|
|
|
if (!SymReaper.hasDeadSymbols())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const GRState *state = C.getState();
|
|
|
|
RegionStateTy RS = state->get<RegionState>();
|
2010-08-18 12:33:47 +08:00
|
|
|
RegionStateTy::Factory &F = state->get_context<RegionState>();
|
2010-08-15 16:19:57 +08:00
|
|
|
|
|
|
|
for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
|
|
|
|
if (SymReaper.isDead(I->first)) {
|
|
|
|
if (I->second.isAllocated()) {
|
2010-12-21 05:19:09 +08:00
|
|
|
if (ExplodedNode *N = C.generateNode()) {
|
2010-08-15 16:19:57 +08:00
|
|
|
if (!BT_Leak)
|
|
|
|
BT_Leak = new BuiltinBug("Memory leak",
|
2009-11-13 15:48:11 +08:00
|
|
|
"Allocated memory never released. Potential memory leak.");
|
2010-08-15 16:19:57 +08:00
|
|
|
// FIXME: where it is allocated.
|
|
|
|
BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N);
|
|
|
|
C.EmitReport(R);
|
|
|
|
}
|
2009-11-13 15:48:11 +08:00
|
|
|
}
|
2010-08-18 12:33:47 +08:00
|
|
|
|
|
|
|
// Remove the dead symbol from the map.
|
2010-11-24 08:54:37 +08:00
|
|
|
RS = F.remove(RS, I->first);
|
2009-11-13 15:48:11 +08:00
|
|
|
}
|
|
|
|
}
|
2010-12-21 05:19:09 +08:00
|
|
|
C.generateNode(state->set<RegionState>(RS));
|
2009-11-13 15:25:27 +08:00
|
|
|
}
|
2009-11-17 15:54:15 +08:00
|
|
|
|
2011-01-11 10:34:45 +08:00
|
|
|
void MallocChecker::evalEndPath(EndOfFunctionNodeBuilder &B, void *tag,
|
2010-12-23 02:53:44 +08:00
|
|
|
ExprEngine &Eng) {
|
2009-11-17 15:54:15 +08:00
|
|
|
const GRState *state = B.getState();
|
2010-08-18 12:26:59 +08:00
|
|
|
RegionStateTy M = state->get<RegionState>();
|
2009-11-17 15:54:15 +08:00
|
|
|
|
2010-08-18 12:26:59 +08:00
|
|
|
for (RegionStateTy::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
2009-11-17 15:54:15 +08:00
|
|
|
RefState RS = I->second;
|
|
|
|
if (RS.isAllocated()) {
|
|
|
|
ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
|
|
|
|
if (N) {
|
|
|
|
if (!BT_Leak)
|
|
|
|
BT_Leak = new BuiltinBug("Memory leak",
|
|
|
|
"Allocated memory never released. Potential memory leak.");
|
|
|
|
BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N);
|
|
|
|
Eng.getBugReporter().EmitReport(R);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-17 16:58:18 +08:00
|
|
|
|
|
|
|
void MallocChecker::PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S) {
|
2010-12-02 15:49:45 +08:00
|
|
|
const Expr *retExpr = S->getRetValue();
|
|
|
|
if (!retExpr)
|
2009-11-17 16:58:18 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
const GRState *state = C.getState();
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
SymbolRef Sym = state->getSVal(retExpr).getAsSymbol();
|
2009-11-17 16:58:18 +08:00
|
|
|
if (!Sym)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const RefState *RS = state->get<RegionState>(Sym);
|
|
|
|
if (!RS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// FIXME: check other cases.
|
|
|
|
if (RS->isAllocated())
|
|
|
|
state = state->set<RegionState>(Sym, RefState::getEscaped(S));
|
|
|
|
|
2009-11-24 06:22:01 +08:00
|
|
|
C.addTransition(state);
|
2009-11-17 16:58:18 +08:00
|
|
|
}
|
2009-12-31 14:13:07 +08:00
|
|
|
|
2010-12-02 05:57:22 +08:00
|
|
|
const GRState *MallocChecker::evalAssume(const GRState *state, SVal Cond,
|
2010-08-04 15:10:57 +08:00
|
|
|
bool Assumption,
|
|
|
|
bool * /* respondsToCallback */) {
|
2009-12-31 14:13:07 +08:00
|
|
|
// If a symblic region is assumed to NULL, set its state to AllocateFailed.
|
|
|
|
// FIXME: should also check symbols assumed to non-null.
|
|
|
|
|
|
|
|
RegionStateTy RS = state->get<RegionState>();
|
|
|
|
|
|
|
|
for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
|
|
|
|
if (state->getSymVal(I.getKey()))
|
|
|
|
state = state->set<RegionState>(I.getKey(),RefState::getAllocateFailed());
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
2010-03-10 12:58:55 +08:00
|
|
|
|
|
|
|
// Check if the location is a freed symbolic region.
|
2011-01-12 03:45:13 +08:00
|
|
|
void MallocChecker::visitLocation(CheckerContext &C, const Stmt *S, SVal l,
|
|
|
|
bool isLoad) {
|
2010-03-10 12:58:55 +08:00
|
|
|
SymbolRef Sym = l.getLocSymbolInBase();
|
|
|
|
if (Sym) {
|
|
|
|
const RefState *RS = C.getState()->get<RegionState>(Sym);
|
2010-08-07 05:12:49 +08:00
|
|
|
if (RS && RS->isReleased()) {
|
2010-12-21 05:19:09 +08:00
|
|
|
if (ExplodedNode *N = C.generateNode()) {
|
2010-03-10 12:58:55 +08:00
|
|
|
if (!BT_UseFree)
|
|
|
|
BT_UseFree = new BuiltinBug("Use dynamically allocated memory after"
|
|
|
|
" it is freed.");
|
|
|
|
|
|
|
|
BugReport *R = new BugReport(*BT_UseFree, BT_UseFree->getDescription(),
|
|
|
|
N);
|
|
|
|
C.EmitReport(R);
|
|
|
|
}
|
2010-08-07 05:12:49 +08:00
|
|
|
}
|
2010-03-10 12:58:55 +08:00
|
|
|
}
|
|
|
|
}
|
2010-07-31 09:52:11 +08:00
|
|
|
|
|
|
|
void MallocChecker::PreVisitBind(CheckerContext &C,
|
|
|
|
const Stmt *StoreE,
|
|
|
|
SVal location,
|
|
|
|
SVal val) {
|
|
|
|
// The PreVisitBind implements the same algorithm as already used by the
|
|
|
|
// Objective C ownership checker: if the pointer escaped from this scope by
|
|
|
|
// assignment, let it go. However, assigning to fields of a stack-storage
|
|
|
|
// structure does not transfer ownership.
|
|
|
|
|
|
|
|
const GRState *state = C.getState();
|
|
|
|
DefinedOrUnknownSVal l = cast<DefinedOrUnknownSVal>(location);
|
|
|
|
|
|
|
|
// Check for null dereferences.
|
|
|
|
if (!isa<Loc>(l))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Before checking if the state is null, check if 'val' has a RefState.
|
|
|
|
// Only then should we check for null and bifurcate the state.
|
|
|
|
SymbolRef Sym = val.getLocSymbolInBase();
|
|
|
|
if (Sym) {
|
|
|
|
if (const RefState *RS = state->get<RegionState>(Sym)) {
|
|
|
|
// If ptr is NULL, no operation is performed.
|
|
|
|
const GRState *notNullState, *nullState;
|
2010-12-02 06:16:56 +08:00
|
|
|
llvm::tie(notNullState, nullState) = state->assume(l);
|
2010-07-31 09:52:11 +08:00
|
|
|
|
|
|
|
// Generate a transition for 'nullState' to record the assumption
|
|
|
|
// that the state was null.
|
|
|
|
if (nullState)
|
|
|
|
C.addTransition(nullState);
|
|
|
|
|
|
|
|
if (!notNullState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (RS->isAllocated()) {
|
|
|
|
// Something we presently own is being assigned somewhere.
|
|
|
|
const MemRegion *AR = location.getAsRegion();
|
|
|
|
if (!AR)
|
|
|
|
return;
|
|
|
|
AR = AR->StripCasts()->getBaseRegion();
|
|
|
|
do {
|
|
|
|
// If it is on the stack, we still own it.
|
|
|
|
if (AR->hasStackNonParametersStorage())
|
|
|
|
break;
|
|
|
|
|
|
|
|
// If the state can't represent this binding, we still own it.
|
2010-08-07 05:12:55 +08:00
|
|
|
if (notNullState == (notNullState->bindLoc(cast<Loc>(location),
|
|
|
|
UnknownVal())))
|
2010-07-31 09:52:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
// We no longer own this pointer.
|
2010-08-07 05:12:55 +08:00
|
|
|
notNullState =
|
|
|
|
notNullState->set<RegionState>(Sym,
|
|
|
|
RefState::getRelinquished(StoreE));
|
2010-07-31 09:52:11 +08:00
|
|
|
}
|
|
|
|
while (false);
|
|
|
|
}
|
|
|
|
C.addTransition(notNullState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|