Debian Codegraph @

clang_delta/AggregateToScalar.h

raw symbols SCIP
1 //===----------------------------------------------------------------------===//
2 //
3 // Copyright (c) 2012, 2013 The University of Utah
4 // All rights reserved.
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See the file COPYING for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef AGGREGATE_TO_SCALAR_H
12 #define AGGREGATE_TO_SCALAR_H
13
14 #include <string>
15 #include <set>
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/SmallPtrSet.h"
18 #include "Transformation.h"
19
20 namespace clang {
21 class DeclGroupRef;
22 class ASTContext;
23 class FunctionDecl;
24 class MemberExpr;
25 class VarDecl;
26 class InitListExpr;
27 class DeclStmt;
28 class Expr;
29 class ArraySubscriptExpr;
30 }
31
32 class ATSCollectionVisitor;
33
34 class AggregateToScalar : public Transformation {
35 friend class ATSCollectionVisitor;
36
37 public:
38
39 AggregateToScalar(const char *TransName, const char *Desc)
40 : Transformation(TransName, Desc),
41 AggregateAccessVisitor(NULL),
42 TheVarDecl(NULL),
43 TheIdx(NULL)
44 { }
45
46 ~AggregateToScalar(void);
47
48 private:
49
50 typedef std::set<const clang::Expr *> ExprSet;
51
52 typedef llvm::DenseMap<IndexVector *, ExprSet *>
53 IdxToExpr;
54
55 typedef llvm::SmallPtrSet<IndexVector *, 10> IdxVectorSet;
56
57 typedef llvm::DenseMap<const clang::VarDecl *, IdxVectorSet *>
58 VarToIdx;
59
60 virtual void Initialize(clang::ASTContext &context);
61
62 virtual bool HandleTopLevelDecl(clang::DeclGroupRef D);
63
64 virtual void HandleTranslationUnit(clang::ASTContext &Ctx);
65
66 bool isStructuralEqualVectors(IndexVector *IV1, IndexVector *IV2);
67
68 void addOneIdx(const clang::Expr *E,
69 const clang::VarDecl *VD,
70 IdxVectorSet *IdxSet, IndexVector *Idx);
71
72 void addOneExpr(const clang::Expr *E);
73
74 bool createNewVar(const clang::Expr *RefE, std::string &VarName);
75
76 bool addTmpVar(const clang::Expr *RefE, const std::string &VarName,
77 const std::string *InitStr);
78
79 void createNewVarName(std::string &VarName);
80
81 void doRewrite(void);
82
83 llvm::DenseMap<const clang::VarDecl *, clang::DeclStmt *> VarDeclToDeclStmtMap;
84
85 VarToIdx ValidVars;
86
87 IdxToExpr ValidExprs;
88
89 ATSCollectionVisitor *AggregateAccessVisitor;
90
91 const clang::VarDecl *TheVarDecl;
92
93 IndexVector *TheIdx;
94
95 // Unimplemented
96 AggregateToScalar(void);
97
98 AggregateToScalar(const AggregateToScalar &);
99
100 void operator=(const AggregateToScalar &);
101 };
102 #endif