| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef SIMPLIFY_STRUCT_UNION_DECL_H |
| 12 |
#define SIMPLIFY_STRUCT_UNION_DECL_H |
| 13 |
|
| 14 |
#include "llvm/ADT/DenseMap.h" |
| 15 |
#include "llvm/ADT/SmallVector.h" |
| 16 |
#include "llvm/ADT/SmallPtrSet.h" |
| 17 |
#include "Transformation.h" |
| 18 |
|
| 19 |
namespace clang { |
| 20 |
class DeclGroupRef; |
| 21 |
class ASTContext; |
| 22 |
class RecordDecl; |
| 23 |
class Type; |
| 24 |
class VarDecl; |
| 25 |
} |
| 26 |
|
| 27 |
class SimplifyStructUnionDeclVisitor; |
| 28 |
|
| 29 |
class SimplifyStructUnionDecl : public Transformation { |
| 30 |
|
| 31 |
friend class SimplifyStructUnionDeclVisitor; |
| 32 |
|
| 33 |
public: |
| 34 |
|
| 35 |
SimplifyStructUnionDecl(const char *TransName, const char *Desc) |
| 36 |
: Transformation(TransName, Desc), |
| 37 |
AnalysisVisitor(NULL), |
| 38 |
TheRecordDecl(NULL), |
| 39 |
SafeToRemoveName(true) |
| 40 |
{ } |
| 41 |
|
| 42 |
~SimplifyStructUnionDecl(void); |
| 43 |
|
| 44 |
private: |
| 45 |
|
| 46 |
typedef llvm::SmallPtrSet<const clang::VarDecl *, 5> VarDeclSet; |
| 47 |
|
| 48 |
typedef llvm::DenseMap<const clang::Decl*, void *> |
| 49 |
RecordDeclToDeclGroupMap; |
| 50 |
|
| 51 |
virtual void Initialize(clang::ASTContext &context); |
| 52 |
|
| 53 |
virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); |
| 54 |
|
| 55 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 56 |
|
| 57 |
void addOneRecordDecl(const clang::RecordDecl *RD, clang::DeclGroupRef DGR); |
| 58 |
|
| 59 |
void doCombination(); |
| 60 |
|
| 61 |
bool handleOneDeclarator(const clang::Type *Ty); |
| 62 |
|
| 63 |
const clang::RecordDecl *getBaseRecordDecl(const clang::Type *Ty); |
| 64 |
|
| 65 |
bool isSafeToRemoveName(void); |
| 66 |
|
| 67 |
RecordDeclToDeclGroupMap RecordDeclToDeclGroup; |
| 68 |
|
| 69 |
llvm::SmallVector<void *, 2> TheDeclGroupRefs; |
| 70 |
|
| 71 |
VarDeclSet CombinedVars; |
| 72 |
|
| 73 |
SimplifyStructUnionDeclVisitor *AnalysisVisitor; |
| 74 |
|
| 75 |
const clang::RecordDecl *TheRecordDecl; |
| 76 |
|
| 77 |
bool SafeToRemoveName; |
| 78 |
|
| 79 |
|
| 80 |
SimplifyStructUnionDecl(void); |
| 81 |
|
| 82 |
SimplifyStructUnionDecl(const SimplifyStructUnionDecl &); |
| 83 |
|
| 84 |
void operator=(const SimplifyStructUnionDecl &); |
| 85 |
}; |
| 86 |
#endif |