• 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.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 
CheckAction(FrontendAction * WrappedAction)27 CheckAction::CheckAction(FrontendAction *WrappedAction)
28   : WrapperFrontendAction(WrappedAction) {}
29 
BeginInvocation(CompilerInstance & CI)30 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
31   return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
32                                       CI.getDiagnostics().getClient());
33 }
34 
ModifyAction(FrontendAction * WrappedAction)35 ModifyAction::ModifyAction(FrontendAction *WrappedAction)
36   : WrapperFrontendAction(WrappedAction) {}
37 
BeginInvocation(CompilerInstance & CI)38 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
39   if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(),
40                                        getCurrentInput(),
41                                        CI.getDiagnostics().getClient(),
42                                        MigrateDir,
43                                        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(FrontendAction * WrappedAction,StringRef migrateDir,StringRef plistOut,bool emitPremigrationARCErrors)52 MigrateAction::MigrateAction(FrontendAction *WrappedAction,
53                              StringRef migrateDir,
54                              StringRef plistOut,
55                              bool emitPremigrationARCErrors)
56   : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),
57     PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
58   if (MigrateDir.empty())
59     MigrateDir = "."; // user current directory if none is given.
60 }
61