• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- 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 
14 using namespace clang;
15 using namespace arcmt;
16 
BeginInvocation(CompilerInstance & CI)17 bool CheckAction::BeginInvocation(CompilerInstance &CI) {
18   if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
19                                   CI.getPCHContainerOperations(),
20                                   CI.getDiagnostics().getClient()))
21     return false; // errors, stop the action.
22 
23   // We only want to see warnings reported from arcmt::checkForManualIssues.
24   CI.getDiagnostics().setIgnoreAllWarnings(true);
25   return true;
26 }
27 
CheckAction(std::unique_ptr<FrontendAction> WrappedAction)28 CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
29   : WrapperFrontendAction(std::move(WrappedAction)) {}
30 
BeginInvocation(CompilerInstance & CI)31 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
32   return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
33                                       CI.getPCHContainerOperations(),
34                                       CI.getDiagnostics().getClient());
35 }
36 
ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)37 ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
38   : WrapperFrontendAction(std::move(WrappedAction)) {}
39 
BeginInvocation(CompilerInstance & CI)40 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
41   if (arcmt::migrateWithTemporaryFiles(
42           CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
43           CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErros,
44           PlistOut))
45     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;
50 }
51 
MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,StringRef migrateDir,StringRef plistOut,bool emitPremigrationARCErrors)52 MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
53                              StringRef migrateDir,
54                              StringRef plistOut,
55                              bool emitPremigrationARCErrors)
56   : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
57     PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
58   if (MigrateDir.empty())
59     MigrateDir = "."; // user current directory if none is given.
60 }
61