| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef REPLACE_FUNCTION_DEF_WITH_DECL_H |
| 12 |
#define REPLACE_FUNCTION_DEF_WITH_DECL_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 CXXConstructorDecl; |
| 23 |
class FunctionTemplateDecl; |
| 24 |
class SourceLocation; |
| 25 |
} |
| 26 |
|
| 27 |
class ReplaceFunctionDefWithDeclCollectionVisitor; |
| 28 |
|
| 29 |
class ReplaceFunctionDefWithDecl : public Transformation { |
| 30 |
friend class ReplaceFunctionDefWithDeclCollectionVisitor; |
| 31 |
|
| 32 |
public: |
| 33 |
|
| 34 |
|
| 35 |
ReplaceFunctionDefWithDecl(const char *TransName, const char *Desc) |
| 36 |
: Transformation(TransName, Desc, true), |
| 37 |
CollectionVisitor(NULL), |
| 38 |
TheFunctionDef(NULL) |
| 39 |
{ } |
| 40 |
|
| 41 |
~ReplaceFunctionDefWithDecl(); |
| 42 |
|
| 43 |
private: |
| 44 |
|
| 45 |
typedef llvm::SmallVector<const clang::FunctionDecl *, 500> |
| 46 |
FunctionDeclVector; |
| 47 |
|
| 48 |
virtual void Initialize(clang::ASTContext &context); |
| 49 |
|
| 50 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 51 |
|
| 52 |
void addOneFunctionDef(const clang::FunctionDecl *FD); |
| 53 |
|
| 54 |
void rewriteOneFunctionDef(const clang::FunctionDecl *FD); |
| 55 |
|
| 56 |
void removeCtorInitializers(const clang::CXXConstructorDecl *Ctor); |
| 57 |
|
| 58 |
unsigned getNumWrittenInitializers(const clang::CXXConstructorDecl *Ctor); |
| 59 |
|
| 60 |
bool hasValidOuterLocStart(const clang::FunctionTemplateDecl *FTD, |
| 61 |
const clang::FunctionDecl *FD); |
| 62 |
|
| 63 |
void removeStringBeforeTypeIdentifier(const clang::SourceLocation &StartLoc, |
| 64 |
const clang::SourceLocation &EndLoc); |
| 65 |
|
| 66 |
bool removeOneInlineKeyword(const std::string &LeadingInlineStr, |
| 67 |
const std::string &InlineStr, |
| 68 |
const std::string &Str, |
| 69 |
const clang::SourceLocation &StartLoc); |
| 70 |
|
| 71 |
bool removeInlineKeyword(const std::string &InlineStr, |
| 72 |
const std::string &Str, |
| 73 |
const clang::SourceLocation &StartLoc); |
| 74 |
|
| 75 |
void removeInlineKeywordFromOneFunctionDecl(const clang::FunctionDecl *FD); |
| 76 |
|
| 77 |
void removeInlineKeywordFromFunctionDecls(const clang::FunctionDecl *FD); |
| 78 |
|
| 79 |
void doRewriting(); |
| 80 |
|
| 81 |
FunctionDeclVector AllValidFunctionDefs; |
| 82 |
|
| 83 |
ReplaceFunctionDefWithDeclCollectionVisitor *CollectionVisitor; |
| 84 |
|
| 85 |
const clang::FunctionDecl *TheFunctionDef; |
| 86 |
|
| 87 |
|
| 88 |
ReplaceFunctionDefWithDecl(void); |
| 89 |
|
| 90 |
ReplaceFunctionDefWithDecl(const ReplaceFunctionDefWithDecl &); |
| 91 |
|
| 92 |
void operator=(const ReplaceFunctionDefWithDecl &); |
| 93 |
}; |
| 94 |
#endif |
| 95 |
|