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