diff options
Diffstat (limited to 'include/clang/Checker/PathSensitive')
14 files changed, 71 insertions, 69 deletions
| diff --git a/include/clang/Checker/PathSensitive/BasicValueFactory.h b/include/clang/Checker/PathSensitive/BasicValueFactory.h index 2f0b6c2a0348a..59dd9190d25e7 100644 --- a/include/clang/Checker/PathSensitive/BasicValueFactory.h +++ b/include/clang/Checker/PathSensitive/BasicValueFactory.h @@ -16,7 +16,6 @@  #ifndef LLVM_CLANG_ANALYSIS_BASICVALUEFACTORY_H  #define LLVM_CLANG_ANALYSIS_BASICVALUEFACTORY_H -#include "clang/Checker/PathSensitive/SymbolManager.h"  #include "clang/Checker/PathSensitive/SVals.h"  #include "clang/AST/ASTContext.h"  #include "llvm/ADT/FoldingSet.h" diff --git a/include/clang/Checker/PathSensitive/Checker.h b/include/clang/Checker/PathSensitive/Checker.h index 2401a72741b2b..8cb9cc8337c6a 100644 --- a/include/clang/Checker/PathSensitive/Checker.h +++ b/include/clang/Checker/PathSensitive/Checker.h @@ -14,21 +14,15 @@  #ifndef LLVM_CLANG_ANALYSIS_CHECKER  #define LLVM_CLANG_ANALYSIS_CHECKER +  #include "clang/Analysis/Support/SaveAndRestore.h" -#include "clang/Checker/PathSensitive/GRCoreEngine.h" -#include "clang/Checker/PathSensitive/GRState.h"  #include "clang/Checker/PathSensitive/GRExprEngine.h" -#include "clang/AST/ExprCXX.h" -#include "clang/AST/ExprObjC.h" -#include "clang/AST/StmtCXX.h" -#include "clang/AST/StmtObjC.h"  //===----------------------------------------------------------------------===//  // Checker interface.  //===----------------------------------------------------------------------===//  namespace clang { -  class GRExprEngine;  class CheckerContext {    ExplodedNodeSet &Dst; diff --git a/include/clang/Checker/PathSensitive/Environment.h b/include/clang/Checker/PathSensitive/Environment.h index 6051654f4855f..b9bbebc652f24 100644 --- a/include/clang/Checker/PathSensitive/Environment.h +++ b/include/clang/Checker/PathSensitive/Environment.h @@ -18,11 +18,8 @@  // typedefs.  #include "clang/Checker/PathSensitive/Store.h" -#include "llvm/ADT/ImmutableMap.h" -#include "llvm/ADT/SmallVector.h"  #include "clang/Checker/PathSensitive/SVals.h" -#include "llvm/Support/Allocator.h" -#include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/ImmutableMap.h"  namespace clang { diff --git a/include/clang/Checker/PathSensitive/ExplodedGraph.h b/include/clang/Checker/PathSensitive/ExplodedGraph.h index d6c4436c594c3..c09c89312e106 100644 --- a/include/clang/Checker/PathSensitive/ExplodedGraph.h +++ b/include/clang/Checker/PathSensitive/ExplodedGraph.h @@ -9,6 +9,10 @@  //  //  This file defines the template classes ExplodedNode and ExplodedGraph,  //  which represent a path-sensitive, intra-procedural "exploded graph." +//  See "Precise interprocedural dataflow analysis via graph reachability" +//  by Reps, Horwitz, and Sagiv +//  (http://portal.acm.org/citation.cfm?id=199462) for the definition of an +//  exploded graph.  //  //===----------------------------------------------------------------------===// diff --git a/include/clang/Checker/PathSensitive/GRBlockCounter.h b/include/clang/Checker/PathSensitive/GRBlockCounter.h index 67ed9532db02b..b7d0e8ae0c71d 100644 --- a/include/clang/Checker/PathSensitive/GRBlockCounter.h +++ b/include/clang/Checker/PathSensitive/GRBlockCounter.h @@ -22,6 +22,8 @@ namespace llvm {  namespace clang { +class StackFrameContext; +  class GRBlockCounter {    void* Data; @@ -30,7 +32,8 @@ class GRBlockCounter {  public:    GRBlockCounter() : Data(0) {} -  unsigned getNumVisited(unsigned BlockID) const; +  unsigned getNumVisited(const StackFrameContext *CallSite,  +                         unsigned BlockID) const;    class Factory {      void* F; @@ -39,7 +42,9 @@ public:      ~Factory();      GRBlockCounter GetEmptyCounter(); -    GRBlockCounter IncrementCount(GRBlockCounter BC, unsigned BlockID); +    GRBlockCounter IncrementCount(GRBlockCounter BC,  +                                  const StackFrameContext *CallSite, +                                  unsigned BlockID);    };    friend class Factory; diff --git a/include/clang/Checker/PathSensitive/GRCoreEngine.h b/include/clang/Checker/PathSensitive/GRCoreEngine.h index c5bf5138a63fc..a3ff0dbedc7bf 100644 --- a/include/clang/Checker/PathSensitive/GRCoreEngine.h +++ b/include/clang/Checker/PathSensitive/GRCoreEngine.h @@ -82,7 +82,7 @@ class GRCoreEngine {    void ProcessStmt(CFGElement E, GRStmtNodeBuilder& Builder); -  bool ProcessBlockEntrance(CFGBlock* Blk, const GRState* State, +  bool ProcessBlockEntrance(CFGBlock* Blk, const ExplodedNode *Pred,                              GRBlockCounter BC); @@ -174,7 +174,9 @@ public:    GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}    unsigned getCurrentBlockCount() const { -    return getBlockCounter().getNumVisited(B.getBlockID()); +    return getBlockCounter().getNumVisited( +                            Pred->getLocationContext()->getCurrentStackFrame(), +                                           B.getBlockID());    }    ExplodedNode* generateNode(PostStmt PP,const GRState* St,ExplodedNode* Pred) { @@ -434,7 +436,9 @@ public:    }    unsigned getCurrentBlockCount() const { -    return getBlockCounter().getNumVisited(B.getBlockID()); +    return getBlockCounter().getNumVisited( +                            Pred->getLocationContext()->getCurrentStackFrame(), +                                           B.getBlockID());    }    ExplodedNode* generateNode(const GRState* State, const void *tag = 0, diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h index 916511e8bd098..161cb28df0333 100644 --- a/include/clang/Checker/PathSensitive/GRExprEngine.h +++ b/include/clang/Checker/PathSensitive/GRExprEngine.h @@ -16,7 +16,6 @@  #ifndef LLVM_CLANG_ANALYSIS_GREXPRENGINE  #define LLVM_CLANG_ANALYSIS_GREXPRENGINE -#include "clang/Checker/PathSensitive/AnalysisManager.h"  #include "clang/Checker/PathSensitive/GRSubEngine.h"  #include "clang/Checker/PathSensitive/GRCoreEngine.h"  #include "clang/Checker/PathSensitive/GRState.h" @@ -28,11 +27,9 @@  #include "clang/AST/ExprCXX.h"  namespace clang { - -  class PathDiagnosticClient; -  class Diagnostic; -  class ObjCForCollectionStmt; -  class Checker; +class AnalysisManager; +class Checker; +class ObjCForCollectionStmt;  class GRExprEngine : public GRSubEngine {    AnalysisManager &AMgr; @@ -153,7 +150,7 @@ public:    /// ProcessBlockEntrance - Called by GRCoreEngine when start processing    ///  a CFGBlock.  This method returns true if the analysis should continue    ///  exploring the given path, and false otherwise. -  bool ProcessBlockEntrance(CFGBlock* B, const GRState* St, +  bool ProcessBlockEntrance(CFGBlock* B, const ExplodedNode *Pred,                              GRBlockCounter BC);    /// ProcessBranch - Called by GRCoreEngine.  Used to generate successor @@ -216,7 +213,7 @@ public:                           const GRState* St,                           ProgramPoint::Kind K = ProgramPoint::PostStmtKind,                           const void *tag = 0); -protected: +    /// CheckerVisit - Dispatcher for performing checker-specific logic    ///  at specific statements.    void CheckerVisit(Stmt *S, ExplodedNodeSet &Dst, ExplodedNodeSet &Src,  @@ -351,10 +348,21 @@ protected:    void VisitCXXConstructExpr(const CXXConstructExpr *E, SVal Dest,                               ExplodedNode *Pred,                               ExplodedNodeSet &Dst); + +  void VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE, ExplodedNode *Pred, +                              ExplodedNodeSet &Dst); + +  void VisitAggExpr(const Expr *E, SVal Dest, ExplodedNode *Pred, +                    ExplodedNodeSet &Dst); +    /// Create a C++ temporary object for an rvalue.    void CreateCXXTemporaryObject(Expr *Ex, ExplodedNode *Pred,                                   ExplodedNodeSet &Dst); +  /// Synthesize CXXThisRegion. +  const CXXThisRegion *getCXXThisRegion(const CXXMethodDecl *MD, +                                        const StackFrameContext *SFC); +    /// EvalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic    ///  expressions of the form 'x != 0' and generate new nodes (stored in Dst)    ///  with those assumptions. diff --git a/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h b/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h index 383463b822cb9..6d85e5fe6a90e 100644 --- a/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h +++ b/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h @@ -17,18 +17,9 @@  #define LLVM_CLANG_ANALYSIS_GRAPICHECKS  #include "clang/Checker/PathSensitive/GRAuditor.h" -#include "clang/Checker/PathSensitive/GRState.h"  namespace clang { -class Diagnostic; -class BugReporter; -class ASTContext; -class GRExprEngine; -class PathDiagnosticClient; -class ExplodedGraph; - -  class GRSimpleAPICheck : public GRAuditor {  public:    GRSimpleAPICheck() {} diff --git a/include/clang/Checker/PathSensitive/GRState.h b/include/clang/Checker/PathSensitive/GRState.h index 657266b7508dc..25ba1f85fdff5 100644 --- a/include/clang/Checker/PathSensitive/GRState.h +++ b/include/clang/Checker/PathSensitive/GRState.h @@ -14,30 +14,22 @@  #ifndef LLVM_CLANG_ANALYSIS_VALUESTATE_H  #define LLVM_CLANG_ANALYSIS_VALUESTATE_H -// FIXME: Reduce the number of includes. - -#include "clang/AST/ASTContext.h" -#include "clang/AST/Decl.h" -#include "clang/AST/Expr.h" -#include "clang/Analysis/Analyses/LiveVariables.h"  #include "clang/Checker/PathSensitive/ConstraintManager.h"  #include "clang/Checker/PathSensitive/Environment.h" -#include "clang/Checker/PathSensitive/GRCoreEngine.h"  #include "clang/Checker/PathSensitive/Store.h"  #include "clang/Checker/PathSensitive/ValueManager.h" -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/DenseSet.h"  #include "llvm/ADT/FoldingSet.h"  #include "llvm/ADT/ImmutableMap.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/Allocator.h"  #include "llvm/Support/Casting.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/System/DataTypes.h" -#include <functional> -namespace clang { +namespace llvm { +class APSInt; +class BumpPtrAllocator; +class raw_ostream; +} +namespace clang { +class ASTContext;  class GRStateManager;  class Checker; @@ -302,6 +294,8 @@ public:    template<typename T>    const GRState *remove(typename GRStateTrait<T>::key_type K,                          typename GRStateTrait<T>::context_type C) const; +  template <typename T> +  const GRState *remove() const;    template<typename T>    const GRState *set(typename GRStateTrait<T>::data_type D) const; @@ -464,6 +458,7 @@ public:    // Methods that manipulate the GDM.    const GRState* addGDM(const GRState* St, void* Key, void* Data); +  const GRState *removeGDM(const GRState *state, void *Key);    // Methods that query & manipulate the Store. @@ -528,6 +523,10 @@ public:       GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Remove(st->get<T>(), K, C)));    } +  template <typename T> +  const GRState *remove(const GRState *st) { +    return removeGDM(st, GRStateTrait<T>::GDMIndex()); +  }    void* FindGDMContext(void* index,                         void* (*CreateContext)(llvm::BumpPtrAllocator&), @@ -702,6 +701,11 @@ const GRState *GRState::remove(typename GRStateTrait<T>::key_type K,    return getStateManager().remove<T>(this, K, C);  } +template <typename T> +const GRState *GRState::remove() const { +  return getStateManager().remove<T>(this); +} +  template<typename T>  const GRState *GRState::set(typename GRStateTrait<T>::data_type D) const {    return getStateManager().set<T>(this, D); diff --git a/include/clang/Checker/PathSensitive/GRSubEngine.h b/include/clang/Checker/PathSensitive/GRSubEngine.h index f2cd0486e326c..d2e7457ea93d7 100644 --- a/include/clang/Checker/PathSensitive/GRSubEngine.h +++ b/include/clang/Checker/PathSensitive/GRSubEngine.h @@ -20,6 +20,7 @@ namespace clang {  class Stmt;  class CFGBlock;  class CFGElement; +class ExplodedNode;  class GRState;  class GRStateManager;  class GRBlockCounter; @@ -47,7 +48,7 @@ public:    /// ProcessBlockEntrance - Called by GRCoreEngine when start processing    ///  a CFGBlock.  This method returns true if the analysis should continue    ///  exploring the given path, and false otherwise. -  virtual bool ProcessBlockEntrance(CFGBlock* B, const GRState* St, +  virtual bool ProcessBlockEntrance(CFGBlock* B, const ExplodedNode *Pred,                                      GRBlockCounter BC) = 0;    /// ProcessBranch - Called by GRCoreEngine.  Used to generate successor diff --git a/include/clang/Checker/PathSensitive/GRTransferFuncs.h b/include/clang/Checker/PathSensitive/GRTransferFuncs.h index 04634effd5878..13325edea778d 100644 --- a/include/clang/Checker/PathSensitive/GRTransferFuncs.h +++ b/include/clang/Checker/PathSensitive/GRTransferFuncs.h @@ -15,16 +15,18 @@  #ifndef LLVM_CLANG_ANALYSIS_GRTF  #define LLVM_CLANG_ANALYSIS_GRTF -#include "clang/Checker/PathSensitive/SVals.h" -#include "clang/Checker/PathSensitive/GRCoreEngine.h"  #include "clang/Checker/PathSensitive/GRState.h" +#include "clang/Checker/PathSensitive/SVals.h"  #include <vector>  namespace clang { - +class ExplodedNode; +class ExplodedNodeSet; +class GREndPathNodeBuilder;  class GRExprEngine; -class ObjCMessageExpr; +class GRStmtNodeBuilder;  class GRStmtNodeBuilderRef; +class ObjCMessageExpr;  class GRTransferFuncs {  public: diff --git a/include/clang/Checker/PathSensitive/MemRegion.h b/include/clang/Checker/PathSensitive/MemRegion.h index be89d2a3eb888..57ea8a3f6d9de 100644 --- a/include/clang/Checker/PathSensitive/MemRegion.h +++ b/include/clang/Checker/PathSensitive/MemRegion.h @@ -18,17 +18,15 @@  #include "clang/AST/Decl.h"  #include "clang/AST/DeclObjC.h" -#include "clang/Checker/PathSensitive/SymbolManager.h"  #include "clang/Checker/PathSensitive/SVals.h" -#include "clang/AST/ASTContext.h"  #include "llvm/Support/Casting.h"  #include "llvm/ADT/FoldingSet.h" -#include "llvm/ADT/ImmutableList.h" -#include "llvm/ADT/ImmutableMap.h" -#include "llvm/Support/Allocator.h"  #include <string> -namespace llvm { class raw_ostream; } +namespace llvm { +class BumpPtrAllocator; +class raw_ostream; +}  namespace clang { diff --git a/include/clang/Checker/PathSensitive/Store.h b/include/clang/Checker/PathSensitive/Store.h index edc338012ada2..72565f4d740db 100644 --- a/include/clang/Checker/PathSensitive/Store.h +++ b/include/clang/Checker/PathSensitive/Store.h @@ -18,9 +18,6 @@  #include "clang/Checker/PathSensitive/SVals.h"  #include "clang/Checker/PathSensitive/ValueManager.h"  #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallSet.h" -#include "llvm/ADT/SmallVector.h"  namespace clang { diff --git a/include/clang/Checker/PathSensitive/SymbolManager.h b/include/clang/Checker/PathSensitive/SymbolManager.h index b6630c3d97d2b..dea877c0657f9 100644 --- a/include/clang/Checker/PathSensitive/SymbolManager.h +++ b/include/clang/Checker/PathSensitive/SymbolManager.h @@ -17,14 +17,14 @@  #include "clang/AST/Decl.h"  #include "clang/AST/Expr.h" -#include "clang/Analysis/Analyses/LiveVariables.h" +#include "clang/Analysis/AnalysisContext.h"  #include "llvm/System/DataTypes.h" -#include "llvm/Support/Allocator.h"  #include "llvm/ADT/FoldingSet.h"  #include "llvm/ADT/DenseSet.h"  namespace llvm { -  class raw_ostream; +class BumpPtrAllocator; +class raw_ostream;  }  namespace clang { @@ -34,9 +34,6 @@ namespace clang {    class TypedRegion;    class VarRegion;    class StackFrameContext; -} - -namespace clang {  class SymExpr : public llvm::FoldingSetNode {  public: @@ -247,6 +244,7 @@ public:               QualType t)      : SymExpr(SymSymKind), LHS(lhs), Op(op), RHS(rhs), T(t) {} +  BinaryOperator::Opcode getOpcode() const { return Op; }    const SymExpr *getLHS() const { return LHS; }    const SymExpr *getRHS() const { return RHS; } | 
