1*0b57cec5SDimitry Andric //===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "clang/ARCMigrate/ARCMTActions.h" 10*0b57cec5SDimitry Andric #include "clang/ARCMigrate/ARCMT.h" 11*0b57cec5SDimitry Andric #include "clang/Frontend/CompilerInstance.h" 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric using namespace clang; 14*0b57cec5SDimitry Andric using namespace arcmt; 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric bool CheckAction::BeginInvocation(CompilerInstance &CI) { 17*0b57cec5SDimitry Andric if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(), 18*0b57cec5SDimitry Andric CI.getPCHContainerOperations(), 19*0b57cec5SDimitry Andric CI.getDiagnostics().getClient())) 20*0b57cec5SDimitry Andric return false; // errors, stop the action. 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric // We only want to see warnings reported from arcmt::checkForManualIssues. 23*0b57cec5SDimitry Andric CI.getDiagnostics().setIgnoreAllWarnings(true); 24*0b57cec5SDimitry Andric return true; 25*0b57cec5SDimitry Andric } 26*0b57cec5SDimitry Andric 27*0b57cec5SDimitry Andric CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction) 28*0b57cec5SDimitry Andric : WrapperFrontendAction(std::move(WrappedAction)) {} 29*0b57cec5SDimitry Andric 30*0b57cec5SDimitry Andric bool ModifyAction::BeginInvocation(CompilerInstance &CI) { 31*0b57cec5SDimitry Andric return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(), 32*0b57cec5SDimitry Andric CI.getPCHContainerOperations(), 33*0b57cec5SDimitry Andric CI.getDiagnostics().getClient()); 34*0b57cec5SDimitry Andric } 35*0b57cec5SDimitry Andric 36*0b57cec5SDimitry Andric ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction) 37*0b57cec5SDimitry Andric : WrapperFrontendAction(std::move(WrappedAction)) {} 38*0b57cec5SDimitry Andric 39*0b57cec5SDimitry Andric bool MigrateAction::BeginInvocation(CompilerInstance &CI) { 40*0b57cec5SDimitry Andric if (arcmt::migrateWithTemporaryFiles( 41*0b57cec5SDimitry Andric CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(), 42*0b57cec5SDimitry Andric CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErros, 43*0b57cec5SDimitry Andric PlistOut)) 44*0b57cec5SDimitry Andric return false; // errors, stop the action. 45*0b57cec5SDimitry Andric 46*0b57cec5SDimitry Andric // We only want to see diagnostics emitted by migrateWithTemporaryFiles. 47*0b57cec5SDimitry Andric CI.getDiagnostics().setIgnoreAllWarnings(true); 48*0b57cec5SDimitry Andric return true; 49*0b57cec5SDimitry Andric } 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction, 52*0b57cec5SDimitry Andric StringRef migrateDir, 53*0b57cec5SDimitry Andric StringRef plistOut, 54*0b57cec5SDimitry Andric bool emitPremigrationARCErrors) 55*0b57cec5SDimitry Andric : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir), 56*0b57cec5SDimitry Andric PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) { 57*0b57cec5SDimitry Andric if (MigrateDir.empty()) 58*0b57cec5SDimitry Andric MigrateDir = "."; // user current directory if none is given. 59*0b57cec5SDimitry Andric } 60