| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef REDUCE_POINTER_PAIRS_H |
| 12 |
#define REDUCE_POINTER_PAIRS_H |
| 13 |
|
| 14 |
#include "Transformation.h" |
| 15 |
#include "llvm/ADT/DenseMap.h" |
| 16 |
|
| 17 |
namespace clang { |
| 18 |
class DeclGroupRef; |
| 19 |
class ASTContext; |
| 20 |
class VarDecl; |
| 21 |
} |
| 22 |
|
| 23 |
class ReducePointerPairsCollectionVisitor; |
| 24 |
class ReducePointerPairsInvalidatingVisitor; |
| 25 |
|
| 26 |
class ReducePointerPairs : public Transformation { |
| 27 |
friend class ReducePointerPairsCollectionVisitor; |
| 28 |
friend class ReducePointerPairsInvalidatingVisitor; |
| 29 |
|
| 30 |
public: |
| 31 |
|
| 32 |
ReducePointerPairs(const char *TransName, const char *Desc) |
| 33 |
: Transformation(TransName, Desc), |
| 34 |
CollectionVisitor(NULL), |
| 35 |
InvalidatingVisitor(NULL), |
| 36 |
TheVarDecl(NULL), |
| 37 |
ThePairedVarDecl(NULL) |
| 38 |
{ } |
| 39 |
|
| 40 |
~ReducePointerPairs(void); |
| 41 |
|
| 42 |
private: |
| 43 |
|
| 44 |
typedef llvm::DenseMap<const clang::VarDecl *, const clang::VarDecl *> |
| 45 |
PointerMap; |
| 46 |
|
| 47 |
virtual void Initialize(clang::ASTContext &context); |
| 48 |
|
| 49 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 50 |
|
| 51 |
void handleOnePair(const clang::VarDecl *VD, const clang::Expr *E); |
| 52 |
|
| 53 |
bool isValidVD(const clang::VarDecl *VD); |
| 54 |
|
| 55 |
bool invalidatePairedVarDecl(const clang::VarDecl *VD); |
| 56 |
|
| 57 |
const clang::VarDecl *getVarDeclFromDRE(const clang::Expr *E); |
| 58 |
|
| 59 |
bool isMappedVarDecl(const clang::VarDecl *VD); |
| 60 |
|
| 61 |
void doRewriting(const clang::VarDecl *VD); |
| 62 |
|
| 63 |
void doAnalysis(void); |
| 64 |
|
| 65 |
void invalidateVarDecl(const clang::VarDecl *VD); |
| 66 |
|
| 67 |
PointerMap ValidPointerPairs; |
| 68 |
|
| 69 |
ReducePointerPairsCollectionVisitor *CollectionVisitor; |
| 70 |
|
| 71 |
ReducePointerPairsInvalidatingVisitor *InvalidatingVisitor; |
| 72 |
|
| 73 |
const clang::VarDecl *TheVarDecl; |
| 74 |
|
| 75 |
const clang::VarDecl *ThePairedVarDecl; |
| 76 |
|
| 77 |
|
| 78 |
ReducePointerPairs(void); |
| 79 |
|
| 80 |
ReducePointerPairs(const ReducePointerPairs &); |
| 81 |
|
| 82 |
void operator=(const ReducePointerPairs &); |
| 83 |
}; |
| 84 |
|
| 85 |
#endif |