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

source code of clang/lib/ARCMigrate/ARCMTActions.cpp