blob: 0ed36ddf68c8d5e601e6402edd80269ea30a6a7e [file] [log] [blame]
Chandler Carruthf7f81882011-06-16 16:17:05 +00001//===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/ARCMigrate/ARCMTActions.h"
11#include "clang/ARCMigrate/ARCMT.h"
12#include "clang/Frontend/CompilerInstance.h"
13
14using namespace clang;
15using namespace arcmt;
16
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +000017bool CheckAction::BeginInvocation(CompilerInstance &CI) {
Douglas Gregor1f6b2b52012-01-20 16:28:04 +000018 if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
Chandler Carruthf7f81882011-06-16 16:17:05 +000019 CI.getDiagnostics().getClient()))
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +000020 return false; // errors, stop the action.
Chandler Carruthf7f81882011-06-16 16:17:05 +000021
22 // We only want to see warnings reported from arcmt::checkForManualIssues.
23 CI.getDiagnostics().setIgnoreAllWarnings(true);
Argyrios Kyrtzidise665d692011-06-18 00:53:41 +000024 return true;
Chandler Carruthf7f81882011-06-16 16:17:05 +000025}
26
27CheckAction::CheckAction(FrontendAction *WrappedAction)
28 : WrapperFrontendAction(WrappedAction) {}
29
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000030bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
Douglas Gregor1f6b2b52012-01-20 16:28:04 +000031 return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000032 CI.getDiagnostics().getClient());
Chandler Carruthf7f81882011-06-16 16:17:05 +000033}
34
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000035ModifyAction::ModifyAction(FrontendAction *WrappedAction)
Chandler Carruthf7f81882011-06-16 16:17:05 +000036 : WrapperFrontendAction(WrappedAction) {}
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000037
38bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
Argyrios Kyrtzidis7ee20492011-07-19 17:20:03 +000039 if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(),
Douglas Gregor1f6b2b52012-01-20 16:28:04 +000040 getCurrentInput(),
41 CI.getDiagnostics().getClient(),
42 MigrateDir,
43 EmitPremigrationARCErros,
44 PlistOut))
Argyrios Kyrtzidis7ee20492011-07-19 17:20:03 +000045 return false; // errors, stop the action.
46
47 // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
48 CI.getDiagnostics().setIgnoreAllWarnings(true);
49 return true;
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000050}
51
52MigrateAction::MigrateAction(FrontendAction *WrappedAction,
Chris Lattner5f9e2722011-07-23 10:55:15 +000053 StringRef migrateDir,
54 StringRef plistOut,
Argyrios Kyrtzidis7ee20492011-07-19 17:20:03 +000055 bool emitPremigrationARCErrors)
56 : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),
57 PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
Argyrios Kyrtzidis69325d52011-07-09 20:00:58 +000058 if (MigrateDir.empty())
59 MigrateDir = "."; // user current directory if none is given.
60}