| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef REMOVE_NESTED_FUNCTION_H |
| 12 |
#define REMOVE_NESTED_FUNCTION_H |
| 13 |
|
| 14 |
#include <string> |
| 15 |
#include "llvm/ADT/SmallVector.h" |
| 16 |
#include "Transformation.h" |
| 17 |
|
| 18 |
namespace clang { |
| 19 |
class DeclGroupRef; |
| 20 |
class ASTContext; |
| 21 |
class FunctionDecl; |
| 22 |
class Stmt; |
| 23 |
class CallExpr; |
| 24 |
class DeclarationName; |
| 25 |
class DeclContext; |
| 26 |
class NestedNameSpecifier; |
| 27 |
class CXXOperatorCallExpr; |
| 28 |
class QualType; |
| 29 |
} |
| 30 |
|
| 31 |
class RNFCollectionVisitor; |
| 32 |
class RNFStatementVisitor; |
| 33 |
|
| 34 |
class RemoveNestedFunction : public Transformation { |
| 35 |
friend class RNFCollectionVisitor; |
| 36 |
friend class RNFStatementVisitor; |
| 37 |
|
| 38 |
public: |
| 39 |
|
| 40 |
RemoveNestedFunction(const char *TransName, const char *Desc) |
| 41 |
: Transformation(TransName, Desc), |
| 42 |
NestedInvocationVisitor(NULL), |
| 43 |
StmtVisitor(NULL), |
| 44 |
NameQueryWrap(NULL), |
| 45 |
TheFuncDecl(NULL), |
| 46 |
TheStmt(NULL), |
| 47 |
TheCallExpr(NULL), |
| 48 |
TmpVarName(""), |
| 49 |
NeedParen(false) |
| 50 |
{ } |
| 51 |
|
| 52 |
~RemoveNestedFunction(void); |
| 53 |
|
| 54 |
private: |
| 55 |
|
| 56 |
virtual void Initialize(clang::ASTContext &context); |
| 57 |
|
| 58 |
virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); |
| 59 |
|
| 60 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 61 |
|
| 62 |
void getNewTmpVariableStr(clang::ASTContext &ASTCtx, std::string &VarStr); |
| 63 |
|
| 64 |
void addNewTmpVariable(clang::ASTContext &ASTCtx); |
| 65 |
|
| 66 |
bool isInvalidOperator(const clang::CXXOperatorCallExpr *OpE); |
| 67 |
|
| 68 |
void setTmpVarName(std::string &Name) { |
| 69 |
TmpVarName = Name; |
| 70 |
} |
| 71 |
|
| 72 |
std::string getTmpVarName(void) { |
| 73 |
return TmpVarName; |
| 74 |
} |
| 75 |
|
| 76 |
void getVarStrForTemplateSpecialization( |
| 77 |
std::string &VarStr, |
| 78 |
const clang::TemplateSpecializationType *TST); |
| 79 |
|
| 80 |
void getNewTmpVariable(const clang::QualType &QT, std::string &VarStr); |
| 81 |
|
| 82 |
void getNewIntTmpVariable(std::string &VarStr); |
| 83 |
|
| 84 |
void getNewAutoTmpVariable(std::string &VarStr); |
| 85 |
|
| 86 |
clang::SmallVector<clang::CallExpr *, 5> CallExprQueue; |
| 87 |
|
| 88 |
clang::SmallVector<clang::CallExpr *, 10> ValidCallExprs; |
| 89 |
|
| 90 |
RNFCollectionVisitor *NestedInvocationVisitor; |
| 91 |
|
| 92 |
RNFStatementVisitor *StmtVisitor; |
| 93 |
|
| 94 |
TransNameQueryWrap *NameQueryWrap; |
| 95 |
|
| 96 |
clang::FunctionDecl *TheFuncDecl; |
| 97 |
|
| 98 |
clang::Stmt *TheStmt; |
| 99 |
|
| 100 |
clang::CallExpr *TheCallExpr; |
| 101 |
|
| 102 |
std::string TmpVarName; |
| 103 |
|
| 104 |
bool NeedParen; |
| 105 |
|
| 106 |
|
| 107 |
RemoveNestedFunction(void); |
| 108 |
|
| 109 |
RemoveNestedFunction(const RemoveNestedFunction &); |
| 110 |
|
| 111 |
void operator=(const RemoveNestedFunction &); |
| 112 |
}; |
| 113 |
#endif |