| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef PARAM_TO_GLOBAL_H |
| 12 |
#define PARAM_TO_GLOBAL_H |
| 13 |
|
| 14 |
#include <string> |
| 15 |
#include "llvm/ADT/SmallVector.h" |
| 16 |
#include "Transformation.h" |
| 17 |
#include "CommonParameterRewriteVisitor.h" |
| 18 |
|
| 19 |
namespace clang { |
| 20 |
class DeclGroupRef; |
| 21 |
class ASTContext; |
| 22 |
class FunctionDecl; |
| 23 |
class ReturnStmt; |
| 24 |
class ParmVarDecl; |
| 25 |
} |
| 26 |
|
| 27 |
class ParamToGlobalASTVisitor; |
| 28 |
class ParamToGlobalRewriteVisitor; |
| 29 |
template<typename T, typename Trans> class CommonParameterRewriteVisitor; |
| 30 |
|
| 31 |
class ParamToGlobal : public Transformation { |
| 32 |
friend class ParamToGlobalASTVisitor; |
| 33 |
friend class ParamToGlobalRewriteVisitor; |
| 34 |
friend class CommonParameterRewriteVisitor<ParamToGlobalRewriteVisitor, |
| 35 |
ParamToGlobal>; |
| 36 |
|
| 37 |
public: |
| 38 |
|
| 39 |
ParamToGlobal(const char *TransName, const char *Desc) |
| 40 |
: Transformation(TransName, Desc), |
| 41 |
CollectionVisitor(NULL), |
| 42 |
RewriteVisitor(NULL), |
| 43 |
TheFuncDecl(NULL), |
| 44 |
TheParmVarDecl(NULL), |
| 45 |
TheNewDeclName(""), |
| 46 |
TheParamPos(-1) |
| 47 |
{ } |
| 48 |
|
| 49 |
~ParamToGlobal(void); |
| 50 |
|
| 51 |
private: |
| 52 |
|
| 53 |
virtual void Initialize(clang::ASTContext &context); |
| 54 |
|
| 55 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 56 |
|
| 57 |
bool transformParamVar(clang::FunctionDecl *FD, |
| 58 |
const clang::ParmVarDecl *PV); |
| 59 |
|
| 60 |
bool rewriteFuncDecl(clang::FunctionDecl *FD); |
| 61 |
|
| 62 |
std::string getNewName(clang::FunctionDecl *FP, |
| 63 |
const clang::ParmVarDecl *PV); |
| 64 |
|
| 65 |
bool isValidFuncDecl(clang::FunctionDecl *FD); |
| 66 |
|
| 67 |
llvm::SmallVector<clang::FunctionDecl *, 10> ValidFuncDecls; |
| 68 |
|
| 69 |
ParamToGlobalASTVisitor *CollectionVisitor; |
| 70 |
|
| 71 |
ParamToGlobalRewriteVisitor *RewriteVisitor; |
| 72 |
|
| 73 |
clang::FunctionDecl *TheFuncDecl; |
| 74 |
|
| 75 |
const clang::ParmVarDecl *TheParmVarDecl; |
| 76 |
|
| 77 |
std::string TheNewDeclName; |
| 78 |
|
| 79 |
int TheParamPos; |
| 80 |
|
| 81 |
|
| 82 |
ParamToGlobal(void); |
| 83 |
|
| 84 |
ParamToGlobal(const ParamToGlobal &); |
| 85 |
|
| 86 |
void operator=(const ParamToGlobal &); |
| 87 |
}; |
| 88 |
#endif |