summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoActions.h
blob: 0ddb0e0c5afc3f8af5617c36a136c5ee7849a9de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//===-- UseAuto/Actions.h - Matcher callback --------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
///  \file
///  \brief This file contains the declarations for callbacks used by the
///  UseAuto transform.
///
//===----------------------------------------------------------------------===//

#ifndef CPP11_MIGRATE_USE_AUTO_ACTIONS_H
#define CPP11_MIGRATE_USE_AUTO_ACTIONS_H

#include "Core/Transform.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Tooling/Refactoring.h"

/// \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:
  IteratorReplacer(unsigned &AcceptedChanges, RiskLevel, Transform &Owner)
      : AcceptedChanges(AcceptedChanges), Owner(Owner) {}

  /// \brief Entry point to the callback called when matches are made.
  virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result)
      LLVM_OVERRIDE;

private:
  unsigned &AcceptedChanges;
  Transform &Owner;
};

/// \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(unsigned &AcceptedChanges, RiskLevel, Transform &Owner)
      : AcceptedChanges(AcceptedChanges), Owner(Owner) {}

  /// \brief Entry point to the callback called when matches are made.
  virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result)
      LLVM_OVERRIDE;

private:
  unsigned &AcceptedChanges;
  Transform &Owner;
};

#endif // CPP11_MIGRATE_USE_AUTO_ACTIONS_H
OpenPOWER on IntegriCloud