2011-06-17 00:17:05 +08:00
|
|
|
//===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-06-17 00:17:05 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/ARCMigrate/ARCMTActions.h"
|
|
|
|
#include "clang/ARCMigrate/ARCMT.h"
|
|
|
|
#include "clang/Frontend/CompilerInstance.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
using namespace arcmt;
|
|
|
|
|
2011-06-18 08:53:41 +08:00
|
|
|
bool CheckAction::BeginInvocation(CompilerInstance &CI) {
|
2012-01-21 00:28:04 +08:00
|
|
|
if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
|
2015-06-21 02:53:08 +08:00
|
|
|
CI.getPCHContainerOperations(),
|
2011-06-17 00:17:05 +08:00
|
|
|
CI.getDiagnostics().getClient()))
|
2011-06-18 08:53:41 +08:00
|
|
|
return false; // errors, stop the action.
|
2011-06-17 00:17:05 +08:00
|
|
|
|
|
|
|
// We only want to see warnings reported from arcmt::checkForManualIssues.
|
|
|
|
CI.getDiagnostics().setIgnoreAllWarnings(true);
|
2011-06-18 08:53:41 +08:00
|
|
|
return true;
|
2011-06-17 00:17:05 +08:00
|
|
|
}
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
|
|
|
|
: WrapperFrontendAction(std::move(WrappedAction)) {}
|
2011-06-17 00:17:05 +08:00
|
|
|
|
2011-07-10 04:00:58 +08:00
|
|
|
bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
|
2012-01-21 00:28:04 +08:00
|
|
|
return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
|
2015-06-21 02:53:08 +08:00
|
|
|
CI.getPCHContainerOperations(),
|
2011-07-10 04:00:58 +08:00
|
|
|
CI.getDiagnostics().getClient());
|
2011-06-17 00:17:05 +08:00
|
|
|
}
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
|
|
|
|
: WrapperFrontendAction(std::move(WrappedAction)) {}
|
2011-07-10 04:00:58 +08:00
|
|
|
|
|
|
|
bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
|
2015-06-21 02:53:08 +08:00
|
|
|
if (arcmt::migrateWithTemporaryFiles(
|
|
|
|
CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
|
|
|
|
CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErros,
|
|
|
|
PlistOut))
|
2011-07-20 01:20:03 +08:00
|
|
|
return false; // errors, stop the action.
|
|
|
|
|
|
|
|
// We only want to see diagnostics emitted by migrateWithTemporaryFiles.
|
|
|
|
CI.getDiagnostics().setIgnoreAllWarnings(true);
|
|
|
|
return true;
|
2011-07-10 04:00:58 +08:00
|
|
|
}
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef migrateDir,
|
|
|
|
StringRef plistOut,
|
2011-07-20 01:20:03 +08:00
|
|
|
bool emitPremigrationARCErrors)
|
2016-02-08 03:28:36 +08:00
|
|
|
: WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
|
2011-07-20 01:20:03 +08:00
|
|
|
PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
|
2011-07-10 04:00:58 +08:00
|
|
|
if (MigrateDir.empty())
|
|
|
|
MigrateDir = "."; // user current directory if none is given.
|
|
|
|
}
|