diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-06 00:08:09 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-06 00:08:09 +0000 |
commit | 2fff37ecce1efd21ecb9bb4937dca83bdea715ff (patch) | |
tree | 8cc5a4ad1a9c80f6e847c575945a5867d6384551 /Analysis/CFRefCount.cpp | |
parent | cb0ab296dd7942b951ca84a0b82b954e3642b116 (diff) |
Added boilerplate to execute the CF reference count checker (which isn't yet implemented).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Analysis/CFRefCount.cpp')
-rw-r--r-- | Analysis/CFRefCount.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Analysis/CFRefCount.cpp b/Analysis/CFRefCount.cpp new file mode 100644 index 0000000000..188ce7084c --- /dev/null +++ b/Analysis/CFRefCount.cpp @@ -0,0 +1,65 @@ +// CFRefCount.cpp - Transfer functions for tracking simple values -*- C++ -*-- +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This files defines the methods for CFRefCount, which implements +// a reference count checker for Core Foundation (Mac OS X). +// +//===----------------------------------------------------------------------===// + +#include "CFRefCount.h" +#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Analysis/LocalCheckers.h" + + +using namespace clang; + + +namespace clang { + +void CheckCFRefCount(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx, + Diagnostic& Diag) { + + if (Diag.hasErrorOccurred()) + return; + + // FIXME: Refactor some day so this becomes a single function invocation. + + GRCoreEngine<GRExprEngine> Engine(cfg, FD, Ctx); + GRExprEngine* CS = &Engine.getCheckerState(); + CFRefCount TF; + CS->setTransferFunctions(TF); + Engine.ExecuteWorkList(20000); + +} + +} + +void CFRefCount::EvalCall(ExplodedNodeSet<ValueState>& Dst, + ValueStateManager& StateMgr, + GRStmtNodeBuilder<ValueState>& Builder, + ValueManager& ValMgr, + CallExpr* CE, LVal L, + ExplodedNode<ValueState>* Pred) { + + ValueState* St = Pred->getState(); + + // Invalidate all arguments passed in by reference (LVals). + + for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end(); + I != E; ++I) { + + RVal V = StateMgr.GetRVal(St, *I); + + if (isa<LVal>(V)) + St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal()); + } + + Builder.Nodify(Dst, CE, Pred, St); +} |