FindTemplateTypes.h 1.18 KB
Newer Older
1
2
#ifndef _FIND_TEMPLATE_TYPES_H_
#define _FIND_TEMPLATE_TYPES_H_
Anirudh Kaushik's avatar
Anirudh Kaushik committed
3
4
5

#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
rmrf's avatar
rmrf committed
6
#include "clang/AST/RecursiveASTVisitor.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
7
#include "clang/AST/Type.h"
rmrf's avatar
rmrf committed
8
9
10
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <vector>
Anirudh Kaushik's avatar
Anirudh Kaushik committed
11

rmrf's avatar
rmrf committed
12
13
#include <iostream>

Anirudh Kaushik's avatar
Anirudh Kaushik committed
14
namespace scpar {
rmrf's avatar
rmrf committed
15
16
17
18
19
20
21
22
23
24
25
using namespace clang;
using namespace std;

// This class is going to find the arguments from templates
class FindTemplateTypes : public RecursiveASTVisitor<FindTemplateTypes> {
public:
  /// Typedefs
  typedef vector<pair<string, const Type *>> type_vector_t;
  typedef vector<pair<string, const Type *>> argVectorType;

  // Constructor
rmrf's avatar
rmrf committed
26
  FindTemplateTypes();
rmrf's avatar
rmrf committed
27
28

  /// Copy constructor
rmrf's avatar
rmrf committed
29
30
31
32
33
34
35
36
37
38
  FindTemplateTypes(const FindTemplateTypes &rhs);
  FindTemplateTypes(const FindTemplateTypes *rhs);
  string getTemplateType();
  type_vector_t Enumerate(const Type *type);
  bool VisitType(Type *type);
  bool VisitIntegerLiteral(IntegerLiteral *l);
  type_vector_t getTemplateArgumentsType();
  void printTemplateArguments(llvm::raw_ostream &os);
  vector<string> getTemplateArguments();
  size_t size();
rmrf's avatar
rmrf committed
39

rmrf's avatar
rmrf committed
40
private:
rmrf's avatar
rmrf committed
41
  // (string, Type*)
rmrf's avatar
rmrf committed
42
43
44
  type_vector_t template_types_;
};
} // namespace scpar
Anirudh Kaushik's avatar
Anirudh Kaushik committed
45
#endif