#ifndef __ARRAY__ANALYSIS__H
#define __ARRAY__ANALYSIS__H

#include "CommonTypes.hpp"

#include "llvm/Pass.h"
#include "llvm/CallGraphSCCPass.h"
#include "llvm/ADT/BitVector.h"

#include <boost/scoped_ptr.hpp>

namespace llvm
{
  class Argument;
  class BitVector;
  class Function;
  class Value;
}

class AliasHelper;

struct ArrayAnalysis : public llvm::CallGraphSCCPass
{
  static char ID;
  results_t * _res;
  ArrayAnalysis(results_t * res = NULL);

  // CallGraphSCCPass
  virtual bool runOnSCC(const std::vector<llvm::CallGraphNode *> &SCCM);
  virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const;

private:
  void checkArray(llvm::Function &F);
  void markArray(const llvm::BitVector & depths, const llvm::Argument & arg);
  
private:
  boost::scoped_ptr<AliasHelper> _AH;
};

#endif // __ARRAY__ANALYSIS__H
