OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <set> |
| 6 #include <string> |
| 7 #include <vector> |
| 8 |
| 9 #include "clang/AST/RecursiveASTVisitor.h" |
| 10 |
| 11 #include "Util.h" |
| 12 |
| 13 #ifndef TOOLS_CLANG_BINDMIGRATE_TRANSFORM_H_ |
| 14 #define TOOLS_CLANG_BINDMIGRATE_TRANSFORM_H_ |
| 15 |
| 16 namespace clang { |
| 17 |
| 18 class Stmt; |
| 19 class Decl; |
| 20 class Type; |
| 21 |
| 22 class Transform { |
| 23 public: |
| 24 typedef std::vector<Transform*> TransformList; |
| 25 |
| 26 virtual bool WouldTransformStmt(Stmt* statement) { return false; } |
| 27 virtual bool WouldTransformDecl(Decl* decl) { return false; } |
| 28 virtual bool WouldTransformType(Type* type) { return false; } |
| 29 |
| 30 virtual void TransformStmt(Stmt *statement) {} |
| 31 virtual void TransformDecl(Decl *decl) {} |
| 32 virtual void TransformType(Type* type) {} |
| 33 }; |
| 34 |
| 35 class TransformApplier : public RecursiveASTVisitor<TransformApplier> { |
| 36 public: |
| 37 // The transforms must outlive the TransformApplier; |
| 38 TransformApplier(const Transform::TransformList& transforms); |
| 39 |
| 40 virtual bool VisitStmt(Stmt *statement); |
| 41 virtual bool VisitDecl(Decl *decl); |
| 42 virtual bool VisitType(Type* type); |
| 43 |
| 44 private: |
| 45 std::vector<Transform*> transforms_; |
| 46 }; |
| 47 |
| 48 class TransformCandidatePrinter : |
| 49 public RecursiveASTVisitor<TransformCandidatePrinter> { |
| 50 public: |
| 51 // The transforms must outlive the TransformCandidatePrinter; |
| 52 TransformCandidatePrinter(const Transform::TransformList& transforms, |
| 53 SourceManager* source_manager); |
| 54 virtual ~TransformCandidatePrinter(); |
| 55 |
| 56 virtual bool VisitStmt(Stmt *statement); |
| 57 virtual bool VisitDecl(Decl *decl); |
| 58 virtual bool VisitType(Type* type); |
| 59 |
| 60 private: |
| 61 void AddFileForLocation(SourceLocation location); |
| 62 |
| 63 std::vector<Transform*> transforms_; |
| 64 SourceManager* source_manager_; |
| 65 std::set<std::string> filenames_; |
| 66 }; |
| 67 |
| 68 } // namespace |
| 69 |
| 70 #endif // TOOLS_CLANG_BINDMIGRATE_TRANSFORM_H_ |
OLD | NEW |