]> granicus.if.org Git - clang/commitdiff
[analyzer] Migrate BuiltinFunctionChecker to CheckerV2.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Feb 2011 01:27:07 +0000 (01:27 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Feb 2011 01:27:07 +0000 (01:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126611 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
lib/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/ExprEngine.cpp
lib/StaticAnalyzer/Checkers/InternalChecks.h
test/Analysis/free.c
test/Analysis/outofbound.c
test/Analysis/stack-addr-ps.c
test/Analysis/stackaddrleak.c

index 417b015ca39aea3490a7e691dc5587e7b79adab0..1a86120c1c7e44250552fa21381c1d0884de8aca 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "InternalChecks.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/Checker.h"
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/CheckerV2.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/Basic/Builtins.h"
 
 using namespace clang;
@@ -20,19 +22,15 @@ using namespace ento;
 
 namespace {
 
-class BuiltinFunctionChecker : public Checker {
+class BuiltinFunctionChecker : public CheckerV2<eval::Call> {
 public:
-  static void *getTag() { static int tag = 0; return &tag; }
-  virtual bool evalCallExpr(CheckerContext &C, const CallExpr *CE);
+  bool evalCall(const CallExpr *CE, CheckerContext &C) const;
 };
 
 }
 
-void ento::RegisterBuiltinFunctionChecker(ExprEngine &Eng) {
-  Eng.registerCheck(new BuiltinFunctionChecker());
-}
-
-bool BuiltinFunctionChecker::evalCallExpr(CheckerContext &C,const CallExpr *CE){
+bool BuiltinFunctionChecker::evalCall(const CallExpr *CE,
+                                      CheckerContext &C) const{
   const GRState *state = C.getState();
   const Expr *Callee = CE->getCallee();
   SVal L = state->getSVal(Callee);
@@ -81,3 +79,7 @@ bool BuiltinFunctionChecker::evalCallExpr(CheckerContext &C,const CallExpr *CE){
 
   return false;
 }
+
+void ento::registerBuiltinFunctionChecker(CheckerManager &mgr) {
+  mgr.registerChecker<BuiltinFunctionChecker>();
+}
index c453da96cf4e2cabed79a71061619df46c3a129a..db81af06807aa57fd508ef28bdaccfbb10d0c8c5 100644 (file)
@@ -73,16 +73,22 @@ def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">,
 
 } // end "cocoa"
 
+let ParentPackage = Core in {
+
+def BuiltinFunctionChecker : Checker<"BuiltinFunc">,
+  HelpText<"Evaluate clang builtin functions">,
+  DescFile<"BuiltinFunctionChecker.cpp">;
+
 def StackAddrEscapeChecker : Checker<"StackAddrEscape">,
-  InPackage<Core>,
   HelpText<"Check that addresses to stack memory do not escape the function">,
   DescFile<"StackAddrEscapeChecker.cpp">;
 
 def DeadStoresChecker : Checker<"DeadStores">,
-  InPackage<Core>,
   HelpText<"Check for values stored to a variables that are never read afterwards">,
   DescFile<"DeadStoresChecker.cpp">;
 
+} // end "core"
+
 def UnixAPIChecker : Checker<"API">,
   InPackage<Unix>,
   HelpText<"Check calls to various UNIX/Posix functions">,
index 14c29dd4b5a13cc4616c11df9cb9cd682cf6cf75..eec2ad3b7c02b219b08576ba6c36188eaf96b1e6 100644 (file)
@@ -336,7 +336,6 @@ static void RegisterInternalChecks(ExprEngine &Eng) {
 
   // This is not a checker yet.
   RegisterNoReturnFunctionChecker(Eng);
-  RegisterBuiltinFunctionChecker(Eng);
 }
 
 ExprEngine::ExprEngine(AnalysisManager &mgr, TransferFuncs *tf)
index 5714aca7609d4b21c9b03d6a686b6136e4029c0f..9ce1d7eb2ff28a4c7d5cf964dc58feaeec8d8a67 100644 (file)
@@ -24,7 +24,6 @@ class ExprEngine;
 // Foundational checks that handle basic semantics.
 void RegisterAdjustedReturnValueChecker(ExprEngine &Eng);
 void RegisterAttrNonNullChecker(ExprEngine &Eng);
-void RegisterBuiltinFunctionChecker(ExprEngine &Eng);
 void RegisterCallAndMessageChecker(ExprEngine &Eng);
 void RegisterDereferenceChecker(ExprEngine &Eng);
 void RegisterDivZeroChecker(ExprEngine &Eng);
index 78d3a2ed5f9622e9e09d04ee8ed7ba95997202fc..814a5557f0362d553eeef5b14a3085c73cfa7e99 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-checker=core.experimental.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-checker=core,core.experimental.Malloc -fblocks -verify %s
 void free(void *);
 
 void t1 () {
index e6591d3252a8246e4bd88bc54a5ac9e4589acf00..21bf676cfd9af0615440d72b6e5b480a7dc7f73a 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,core.experimental -analyzer-check-objc-mem -analyzer-store=region -verify %s
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
index 8e7e7dfd9a408ec9d72c1fe84d77c35110e7ed99..297ae74fcd84b03d9e72c42cda7c2827a5d9e42c 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrEscape -analyzer-store=basic -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrEscape -analyzer-store=region -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core -analyzer-store=basic -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core -analyzer-store=region -fblocks -verify %s
 
 int* f1() {
   int x = 0;
index f19eddc811e84b901451b3718408bc96c16109ea..e142924d7302b6a8b9e5d25c6df1c831704dbe68 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrEscape -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core -analyzer-store region -verify %s
 
 char const *p;