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