aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Checker')
-rw-r--r--lib/Checker/AdjustedReturnValueChecker.cpp95
-rw-r--r--lib/Checker/AggExprVisitor.cpp62
-rw-r--r--lib/Checker/AnalysisConsumer.cpp603
-rw-r--r--lib/Checker/AnalysisManager.cpp31
-rw-r--r--lib/Checker/AnalyzerStatsChecker.cpp119
-rw-r--r--lib/Checker/ArrayBoundChecker.cpp90
-rw-r--r--lib/Checker/AttrNonNullChecker.cpp135
-rw-r--r--lib/Checker/BasicConstraintManager.cpp335
-rw-r--r--lib/Checker/BasicObjCFoundationChecks.cpp520
-rw-r--r--lib/Checker/BasicObjCFoundationChecks.h31
-rw-r--r--lib/Checker/BasicStore.cpp593
-rw-r--r--lib/Checker/BasicValueFactory.cpp289
-rw-r--r--lib/Checker/BugReporter.cpp1891
-rw-r--r--lib/Checker/BugReporterVisitors.cpp459
-rw-r--r--lib/Checker/BuiltinFunctionChecker.cpp82
-rw-r--r--lib/Checker/CFRefCount.cpp3495
-rw-r--r--lib/Checker/CMakeLists.txt88
-rw-r--r--lib/Checker/CStringChecker.cpp1045
-rw-r--r--lib/Checker/CallAndMessageChecker.cpp349
-rw-r--r--lib/Checker/CastSizeChecker.cpp90
-rw-r--r--lib/Checker/CastToStructChecker.cpp78
-rw-r--r--lib/Checker/CheckDeadStores.cpp289
-rw-r--r--lib/Checker/CheckObjCDealloc.cpp261
-rw-r--r--lib/Checker/CheckObjCInstMethSignature.cpp119
-rw-r--r--lib/Checker/CheckSecuritySyntaxOnly.cpp502
-rw-r--r--lib/Checker/CheckSizeofPointer.cpp71
-rw-r--r--lib/Checker/Checker.cpp35
-rw-r--r--lib/Checker/CheckerHelpers.cpp80
-rw-r--r--lib/Checker/ChrootChecker.cpp161
-rw-r--r--lib/Checker/DereferenceChecker.cpp203
-rw-r--r--lib/Checker/DivZeroChecker.cpp85
-rw-r--r--lib/Checker/Environment.cpp235
-rw-r--r--lib/Checker/ExplodedGraph.cpp281
-rw-r--r--lib/Checker/FixedAddressChecker.cpp71
-rw-r--r--lib/Checker/FlatStore.cpp202
-rw-r--r--lib/Checker/FrontendActions.cpp21
-rw-r--r--lib/Checker/GRBlockCounter.cpp85
-rw-r--r--lib/Checker/GRCXXExprEngine.cpp327
-rw-r--r--lib/Checker/GRCoreEngine.cpp806
-rw-r--r--lib/Checker/GRExprEngine.cpp3509
-rw-r--r--lib/Checker/GRExprEngineExperimentalChecks.cpp45
-rw-r--r--lib/Checker/GRExprEngineExperimentalChecks.h32
-rw-r--r--lib/Checker/GRExprEngineInternalChecks.h53
-rw-r--r--lib/Checker/GRState.cpp550
-rw-r--r--lib/Checker/HTMLDiagnostics.cpp577
-rw-r--r--lib/Checker/IdempotentOperationChecker.cpp833
-rw-r--r--lib/Checker/LLVMConventionsChecker.cpp312
-rw-r--r--lib/Checker/MacOSXAPIChecker.cpp141
-rw-r--r--lib/Checker/Makefile18
-rw-r--r--lib/Checker/MallocChecker.cpp730
-rw-r--r--lib/Checker/ManagerRegistry.cpp20
-rw-r--r--lib/Checker/MemRegion.cpp986
-rw-r--r--lib/Checker/NSAutoreleasePoolChecker.cpp86
-rw-r--r--lib/Checker/NSErrorChecker.cpp237
-rw-r--r--lib/Checker/NoReturnFunctionChecker.cpp79
-rw-r--r--lib/Checker/OSAtomicChecker.cpp202
-rw-r--r--lib/Checker/ObjCAtSyncChecker.cpp94
-rw-r--r--lib/Checker/ObjCUnusedIVarsChecker.cpp163
-rw-r--r--lib/Checker/PathDiagnostic.cpp278
-rw-r--r--lib/Checker/PlistDiagnostics.cpp471
-rw-r--r--lib/Checker/PointerArithChecker.cpp71
-rw-r--r--lib/Checker/PointerSubChecker.cpp78
-rw-r--r--lib/Checker/PthreadLockChecker.cpp144
-rw-r--r--lib/Checker/README.txt117
-rw-r--r--lib/Checker/RangeConstraintManager.cpp439
-rw-r--r--lib/Checker/RegionStore.cpp1871
-rw-r--r--lib/Checker/ReturnPointerRangeChecker.cpp94
-rw-r--r--lib/Checker/ReturnUndefChecker.cpp68
-rw-r--r--lib/Checker/SValBuilder.cpp309
-rw-r--r--lib/Checker/SVals.cpp355
-rw-r--r--lib/Checker/SimpleConstraintManager.cpp299
-rw-r--r--lib/Checker/SimpleConstraintManager.h89
-rw-r--r--lib/Checker/SimpleSValBuilder.cpp883
-rw-r--r--lib/Checker/StackAddrLeakChecker.cpp204
-rw-r--r--lib/Checker/Store.cpp333
-rw-r--r--lib/Checker/StreamChecker.cpp463
-rw-r--r--lib/Checker/SymbolManager.cpp342
-rw-r--r--lib/Checker/TextPathDiagnostics.cpp69
-rw-r--r--lib/Checker/UndefBranchChecker.cpp119
-rw-r--r--lib/Checker/UndefCapturedBlockVarChecker.cpp101
-rw-r--r--lib/Checker/UndefResultChecker.cpp86
-rw-r--r--lib/Checker/UndefinedArraySubscriptChecker.cpp56
-rw-r--r--lib/Checker/UndefinedAssignmentChecker.cpp93
-rw-r--r--lib/Checker/UnixAPIChecker.cpp276
-rw-r--r--lib/Checker/UnreachableCodeChecker.cpp222
-rw-r--r--lib/Checker/VLASizeChecker.cpp137
86 files changed, 0 insertions, 31048 deletions
diff --git a/lib/Checker/AdjustedReturnValueChecker.cpp b/lib/Checker/AdjustedReturnValueChecker.cpp
deleted file mode 100644
index 281d74f926..0000000000
--- a/lib/Checker/AdjustedReturnValueChecker.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-//== AdjustedReturnValueChecker.cpp -----------------------------*- 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 AdjustedReturnValueChecker, a simple check to see if the
-// return value of a function call is different than the one the caller thinks
-// it is.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugReporter.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-
-using namespace clang;
-
-namespace {
-class AdjustedReturnValueChecker :
- public CheckerVisitor<AdjustedReturnValueChecker> {
-public:
- AdjustedReturnValueChecker() {}
-
- void PostVisitCallExpr(CheckerContext &C, const CallExpr *CE);
-
- static void *getTag() {
- static int x = 0; return &x;
- }
-};
-}
-
-void clang::RegisterAdjustedReturnValueChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new AdjustedReturnValueChecker());
-}
-
-void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
- const CallExpr *CE) {
-
- // Get the result type of the call.
- QualType expectedResultTy = CE->getType();
-
- // Fetch the signature of the called function.
- const GRState *state = C.getState();
-
- SVal V = state->getSVal(CE);
-
- if (V.isUnknown())
- return;
-
- // Casting to void? Discard the value.
- if (expectedResultTy->isVoidType()) {
- C.generateNode(state->BindExpr(CE, UnknownVal()));
- return;
- }
-
- const MemRegion *callee = state->getSVal(CE->getCallee()).getAsRegion();
- if (!callee)
- return;
-
- QualType actualResultTy;
-
- if (const FunctionTextRegion *FT = dyn_cast<FunctionTextRegion>(callee)) {
- const FunctionDecl *FD = FT->getDecl();
- actualResultTy = FD->getResultType();
- }
- else if (const BlockDataRegion *BD = dyn_cast<BlockDataRegion>(callee)) {
- const BlockTextRegion *BR = BD->getCodeRegion();
- const BlockPointerType *BT=BR->getLocationType()->getAs<BlockPointerType>();
- const FunctionType *FT = BT->getPointeeType()->getAs<FunctionType>();
- actualResultTy = FT->getResultType();
- }
-
- // Can this happen?
- if (actualResultTy.isNull())
- return;
-
- // For now, ignore references.
- if (actualResultTy->getAs<ReferenceType>())
- return;
-
-
- // Are they the same?
- if (expectedResultTy != actualResultTy) {
- // FIXME: Do more checking and actual emit an error. At least performing
- // the cast avoids some assertion failures elsewhere.
- SValBuilder &svalBuilder = C.getSValBuilder();
- V = svalBuilder.evalCast(V, expectedResultTy, actualResultTy);
- C.generateNode(state->BindExpr(CE, V));
- }
-}
diff --git a/lib/Checker/AggExprVisitor.cpp b/lib/Checker/AggExprVisitor.cpp
deleted file mode 100644
index b8ec92ff81..0000000000
--- a/lib/Checker/AggExprVisitor.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-//=-- AggExprVisitor.cpp - evaluating expressions of C++ class type -*- 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 AggExprVisitor class, which contains lots of boiler
-// plate code for evaluating expressions of C++ class type.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-#include "clang/AST/StmtVisitor.h"
-
-using namespace clang;
-
-namespace {
-/// AggExprVisitor is designed after AggExprEmitter of the CodeGen module. It
-/// is used for evaluating exprs of C++ object type. Evaluating such exprs
-/// requires a destination pointer pointing to the object being evaluated
-/// into. Passing such a pointer around would pollute the Visit* interface of
-/// GRExprEngine. AggExprVisitor encapsulates code that goes through various
-/// cast and construct exprs (and others), and at the final point, dispatches
-/// back to the GRExprEngine to let the real evaluation logic happen.
-class AggExprVisitor : public StmtVisitor<AggExprVisitor> {
- const MemRegion *Dest;
- ExplodedNode *Pred;
- ExplodedNodeSet &DstSet;
- GRExprEngine &Eng;
-
-public:
- AggExprVisitor(const MemRegion *dest, ExplodedNode *N, ExplodedNodeSet &dst,
- GRExprEngine &eng)
- : Dest(dest), Pred(N), DstSet(dst), Eng(eng) {}
-
- void VisitCastExpr(CastExpr *E);
- void VisitCXXConstructExpr(CXXConstructExpr *E);
-};
-}
-
-void AggExprVisitor::VisitCastExpr(CastExpr *E) {
- switch (E->getCastKind()) {
- default:
- assert(0 && "Unhandled cast kind");
- case CK_NoOp:
- case CK_ConstructorConversion:
- Visit(E->getSubExpr());
- break;
- }
-}
-
-void AggExprVisitor::VisitCXXConstructExpr(CXXConstructExpr *E) {
- Eng.VisitCXXConstructExpr(E, Dest, Pred, DstSet);
-}
-
-void GRExprEngine::VisitAggExpr(const Expr *E, const MemRegion *Dest,
- ExplodedNode *Pred, ExplodedNodeSet &Dst) {
- AggExprVisitor(Dest, Pred, Dst, *this).Visit(const_cast<Expr *>(E));
-}
diff --git a/lib/Checker/AnalysisConsumer.cpp b/lib/Checker/AnalysisConsumer.cpp
deleted file mode 100644
index 839ce044fd..0000000000
--- a/lib/Checker/AnalysisConsumer.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-//===--- AnalysisConsumer.cpp - ASTConsumer for running Analyses ----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// "Meta" ASTConsumer for running different source analyses.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/AnalysisConsumer.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/ParentMap.h"
-#include "clang/Analysis/Analyses/LiveVariables.h"
-#include "clang/Analysis/Analyses/UninitializedValues.h"
-#include "clang/Analysis/CFG.h"
-#include "clang/GR/Checkers/LocalCheckers.h"
-#include "clang/GR/ManagerRegistry.h"
-#include "clang/GR/BugReporter/PathDiagnostic.h"
-#include "clang/GR/PathSensitive/AnalysisManager.h"
-#include "clang/GR/BugReporter/BugReporter.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-#include "clang/GR/PathSensitive/GRTransferFuncs.h"
-#include "clang/GR/PathDiagnosticClients.h"
-#include "GRExprEngineExperimentalChecks.h"
-#include "GRExprEngineInternalChecks.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Frontend/AnalyzerOptions.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Program.h"
-#include "llvm/ADT/OwningPtr.h"
-
-using namespace clang;
-
-static ExplodedNode::Auditor* CreateUbiViz();
-
-//===----------------------------------------------------------------------===//
-// Special PathDiagnosticClients.
-//===----------------------------------------------------------------------===//
-
-static PathDiagnosticClient*
-createPlistHTMLDiagnosticClient(const std::string& prefix,
- const Preprocessor &PP) {
- PathDiagnosticClient *PD =
- createHTMLDiagnosticClient(llvm::sys::path::parent_path(prefix), PP);
- return createPlistDiagnosticClient(prefix, PP, PD);
-}
-
-//===----------------------------------------------------------------------===//
-// AnalysisConsumer declaration.
-//===----------------------------------------------------------------------===//
-
-namespace {
-
-class AnalysisConsumer : public ASTConsumer {
-public:
- typedef void (*CodeAction)(AnalysisConsumer &C, AnalysisManager &M, Decl *D);
- typedef void (*TUAction)(AnalysisConsumer &C, AnalysisManager &M,
- TranslationUnitDecl &TU);
-
-private:
- typedef std::vector<CodeAction> Actions;
- typedef std::vector<TUAction> TUActions;
-
- Actions FunctionActions;
- Actions ObjCMethodActions;
- Actions ObjCImplementationActions;
- Actions CXXMethodActions;
- TUActions TranslationUnitActions; // Remove this.
-
-public:
- ASTContext* Ctx;
- const Preprocessor &PP;
- const std::string OutDir;
- AnalyzerOptions Opts;
-
- // PD is owned by AnalysisManager.
- PathDiagnosticClient *PD;
-
- StoreManagerCreator CreateStoreMgr;
- ConstraintManagerCreator CreateConstraintMgr;
-
- llvm::OwningPtr<AnalysisManager> Mgr;
-
- AnalysisConsumer(const Preprocessor& pp,
- const std::string& outdir,
- const AnalyzerOptions& opts)
- : Ctx(0), PP(pp), OutDir(outdir),
- Opts(opts), PD(0) {
- DigestAnalyzerOptions();
- }
-
- void DigestAnalyzerOptions() {
- // Create the PathDiagnosticClient.
- if (!OutDir.empty()) {
- switch (Opts.AnalysisDiagOpt) {
- default:
-#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) \
- case PD_##NAME: PD = CREATEFN(OutDir, PP); break;
-#include "clang/Frontend/Analyses.def"
- }
- } else if (Opts.AnalysisDiagOpt == PD_TEXT) {