-
Notifications
You must be signed in to change notification settings - Fork 1
/
lambda.h
executable file
·95 lines (70 loc) · 2.75 KB
/
lambda.h
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
#ifndef CPP14REGRESS_LAMBDA_FUNCTION_H
#define CPP14REGRESS_LAMBDA_FUNCTION_H
#include "clang/Driver/Options.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Lex/Lexer.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/ParentMap.h"
#include "cpp14feature.h"
#include "utils.h"
#include <string>
#include <sstream>
#include <algorithm>
namespace cpp14regress {
/*class VariableToField : public StringGenerator {
private:
const clang::ValueDecl *f_variable;
public:
VariableToField(const clang::ValueDecl *variable) : f_variable(variable) {}
virtual std::string toString();
};*/
struct LambdaClassName {
static std::string toString(unsigned i);
};
struct LambdaHeaderName {
static std::string toString(unsigned i, std::string seed);
};
struct LambdaHeaderGuard {
static std::string toString(unsigned i, std::string seed);
};
struct GenericType {
static std::string toString(unsigned i);
};
class IncludeLocSearcher : public InParentSearcher {
private:
clang::SourceLocation f_location;
virtual bool checkDecl(const clang::Decl *decl);
public:
IncludeLocSearcher(clang::ASTContext *astContext) : InParentSearcher(astContext) {}
clang::SourceLocation find(const clang::Stmt *stmt);
};
class InParentTemplateSearcher : public InParentSearcher {
private:
const clang::RedeclarableTemplateDecl *f_templateDecl = nullptr;
virtual bool checkDecl(const clang::Decl *decl);
public:
InParentTemplateSearcher(clang::ASTContext *astContext) : InParentSearcher(astContext) {}
const clang::RedeclarableTemplateDecl *find(const clang::Stmt *stmt);
};
class LambdaReplacer : public FeatureVisitor {
public:
typedef NameGenerator<LambdaClassName> LambdaClassNameGenerator;
typedef NameGenerator<LambdaHeaderName> LambdaHeaderNameGenerator;
typedef NameGenerator<LambdaHeaderGuard> LambdaHeaderGuardGenerator;
typedef NameGenerator<GenericType> GenericTypeGenerator;
LambdaReplacer(clang::CompilerInstance *ci) : FeatureVisitor(ci) {}
virtual features::type type() { return features::type::lambda; }
//virtual bool VisitCallExpr(clang::CallExpr *lambdaCall);
virtual bool VisitLambdaExpr(clang::LambdaExpr *lambda);
};
}
#endif //CPP14REGRESS_LAMBDA_FUNCTION_H