| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef REMOVE_UNUSED_VAR_H |
| 12 |
#define REMOVE_UNUSED_VAR_H |
| 13 |
|
| 14 |
#include <string> |
| 15 |
#include "llvm/ADT/DenseMap.h" |
| 16 |
#include "llvm/ADT/SmallPtrSet.h" |
| 17 |
#include "Transformation.h" |
| 18 |
|
| 19 |
namespace clang { |
| 20 |
class DeclGroupRef; |
| 21 |
class ASTContext; |
| 22 |
class VarDecl; |
| 23 |
class LinkageSpecDecl; |
| 24 |
} |
| 25 |
|
| 26 |
class RemoveUnusedVarAnalysisVisitor; |
| 27 |
|
| 28 |
class RemoveUnusedVar : public Transformation { |
| 29 |
friend class RemoveUnusedVarAnalysisVisitor; |
| 30 |
|
| 31 |
public: |
| 32 |
|
| 33 |
RemoveUnusedVar(const char *TransName, const char *Desc) |
| 34 |
: Transformation(TransName, Desc, true), |
| 35 |
AnalysisVisitor(NULL), |
| 36 |
TheVarDecl(NULL) |
| 37 |
{ } |
| 38 |
|
| 39 |
~RemoveUnusedVar(void); |
| 40 |
|
| 41 |
private: |
| 42 |
virtual void Initialize(clang::ASTContext &context); |
| 43 |
|
| 44 |
virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); |
| 45 |
|
| 46 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 47 |
|
| 48 |
void doRewriting(); |
| 49 |
|
| 50 |
void removeVarDecl(const clang::VarDecl *VD); |
| 51 |
|
| 52 |
void removeVarDeclFromLinkageSpecDecl(const clang::LinkageSpecDecl *LinkageD, |
| 53 |
const clang::VarDecl *VD); |
| 54 |
|
| 55 |
llvm::DenseMap<const clang::VarDecl *, clang::DeclGroupRef> VarToDeclGroup; |
| 56 |
|
| 57 |
llvm::SmallPtrSet<const clang::VarDecl *, 10> SkippedVars; |
| 58 |
|
| 59 |
llvm::SmallVector<const clang::VarDecl *, 500> AllValidVarDecls; |
| 60 |
|
| 61 |
RemoveUnusedVarAnalysisVisitor *AnalysisVisitor; |
| 62 |
|
| 63 |
clang::VarDecl *TheVarDecl; |
| 64 |
|
| 65 |
|
| 66 |
RemoveUnusedVar(void); |
| 67 |
|
| 68 |
RemoveUnusedVar(const RemoveUnusedVar &); |
| 69 |
|
| 70 |
void operator=(const RemoveUnusedVar &); |
| 71 |
}; |
| 72 |
#endif |