]> granicus.if.org Git - clang/commitdiff
Add creation of BasicObjCFoundationChecks when running GRSimpleVals from the driver.
authorTed Kremenek <kremenek@apple.com>
Thu, 27 Mar 2008 17:17:22 +0000 (17:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 27 Mar 2008 17:17:22 +0000 (17:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48886 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicObjCFoundationChecks.cpp
lib/Analysis/BasicObjCFoundationChecks.h [new file with mode: 0644]
lib/Analysis/GRSimpleVals.cpp

index 0fae7ddcd38f4ec84485b4f6842bd32e394248d6..4d7a4d99db8b86d5bd2c3c97b576a24472dac245 100644 (file)
@@ -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 @@ public:
 } // end anonymous namespace
 
 
+GRSimpleAPICheck*
+clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx,
+                                       ValueStateManager* VMgr) {
+  
+  return new BasicObjCFoundationChecks(Ctx, VMgr);  
+}
+
+
 bool BasicObjCFoundationChecks::Audit(ExplodedNode<ValueState>* N) {
   
   ObjCMessageExpr* ME =
diff --git a/lib/Analysis/BasicObjCFoundationChecks.h b/lib/Analysis/BasicObjCFoundationChecks.h
new file mode 100644 (file)
index 0000000..df2992b
--- /dev/null
@@ -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
index b6e6b5087f1dcb6d1201085873bf7535ed76045b..520f6246bfef3a020f12d55f9295b387106bdb91 100644 (file)
@@ -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 @@ void EmitWarning(Diagnostic& Diag, SourceManager& SrcMgr,
 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);