[cfe-commits] r48886 - in /cfe/trunk/lib/Analysis: BasicObjCFoundationChecks.cpp BasicObjCFoundationChecks.h GRSimpleVals.cpp
Ted Kremenek
kremenek at apple.com
Thu Mar 27 10:17:22 PDT 2008
Author: kremenek
Date: Thu Mar 27 12:17:22 2008
New Revision: 48886
URL: http://llvm.org/viewvc/llvm-project?rev=48886&view=rev
Log:
Add creation of BasicObjCFoundationChecks when running GRSimpleVals from the driver.
Added:
cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h
Modified:
cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/Analysis/GRSimpleVals.cpp
Modified: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp?rev=48886&r1=48885&r2=48886&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp Thu Mar 27 12:17:22 2008
@@ -13,6 +13,8 @@
//
//===----------------------------------------------------------------------===//
+#include "BasicObjCFoundationChecks.h"
+
#include "clang/Analysis/PathSensitive/ExplodedGraph.h"
#include "clang/Analysis/PathSensitive/GRSimpleAPICheck.h"
#include "clang/Analysis/PathSensitive/ValueState.h"
@@ -53,6 +55,14 @@
} // end anonymous namespace
+GRSimpleAPICheck*
+clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx,
+ ValueStateManager* VMgr) {
+
+ return new BasicObjCFoundationChecks(Ctx, VMgr);
+}
+
+
bool BasicObjCFoundationChecks::Audit(ExplodedNode<ValueState>* N) {
ObjCMessageExpr* ME =
Added: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h?rev=48886&view=auto
==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h (added)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h Thu Mar 27 12:17:22 2008
@@ -0,0 +1,39 @@
+//== BasicObjCFoundationChecks.h - Simple Apple-Foundation checks -*- 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 BasicObjCFoundationChecks, a class that encapsulates
+// a set of simple checks to run on Objective-C code using Apple's Foundation
+// classes.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/PathSensitive/ExplodedGraph.h"
+#include "clang/Analysis/PathSensitive/GRSimpleAPICheck.h"
+#include "clang/Analysis/PathSensitive/ValueState.h"
+#include "clang/Analysis/PathSensitive/AnnotatedPath.h"
+#include "clang/Analysis/PathDiagnostic.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ASTContext.h"
+#include "llvm/Support/Compiler.h"
+
+#ifndef LLVM_CLANG_ANALYSIS_BASICOBJCFOUNDATIONCHECKS
+#define LLVM_CLANG_ANALYSIS_BASICOBJCFOUNDATIONCHECKS
+
+namespace clang {
+
+class GRSimpleAPICheck;
+class ASTContext;
+class ValueStateManager;
+
+GRSimpleAPICheck* CreateBasicObjCFoundationChecks(ASTContext& Ctx,
+ ValueStateManager* VMgr);
+
+} // end clang namespace
+
+#endif
Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=48886&r1=48885&r2=48886&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Thu Mar 27 12:17:22 2008
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "GRSimpleVals.h"
+#include "BasicObjCFoundationChecks.h"
#include "clang/Analysis/PathSensitive/ValueState.h"
#include "clang/Basic/Diagnostic.h"
#include <sstream>
@@ -103,14 +104,19 @@
unsigned RunGRSimpleVals(CFG& cfg, Decl& CD, ASTContext& Ctx,
Diagnostic& Diag, bool Visualize, bool TrimGraph) {
- if (Diag.hasErrorOccurred())
- return 0;
-
GRCoreEngine<GRExprEngine> Eng(cfg, CD, Ctx);
GRExprEngine* CheckerState = &Eng.getCheckerState();
+
+ // Set base transfer functions.
GRSimpleVals GRSV;
CheckerState->setTransferFunctions(GRSV);
+ // Add extra checkers.
+ llvm::OwningPtr<GRSimpleAPICheck> FoundationCheck(
+ CreateBasicObjCFoundationChecks(Ctx, &CheckerState->getStateManager()));
+
+ CheckerState->AddObjCMessageExprCheck(FoundationCheck.get());
+
// Execute the worklist algorithm.
Eng.ExecuteWorkList(100000);
More information about the cfe-commits
mailing list