1*f4a2713aSLionel Sambuc //===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
2*f4a2713aSLionel Sambuc //
3*f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure
4*f4a2713aSLionel Sambuc //
5*f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6*f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7*f4a2713aSLionel Sambuc //
8*f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc #include "clang/ARCMigrate/ARCMTActions.h"
11*f4a2713aSLionel Sambuc #include "clang/ARCMigrate/ARCMT.h"
12*f4a2713aSLionel Sambuc #include "clang/Frontend/CompilerInstance.h"
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc using namespace clang;
15*f4a2713aSLionel Sambuc using namespace arcmt;
16*f4a2713aSLionel Sambuc
BeginInvocation(CompilerInstance & CI)17*f4a2713aSLionel Sambuc bool CheckAction::BeginInvocation(CompilerInstance &CI) {
18*f4a2713aSLionel Sambuc if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
19*f4a2713aSLionel Sambuc CI.getDiagnostics().getClient()))
20*f4a2713aSLionel Sambuc return false; // errors, stop the action.
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc // We only want to see warnings reported from arcmt::checkForManualIssues.
23*f4a2713aSLionel Sambuc CI.getDiagnostics().setIgnoreAllWarnings(true);
24*f4a2713aSLionel Sambuc return true;
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc
CheckAction(FrontendAction * WrappedAction)27*f4a2713aSLionel Sambuc CheckAction::CheckAction(FrontendAction *WrappedAction)
28*f4a2713aSLionel Sambuc : WrapperFrontendAction(WrappedAction) {}
29*f4a2713aSLionel Sambuc
BeginInvocation(CompilerInstance & CI)30*f4a2713aSLionel Sambuc bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
31*f4a2713aSLionel Sambuc return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
32*f4a2713aSLionel Sambuc CI.getDiagnostics().getClient());
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc
ModifyAction(FrontendAction * WrappedAction)35*f4a2713aSLionel Sambuc ModifyAction::ModifyAction(FrontendAction *WrappedAction)
36*f4a2713aSLionel Sambuc : WrapperFrontendAction(WrappedAction) {}
37*f4a2713aSLionel Sambuc
BeginInvocation(CompilerInstance & CI)38*f4a2713aSLionel Sambuc bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
39*f4a2713aSLionel Sambuc if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(),
40*f4a2713aSLionel Sambuc getCurrentInput(),
41*f4a2713aSLionel Sambuc CI.getDiagnostics().getClient(),
42*f4a2713aSLionel Sambuc MigrateDir,
43*f4a2713aSLionel Sambuc EmitPremigrationARCErros,
44*f4a2713aSLionel Sambuc PlistOut))
45*f4a2713aSLionel Sambuc return false; // errors, stop the action.
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
48*f4a2713aSLionel Sambuc CI.getDiagnostics().setIgnoreAllWarnings(true);
49*f4a2713aSLionel Sambuc return true;
50*f4a2713aSLionel Sambuc }
51*f4a2713aSLionel Sambuc
MigrateAction(FrontendAction * WrappedAction,StringRef migrateDir,StringRef plistOut,bool emitPremigrationARCErrors)52*f4a2713aSLionel Sambuc MigrateAction::MigrateAction(FrontendAction *WrappedAction,
53*f4a2713aSLionel Sambuc StringRef migrateDir,
54*f4a2713aSLionel Sambuc StringRef plistOut,
55*f4a2713aSLionel Sambuc bool emitPremigrationARCErrors)
56*f4a2713aSLionel Sambuc : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),
57*f4a2713aSLionel Sambuc PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
58*f4a2713aSLionel Sambuc if (MigrateDir.empty())
59*f4a2713aSLionel Sambuc MigrateDir = "."; // user current directory if none is given.
60*f4a2713aSLionel Sambuc }
61