diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:27:07 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:27:07 +0000 |
| commit | f3ed8b631d780be6b7c8ea6a6842a19ae64feae7 (patch) | |
| tree | e8b6c9e2db85d40f8dddcdcc429876689e3b8704 /clang/lib/StaticAnalyzer | |
| parent | b2cf708395328da8b00181fbc935b5326ca594ed (diff) | |
| download | bcm5719-llvm-f3ed8b631d780be6b7c8ea6a6842a19ae64feae7.tar.gz bcm5719-llvm-f3ed8b631d780be6b7c8ea6a6842a19ae64feae7.zip | |
[analyzer] Migrate BuiltinFunctionChecker to CheckerV2.
llvm-svn: 126611
Diffstat (limited to 'clang/lib/StaticAnalyzer')
4 files changed, 20 insertions, 14 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp index 417b015ca39..1a86120c1c7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp @@ -11,8 +11,10 @@ // //===----------------------------------------------------------------------===// -#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>(); +} diff --git a/clang/lib/StaticAnalyzer/Checkers/Checkers.td b/clang/lib/StaticAnalyzer/Checkers/Checkers.td index c453da96cf4..db81af06807 100644 --- a/clang/lib/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/lib/StaticAnalyzer/Checkers/Checkers.td @@ -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">, diff --git a/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index 14c29dd4b5a..eec2ad3b7c0 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -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) diff --git a/clang/lib/StaticAnalyzer/Checkers/InternalChecks.h b/clang/lib/StaticAnalyzer/Checkers/InternalChecks.h index 5714aca7609..9ce1d7eb2ff 100644 --- a/clang/lib/StaticAnalyzer/Checkers/InternalChecks.h +++ b/clang/lib/StaticAnalyzer/Checkers/InternalChecks.h @@ -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); |

