diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-21 01:25:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-21 01:25:37 +0000 |
commit | c79d7d49c5ec42e8bb6ac34350ebb5bc24ca663d (patch) | |
tree | 81bb9b03ff5e625bc5005514329598719b8cf30e /lib/Analysis/BadCallChecker.cpp | |
parent | 9cf910efc4fb7001a6d276ed2eabf01f0f0efaaa (diff) |
Pull BadCallChecker int UndefinedArgChecker, and have UndefinedArgChecker also handled undefined receivers in message expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BadCallChecker.cpp')
-rw-r--r-- | lib/Analysis/BadCallChecker.cpp | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/lib/Analysis/BadCallChecker.cpp b/lib/Analysis/BadCallChecker.cpp deleted file mode 100644 index 7a7ea188ba..0000000000 --- a/lib/Analysis/BadCallChecker.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===--- BadCallChecker.h - Bad call checker --------------------*- C++ -*--==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This defines BadCallChecker, a builtin check in GRExprEngine that performs -// checks for bad callee at call sites. -// -//===----------------------------------------------------------------------===// - -#include "clang/Analysis/PathSensitive/CheckerVisitor.h" -#include "clang/Analysis/PathSensitive/BugReporter.h" -#include "GRExprEngineInternalChecks.h" - -using namespace clang; - -namespace { -class VISIBILITY_HIDDEN BadCallChecker : public CheckerVisitor<BadCallChecker> { - BuiltinBug *BT; -public: - BadCallChecker() : BT(0) {} - static void *getTag() { - static int x = 0; - return &x; - } - void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); -}; -} // end anonymous namespace - -void clang::RegisterBadCallChecker(GRExprEngine &Eng) { - Eng.registerCheck(new BadCallChecker()); -} - -void BadCallChecker::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE) { - const Expr *Callee = CE->getCallee()->IgnoreParens(); - SVal L = C.getState()->getSVal(Callee); - - if (L.isUndef() || isa<loc::ConcreteInt>(L)) { - if (ExplodedNode *N = C.GenerateNode(CE, true)) { - if (!BT) - BT = new BuiltinBug("Invalid function call", - "Called function pointer is a null or undefined pointer value"); - - EnhancedBugReport *R = - new EnhancedBugReport(*BT, BT->getDescription(), N); - - R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, - bugreporter::GetCalleeExpr(N)); - - C.EmitReport(R); - } - } -} |