[cfe-commits] r45292 - in /cfe/trunk: Analysis/DeadStores.cpp Analysis/LiveVariables.cpp Analysis/UninitializedValues.cpp Driver/ASTConsumers.cpp include/clang/Analysis/Analyses/ include/clang/Analysis/Analyses/LiveVariables.h include/clang/Analysis/Analyses/UninitializedValues.h include/clang/Analysis/ExprDeclBitVector.h include/clang/Analysis/LiveVariables.h include/clang/Analysis/Support/ExprDeclBitVector.h include/clang/Analysis/UninitializedValues.h
Ted Kremenek
kremenek at apple.com
Fri Dec 21 13:42:19 PST 2007
Author: kremenek
Date: Fri Dec 21 15:42:19 2007
New Revision: 45292
URL: http://llvm.org/viewvc/llvm-project?rev=45292&view=rev
Log:
Directory restructing of Analysis files.
Created include/clang/Analysis/Analyses directory.
- Moved LiveVariables.h and UninitializedValues.h into this dir.
Moved ExprDeclBitVector.h into Analysis/Support.
Updated all clients who use these headers to reflect the new paths.
Added:
cfe/trunk/include/clang/Analysis/Analyses/
cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h
- copied, changed from r45291, cfe/trunk/include/clang/Analysis/LiveVariables.h
cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h
- copied, changed from r45291, cfe/trunk/include/clang/Analysis/UninitializedValues.h
cfe/trunk/include/clang/Analysis/Support/ExprDeclBitVector.h
- copied unchanged from r45291, cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h
Removed:
cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h
cfe/trunk/include/clang/Analysis/LiveVariables.h
cfe/trunk/include/clang/Analysis/UninitializedValues.h
Modified:
cfe/trunk/Analysis/DeadStores.cpp
cfe/trunk/Analysis/LiveVariables.cpp
cfe/trunk/Analysis/UninitializedValues.cpp
cfe/trunk/Driver/ASTConsumers.cpp
Modified: cfe/trunk/Analysis/DeadStores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/DeadStores.cpp?rev=45292&r1=45291&r2=45292&view=diff
==============================================================================
--- cfe/trunk/Analysis/DeadStores.cpp (original)
+++ cfe/trunk/Analysis/DeadStores.cpp Fri Dec 21 15:42:19 2007
@@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/LocalCheckers.h"
-#include "clang/Analysis/LiveVariables.h"
+#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/Visitors/CFGRecStmtVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/AST/ASTContext.h"
Modified: cfe/trunk/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/LiveVariables.cpp?rev=45292&r1=45291&r2=45292&view=diff
==============================================================================
--- cfe/trunk/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/Analysis/LiveVariables.cpp Fri Dec 21 15:42:19 2007
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Analysis/LiveVariables.h"
+#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Basic/SourceManager.h"
#include "clang/AST/Expr.h"
#include "clang/AST/CFG.h"
Modified: cfe/trunk/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=45292&r1=45291&r2=45292&view=diff
==============================================================================
--- cfe/trunk/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/Analysis/UninitializedValues.cpp Fri Dec 21 15:42:19 2007
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Analysis/UninitializedValues.h"
+#include "clang/Analysis/Analyses/UninitializedValues.h"
#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
#include "clang/Analysis/LocalCheckers.h"
#include "clang/Basic/Diagnostic.h"
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=45292&r1=45291&r2=45292&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Fri Dec 21 15:42:19 2007
@@ -18,7 +18,7 @@
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/CFG.h"
-#include "clang/Analysis/LiveVariables.h"
+#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/LocalCheckers.h"
#include "llvm/Support/Streams.h"
Copied: cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h (from r45291, cfe/trunk/include/clang/Analysis/LiveVariables.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h?p2=cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h&p1=cfe/trunk/include/clang/Analysis/LiveVariables.h&r1=45291&r2=45292&rev=45292&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/LiveVariables.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h Fri Dec 21 15:42:19 2007
@@ -15,7 +15,7 @@
#define LLVM_CLANG_LIVEVARIABLES_H
#include "clang/AST/Decl.h"
-#include "clang/Analysis/ExprDeclBitVector.h"
+#include "clang/Analysis/Support/ExprDeclBitVector.h"
#include "clang/Analysis/FlowSensitive/DataflowValues.h"
namespace clang {
Copied: cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h (from r45291, cfe/trunk/include/clang/Analysis/UninitializedValues.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h?p2=cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h&p1=cfe/trunk/include/clang/Analysis/UninitializedValues.h&r1=45291&r2=45292&rev=45292&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/UninitializedValues.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h Fri Dec 21 15:42:19 2007
@@ -15,7 +15,7 @@
#ifndef LLVM_CLANG_UNITVALS_H
#define LLVM_CLANG_UNITVALS_H
-#include "clang/Analysis/ExprDeclBitVector.h"
+#include "clang/Analysis/Support/ExprDeclBitVector.h"
#include "clang/Analysis/FlowSensitive/DataflowValues.h"
namespace clang {
Removed: cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h?rev=45291&view=auto
==============================================================================
--- cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h (original)
+++ cfe/trunk/include/clang/Analysis/ExprDeclBitVector.h (removed)
@@ -1,236 +0,0 @@
-//=- ExprDeclBitVector.h - Dataflow types for Bitvector Analysis --*- C++ --*-//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Ted Kremenek and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides definition of dataflow types used by analyses such
-// as LiveVariables and UninitializedValues. The underlying dataflow values
-// are implemented as bitvectors, but the definitions in this file include
-// the necessary boilerplate to use with our dataflow framework.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EXPRDECLBVDVAL_H
-#define LLVM_CLANG_EXPRDECLBVDVAL_H
-
-#include "clang/AST/CFG.h"
-#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/DenseMap.h"
-
-namespace clang {
-
- class Expr;
- class ScopedDecl;
-
-struct DeclBitVector_Types {
-
- //===--------------------------------------------------------------------===//
- // AnalysisDataTy - Whole-function meta data.
- //===--------------------------------------------------------------------===//
-
- class AnalysisDataTy {
- public:
- typedef llvm::DenseMap<const ScopedDecl*, unsigned > DMapTy;
- typedef DMapTy::const_iterator decl_iterator;
-
- protected:
- DMapTy DMap;
- unsigned NDecls;
-
- public:
-
- AnalysisDataTy() : NDecls(0) {}
- virtual ~AnalysisDataTy() {}
-
- bool isTracked(const ScopedDecl* SD) { return DMap.find(SD) != DMap.end(); }
-
- unsigned getIdx(const ScopedDecl* SD) const {
- DMapTy::const_iterator I = DMap.find(SD);
- assert (I != DMap.end());
- return I->second;
- }
-
- unsigned getNumDecls() const { return NDecls; }
-
- void Register(const ScopedDecl* SD) {
- if (!isTracked(SD)) DMap[SD] = NDecls++;
- }
-
- decl_iterator begin_decl() const { return DMap.begin(); }
- decl_iterator end_decl() const { return DMap.end(); }
- };
-
- //===--------------------------------------------------------------------===//
- // ValTy - Dataflow value.
- //===--------------------------------------------------------------------===//
-
- class ValTy {
- llvm::BitVector DeclBV;
- public:
-
- void resetValues(AnalysisDataTy& AD) {
- DeclBV.resize(AD.getNumDecls());
- DeclBV.reset();
- }
-
- bool operator==(const ValTy& RHS) const {
- assert (sizesEqual(RHS));
- return DeclBV == RHS.DeclBV;
- }
-
- void copyValues(const ValTy& RHS) { DeclBV = RHS.DeclBV; }
-
- llvm::BitVector::reference
- operator()(const ScopedDecl* SD, const AnalysisDataTy& AD) {
- return DeclBV[AD.getIdx(SD)];
- }
- const llvm::BitVector::reference
- operator()(const ScopedDecl* SD, const AnalysisDataTy& AD) const {
- return const_cast<ValTy&>(*this)(SD,AD);
- }
-
- llvm::BitVector::reference getDeclBit(unsigned i) { return DeclBV[i]; }
- const llvm::BitVector::reference getDeclBit(unsigned i) const {
- return const_cast<llvm::BitVector&>(DeclBV)[i];
- }
-
- ValTy& operator|=(const ValTy& RHS) {
- assert (sizesEqual(RHS));
- DeclBV |= RHS.DeclBV;
- return *this;
- }
-
- ValTy& operator&=(const ValTy& RHS) {
- assert (sizesEqual(RHS));
- DeclBV &= RHS.DeclBV;
- return *this;
- }
-
- bool sizesEqual(const ValTy& RHS) const {
- return DeclBV.size() == RHS.DeclBV.size();
- }
- };
-
- //===--------------------------------------------------------------------===//
- // Some useful merge operations.
- //===--------------------------------------------------------------------===//
-
- struct Union { void operator()(ValTy& Dst, ValTy& Src) { Dst |= Src; } };
- struct Intersect { void operator()(ValTy& Dst, ValTy& Src) { Dst &= Src; } };
-};
-
-
-struct ExprDeclBitVector_Types {
-
- //===--------------------------------------------------------------------===//
- // AnalysisDataTy - Whole-function meta data.
- //===--------------------------------------------------------------------===//
-
- class AnalysisDataTy : public DeclBitVector_Types::AnalysisDataTy {
- CFG* cfg;
- public:
- AnalysisDataTy() {}
- virtual ~AnalysisDataTy() {}
-
- void setCFG(CFG* c) { cfg = c; }
- CFG& getCFG() { assert(cfg && "CFG should not be NULL."); return *cfg; }
-
- bool isTracked(const Expr* E) { return cfg->isBlkExpr(E); }
- using DeclBitVector_Types::AnalysisDataTy::isTracked;
-
- unsigned getIdx(const Expr* E) const {
- CFG::BlkExprNumTy I = cfg->getBlkExprNum(E);
- assert(I && "expression not tracked for bitvector.");
- return I;
- }
- using DeclBitVector_Types::AnalysisDataTy::getIdx;
-
- unsigned getNumExprs() const { return cfg->getNumBlkExprs(); }
- };
-
- //===--------------------------------------------------------------------===//
- // ValTy - Dataflow value.
- //===--------------------------------------------------------------------===//
-
- class ValTy : public DeclBitVector_Types::ValTy {
- llvm::BitVector ExprBV;
- typedef DeclBitVector_Types::ValTy ParentTy;
-
- static inline ParentTy& ParentRef(ValTy& X) {
- return static_cast<ParentTy&>(X);
- }
-
- static inline const ParentTy& ParentRef(const ValTy& X) {
- return static_cast<const ParentTy&>(X);
- }
-
- public:
-
- void resetValues(AnalysisDataTy& AD) {
- ParentRef(*this).resetValues(AD);
- ExprBV.resize(AD.getNumExprs());
- ExprBV.reset();
- }
-
- bool operator==(const ValTy& RHS) const {
- return ParentRef(*this) == ParentRef(RHS)
- && ExprBV == RHS.ExprBV;
- }
-
- void copyValues(const ValTy& RHS) {
- ParentRef(*this).copyValues(ParentRef(RHS));
- ExprBV = RHS.ExprBV;
- }
-
- llvm::BitVector::reference
- operator()(const Expr* E, const AnalysisDataTy& AD) {
- return ExprBV[AD.getIdx(E)];
- }
- const llvm::BitVector::reference
- operator()(const Expr* E, const AnalysisDataTy& AD) const {
- return const_cast<ValTy&>(*this)(E,AD);
- }
-
- using DeclBitVector_Types::ValTy::operator();
-
-
- llvm::BitVector::reference getExprBit(unsigned i) { return ExprBV[i]; }
- const llvm::BitVector::reference getExprBit(unsigned i) const {
- return const_cast<llvm::BitVector&>(ExprBV)[i];
- }
-
- ValTy& operator|=(const ValTy& RHS) {
- assert (sizesEqual(RHS));
- ParentRef(*this) |= ParentRef(RHS);
- ExprBV |= RHS.ExprBV;
- return *this;
- }
-
- ValTy& operator&=(const ValTy& RHS) {
- assert (sizesEqual(RHS));
- ParentRef(*this) &= ParentRef(RHS);
- ExprBV &= RHS.ExprBV;
- return *this;
- }
-
- bool sizesEqual(const ValTy& RHS) const {
- return ParentRef(*this).sizesEqual(ParentRef(RHS))
- && ExprBV.size() == RHS.ExprBV.size();
- }
- };
-
- //===--------------------------------------------------------------------===//
- // Some useful merge operations.
- //===--------------------------------------------------------------------===//
-
- struct Union { void operator()(ValTy& Dst, ValTy& Src) { Dst |= Src; } };
- struct Intersect { void operator()(ValTy& Dst, ValTy& Src) { Dst &= Src; } };
-
-};
-} // end namespace clang
-
-#endif
Removed: cfe/trunk/include/clang/Analysis/LiveVariables.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/LiveVariables.h?rev=45291&view=auto
==============================================================================
--- cfe/trunk/include/clang/Analysis/LiveVariables.h (original)
+++ cfe/trunk/include/clang/Analysis/LiveVariables.h (removed)
@@ -1,101 +0,0 @@
-//===- LiveVariables.h - Live Variable Analysis for Source CFGs -*- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Ted Kremenek and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements Live Variables analysis for source-level CFGs.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_LIVEVARIABLES_H
-#define LLVM_CLANG_LIVEVARIABLES_H
-
-#include "clang/AST/Decl.h"
-#include "clang/Analysis/ExprDeclBitVector.h"
-#include "clang/Analysis/FlowSensitive/DataflowValues.h"
-
-namespace clang {
-
-class Stmt;
-class DeclRefExpr;
-class SourceManager;
-
-struct LiveVariables_ValueTypes {
-
- struct ObserverTy;
-
-
- // We need to keep track of both declarations and CFGBlock-level expressions,
- // (so that we don't explore such expressions twice), but we only need
- // liveness information for declarations (hence
- // ValTy = DeclBitVector_Types::ValTy instead of
- // ValTy = ExprDeclBitVector_Types::ValTy).
-
- struct AnalysisDataTy : public ExprDeclBitVector_Types::AnalysisDataTy {
- ObserverTy* Observer;
-
- AnalysisDataTy() : Observer(NULL) {}
- };
-
- // We only keep actual dataflow state for declarations.
- typedef DeclBitVector_Types::ValTy ValTy;
-
- //===-----------------------------------------------------===//
- // ObserverTy - Observer for uninitialized values queries.
- //===-----------------------------------------------------===//
-
- struct ObserverTy {
- virtual ~ObserverTy() {}
-
- /// ObserveStmt - A callback invoked right before invoking the
- /// liveness transfer function on the given statement.
- virtual void ObserveStmt(Stmt* S, const AnalysisDataTy& AD,
- const ValTy& V) {}
-
- virtual void ObserverKill(DeclRefExpr* DR) {}
- };
-};
-
-class LiveVariables : public DataflowValues<LiveVariables_ValueTypes,
- dataflow::backward_analysis_tag> {
-public:
- typedef LiveVariables_ValueTypes::ObserverTy ObserverTy;
-
- LiveVariables(CFG& cfg) { getAnalysisData().setCFG(&cfg); }
-
- /// IsLive - Return true if a variable is live at beginning of a
- /// specified block.
- bool isLive(const CFGBlock* B, const VarDecl* D) const;
-
- /// IsLive - Return true if a variable is live according to the
- /// provided livness bitvector.
- bool isLive(const ValTy& V, const VarDecl* D) const;
-
- /// dumpLiveness - Print to stderr the liveness information encoded
- /// by a specified bitvector.
- void dumpLiveness(const ValTy& V, SourceManager& M) const;
-
- /// dumpBlockLiveness - Print to stderr the liveness information
- /// associated with each basic block.
- void dumpBlockLiveness(SourceManager& M) const;
-
- /// getNumDecls - Return the number of variables (declarations) that
- /// whose liveness status is being tracked by the dataflow
- /// analysis.
- unsigned getNumDecls() const { return getAnalysisData().getNumDecls(); }
-
- /// IntializeValues - Create initial dataflow values and meta data for
- /// a given CFG. This is intended to be called by the dataflow solver.
- void InitializeValues(const CFG& cfg);
-
- void runOnCFG(const CFG& cfg);
- void runOnAllBlocks(const CFG& cfg, ObserverTy& Obs);
-};
-
-} // end namespace clang
-
-#endif
Removed: cfe/trunk/include/clang/Analysis/UninitializedValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/UninitializedValues.h?rev=45291&view=auto
==============================================================================
--- cfe/trunk/include/clang/Analysis/UninitializedValues.h (original)
+++ cfe/trunk/include/clang/Analysis/UninitializedValues.h (removed)
@@ -1,74 +0,0 @@
-//===- UninitializedValues.h - unintialized values analysis ----*- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Ted Kremenek and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the interface for the Unintialized Values analysis,
-// a flow-sensitive analysis that detects when variable values are unintialized.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_UNITVALS_H
-#define LLVM_CLANG_UNITVALS_H
-
-#include "clang/Analysis/ExprDeclBitVector.h"
-#include "clang/Analysis/FlowSensitive/DataflowValues.h"
-
-namespace clang {
-
- class BlockVarDecl;
- class Expr;
- class DeclRefExpr;
- class VarDecl;
-
-/// UninitializedValues_ValueTypes - Utility class to wrap type declarations
-/// for dataflow values and dataflow analysis state for the
-/// Unitialized Values analysis.
-class UninitializedValues_ValueTypes {
-public:
-
- struct ObserverTy;
-
- struct AnalysisDataTy : public ExprDeclBitVector_Types::AnalysisDataTy {
- AnalysisDataTy() : Observer(NULL), FullUninitTaint(true) {}
- virtual ~AnalysisDataTy() {};
-
- ObserverTy* Observer;
- bool FullUninitTaint;
- };
-
- typedef ExprDeclBitVector_Types::ValTy ValTy;
-
- //===--------------------------------------------------------------------===//
- // ObserverTy - Observer for querying DeclRefExprs that use an uninitalized
- // value.
- //===--------------------------------------------------------------------===//
-
- struct ObserverTy {
- virtual ~ObserverTy();
- virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD,
- DeclRefExpr* DR, BlockVarDecl* VD) = 0;
- };
-};
-
-/// UninitializedValues - Objects of this class encapsulate dataflow analysis
-/// information regarding what variable declarations in a function are
-/// potentially unintialized.
-class UninitializedValues :
- public DataflowValues<UninitializedValues_ValueTypes> {
-public:
- typedef UninitializedValues_ValueTypes::ObserverTy ObserverTy;
-
- UninitializedValues(CFG &cfg) { getAnalysisData().setCFG(&cfg); }
-
- /// IntializeValues - Create initial dataflow values and meta data for
- /// a given CFG. This is intended to be called by the dataflow solver.
- void InitializeValues(const CFG& cfg);
-};
-
-} // end namespace clang
-#endif
More information about the cfe-commits
mailing list