| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef TEMPLATE_ARG_TO_INT_H |
| 12 |
#define TEMPLATE_ARG_TO_INT_H |
| 13 |
|
| 14 |
#include "llvm/ADT/SmallPtrSet.h" |
| 15 |
#include "llvm/ADT/SmallSet.h" |
| 16 |
#include "llvm/ADT/DenseMap.h" |
| 17 |
#include "Transformation.h" |
| 18 |
|
| 19 |
namespace clang { |
| 20 |
class DeclGroupRef; |
| 21 |
class ASTContext; |
| 22 |
class TemplateDecl; |
| 23 |
class NamedDecl; |
| 24 |
class TemplateArgumentLoc; |
| 25 |
class TemplateSpecializationTypeLoc; |
| 26 |
class TypeSourceInfo; |
| 27 |
class Type; |
| 28 |
class SubstTemplateTypeParmType; |
| 29 |
} |
| 30 |
|
| 31 |
class TemplateArgToIntASTVisitor; |
| 32 |
class TemplateArgToIntArgCollector; |
| 33 |
class TemplateGlobalInvalidParameterVisitor; |
| 34 |
|
| 35 |
namespace clang_delta_common_visitor { |
| 36 |
template<typename T, typename Trans> class CommonTemplateArgumentVisitor; |
| 37 |
} |
| 38 |
|
| 39 |
class TemplateArgToInt : public Transformation { |
| 40 |
friend class TemplateArgToIntASTVisitor; |
| 41 |
friend class TemplateArgToIntArgCollector; |
| 42 |
friend class TemplateInvalidParameterVisitor; |
| 43 |
friend class TemplateGlobalInvalidParameterVisitor; |
| 44 |
friend class clang_delta_common_visitor:: |
| 45 |
CommonTemplateArgumentVisitor<TemplateArgToIntArgCollector, |
| 46 |
TemplateArgToInt>; |
| 47 |
|
| 48 |
public: |
| 49 |
TemplateArgToInt(const char *TransName, const char *Desc) |
| 50 |
: Transformation(TransName, Desc), |
| 51 |
CollectionVisitor(NULL), |
| 52 |
ArgCollector(NULL), |
| 53 |
GlobalParamFilter(NULL) |
| 54 |
{} |
| 55 |
|
| 56 |
~TemplateArgToInt(); |
| 57 |
|
| 58 |
private: |
| 59 |
|
| 60 |
typedef llvm::SmallPtrSet<const clang::TemplateDecl *, 10> TemplateDeclSet; |
| 61 |
|
| 62 |
typedef llvm::SmallPtrSet<const clang::NamedDecl *, 8> TemplateParameterSet; |
| 63 |
|
| 64 |
typedef llvm::SmallSet<unsigned, 8> TemplateParameterIdxSet; |
| 65 |
|
| 66 |
typedef llvm::DenseMap<const clang::TemplateDecl *, |
| 67 |
TemplateParameterIdxSet *> TemplateDeclToParamIdxMap; |
| 68 |
|
| 69 |
typedef llvm::DenseMap<const clang::NamedDecl *, |
| 70 |
const clang::TemplateDecl *> ParameterToTemplateDeclMap; |
| 71 |
|
| 72 |
virtual void Initialize(clang::ASTContext &context); |
| 73 |
|
| 74 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 75 |
|
| 76 |
void collectInvalidParamIdx(const clang::TemplateDecl *D, |
| 77 |
TemplateParameterIdxSet &InvalidParamIdx); |
| 78 |
|
| 79 |
void handleOneTemplateDecl(const clang::TemplateDecl *D); |
| 80 |
|
| 81 |
void handleTemplateArgumentLocs(const clang::TemplateDecl *D, |
| 82 |
const clang::TemplateArgumentLoc *TAL, |
| 83 |
unsigned NumArgs); |
| 84 |
|
| 85 |
void handleOneTemplateArgumentLoc(const clang::TemplateArgumentLoc &ArgLoc); |
| 86 |
|
| 87 |
void handleTemplateSpecializationTypeLoc( |
| 88 |
const clang::TemplateSpecializationTypeLoc &TLoc); |
| 89 |
|
| 90 |
void handleOneType(const clang::Type *Ty); |
| 91 |
|
| 92 |
const clang::SubstTemplateTypeParmType * |
| 93 |
getSubstTemplateTypeParmType(const clang::Type *Ty); |
| 94 |
|
| 95 |
void rewriteTemplateArgument(); |
| 96 |
|
| 97 |
TemplateDeclToParamIdxMap DeclToParamIdx; |
| 98 |
|
| 99 |
ParameterToTemplateDeclMap ParamToTemplateDecl; |
| 100 |
|
| 101 |
TemplateArgToIntASTVisitor *CollectionVisitor; |
| 102 |
|
| 103 |
TemplateArgToIntArgCollector *ArgCollector; |
| 104 |
|
| 105 |
TemplateGlobalInvalidParameterVisitor *GlobalParamFilter; |
| 106 |
|
| 107 |
clang::TypeSourceInfo *TheTypeSourceInfo; |
| 108 |
|
| 109 |
|
| 110 |
TemplateArgToInt(); |
| 111 |
|
| 112 |
TemplateArgToInt(const TemplateArgToInt &); |
| 113 |
|
| 114 |
void operator=(const TemplateArgToInt &); |
| 115 |
}; |
| 116 |
|
| 117 |
#endif |