| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef INSTANTIATE_TEMPLATE_PARAM_H |
| 12 |
#define INSTANTIATE_TEMPLATE_PARAM_H |
| 13 |
|
| 14 |
#include "llvm/ADT/SmallPtrSet.h" |
| 15 |
#include "Transformation.h" |
| 16 |
|
| 17 |
namespace clang { |
| 18 |
class DeclGroupRef; |
| 19 |
class ASTContext; |
| 20 |
class FunctionTemplateDecl; |
| 21 |
class ClassTemplateDecl; |
| 22 |
class TemplateDecl; |
| 23 |
class TemplateArgumentList; |
| 24 |
class TemplateArgument; |
| 25 |
class QualType; |
| 26 |
class NamedDecl; |
| 27 |
class Type; |
| 28 |
class RecordDecl; |
| 29 |
} |
| 30 |
|
| 31 |
class InstantiateTemplateParamASTVisitor; |
| 32 |
class InstantiateTemplateParamRewriteVisitor; |
| 33 |
|
| 34 |
class InstantiateTemplateParam : public Transformation { |
| 35 |
friend class InstantiateTemplateParamASTVisitor; |
| 36 |
friend class InstantiateTemplateParamRewriteVisitor; |
| 37 |
|
| 38 |
public: |
| 39 |
InstantiateTemplateParam(const char *TransName, const char *Desc) |
| 40 |
: Transformation(TransName, Desc), |
| 41 |
CollectionVisitor(NULL), |
| 42 |
ParamRewriteVisitor(NULL), |
| 43 |
TheParameter(NULL), |
| 44 |
TheTemplateDecl(NULL), |
| 45 |
TheInstantiationString(""), |
| 46 |
TheForwardDeclString("") |
| 47 |
{} |
| 48 |
|
| 49 |
~InstantiateTemplateParam(); |
| 50 |
|
| 51 |
private: |
| 52 |
|
| 53 |
typedef llvm::SmallPtrSet<const clang::RecordDecl *, 10> RecordDeclSet; |
| 54 |
|
| 55 |
typedef llvm::SmallPtrSet<void *, 10> LocPtrSet; |
| 56 |
|
| 57 |
virtual void Initialize(clang::ASTContext &context); |
| 58 |
|
| 59 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 60 |
|
| 61 |
void handleOneFunctionTemplateDecl(const clang::FunctionTemplateDecl *D); |
| 62 |
|
| 63 |
void handleOneClassTemplateDecl(const clang::ClassTemplateDecl *D); |
| 64 |
|
| 65 |
void handleOneTemplateSpecialization( |
| 66 |
const clang::TemplateDecl *D, |
| 67 |
const clang::TemplateArgumentList & ArgList); |
| 68 |
|
| 69 |
bool getTemplateArgumentString(const clang::TemplateArgument &Arg, |
| 70 |
std::string &Str, |
| 71 |
std::string &ForwardStr); |
| 72 |
|
| 73 |
bool getTypeString(const clang::QualType &QT, |
| 74 |
std::string &ArgStr, |
| 75 |
std::string &ForwardStr); |
| 76 |
|
| 77 |
void getForwardDeclStr(const clang::Type *Ty, |
| 78 |
std::string &ForwardStr, |
| 79 |
RecordDeclSet &TempAvailableRecordDecls); |
| 80 |
|
| 81 |
void addOneForwardDeclStr(const clang::RecordDecl *RD, |
| 82 |
std::string &ForwardStr, |
| 83 |
RecordDeclSet &TempAvailableRecordDecls); |
| 84 |
|
| 85 |
void addForwardTemplateDeclStr(const clang::ClassTemplateDecl *ClassTD, |
| 86 |
std::string &ForwardStr, |
| 87 |
RecordDeclSet &TempAvailableRecordDecls); |
| 88 |
|
| 89 |
void removeTemplateKeyword(); |
| 90 |
|
| 91 |
void addForwardDecl(); |
| 92 |
|
| 93 |
RecordDeclSet AvailableRecordDecls; |
| 94 |
|
| 95 |
LocPtrSet VisitedLocs; |
| 96 |
|
| 97 |
InstantiateTemplateParamASTVisitor *CollectionVisitor; |
| 98 |
|
| 99 |
InstantiateTemplateParamRewriteVisitor *ParamRewriteVisitor; |
| 100 |
|
| 101 |
const clang::NamedDecl *TheParameter; |
| 102 |
|
| 103 |
const clang::TemplateDecl *TheTemplateDecl; |
| 104 |
|
| 105 |
std::string TheInstantiationString; |
| 106 |
|
| 107 |
std::string TheForwardDeclString; |
| 108 |
|
| 109 |
|
| 110 |
InstantiateTemplateParam(); |
| 111 |
|
| 112 |
InstantiateTemplateParam(const InstantiateTemplateParam &); |
| 113 |
|
| 114 |
void operator=(const InstantiateTemplateParam &); |
| 115 |
}; |
| 116 |
|
| 117 |
#endif |