diff options
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h')
-rw-r--r-- | clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h b/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h index d6ea557b369..e28a45b10d1 100644 --- a/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h +++ b/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// /// /// \file -/// \brief This file contains the declaration of the UseAutoFixer class which -/// is used as an ASTMatcher callback. +/// \brief This file contains the declarations for callbacks used by the +/// UseAuto transform. /// //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_ACTIONS_H @@ -19,16 +19,37 @@ #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Tooling/Refactoring.h" -/// \brief The callback to be used for use-auto AST matchers. -class UseAutoFixer : public clang::ast_matchers::MatchFinder::MatchCallback { +/// \brief The callback to be used when replacing type specifiers of variable +/// declarations that are iterators. +class IteratorReplacer + : public clang::ast_matchers::MatchFinder::MatchCallback { public: - UseAutoFixer(clang::tooling::Replacements &Replace, unsigned &AcceptedChanges, - RiskLevel) + IteratorReplacer(clang::tooling::Replacements &Replace, + unsigned &AcceptedChanges, RiskLevel) : Replace(Replace), AcceptedChanges(AcceptedChanges) { } /// \brief Entry point to the callback called when matches are made. - virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result); + virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result) + LLVM_OVERRIDE; + +private: + clang::tooling::Replacements &Replace; + unsigned &AcceptedChanges; +}; + +/// \brief The callback used when replacing type specifiers of variable +/// declarations initialized by a C++ new expression. +class NewReplacer : public clang::ast_matchers::MatchFinder::MatchCallback { +public: + NewReplacer(clang::tooling::Replacements &Replace, unsigned &AcceptedChanges, + RiskLevel) + : Replace(Replace), AcceptedChanges(AcceptedChanges) { + } + + /// \brief Entry point to the callback called when matches are made. + virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result) + LLVM_OVERRIDE; private: clang::tooling::Replacements &Replace; |