| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef REPLACE_ARRAY_INDEX_VAR_H |
| 12 |
#define REPLACE_ARRAY_INDEX_VAR_H |
| 13 |
|
| 14 |
#include "Transformation.h" |
| 15 |
#include "llvm/ADT/DenseMap.h" |
| 16 |
#include "llvm/ADT/SmallPtrSet.h" |
| 17 |
|
| 18 |
namespace clang { |
| 19 |
class DeclGroupRef; |
| 20 |
class ASTContext; |
| 21 |
} |
| 22 |
|
| 23 |
class ReplaceArrayIndexVarCollectionVisitor; |
| 24 |
|
| 25 |
class ReplaceArrayIndexVar : public Transformation { |
| 26 |
friend class ReplaceArrayIndexVarCollectionVisitor; |
| 27 |
|
| 28 |
public: |
| 29 |
|
| 30 |
ReplaceArrayIndexVar(const char *TransName, const char *Desc) |
| 31 |
: Transformation(TransName, Desc), |
| 32 |
CollectionVisitor(NULL), |
| 33 |
MaxSize(15), |
| 34 |
TheASESet(NULL), |
| 35 |
CurrIdx(0) |
| 36 |
{ } |
| 37 |
|
| 38 |
~ReplaceArrayIndexVar(void); |
| 39 |
|
| 40 |
private: |
| 41 |
|
| 42 |
typedef llvm::SmallPtrSet<const clang::ArraySubscriptExpr *, 10> |
| 43 |
ArraySubscriptExprSet; |
| 44 |
|
| 45 |
typedef llvm::DenseMap<const clang::VarDecl *, unsigned> |
| 46 |
ArrayVarsToSizeMap; |
| 47 |
|
| 48 |
virtual void Initialize(clang::ASTContext &context); |
| 49 |
|
| 50 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 51 |
|
| 52 |
void doRewrite(void); |
| 53 |
|
| 54 |
ArrayVarsToSizeMap CstArrayVars; |
| 55 |
|
| 56 |
ReplaceArrayIndexVarCollectionVisitor *CollectionVisitor; |
| 57 |
|
| 58 |
const unsigned MaxSize; |
| 59 |
|
| 60 |
ArraySubscriptExprSet *TheASESet; |
| 61 |
|
| 62 |
unsigned CurrIdx; |
| 63 |
|
| 64 |
|
| 65 |
ReplaceArrayIndexVar(void); |
| 66 |
|
| 67 |
ReplaceArrayIndexVar(const ReplaceArrayIndexVar &); |
| 68 |
|
| 69 |
void operator=(const ReplaceArrayIndexVar &); |
| 70 |
}; |
| 71 |
|
| 72 |
#endif |