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(), getCurrentFile(),
19 getCurrentFileKind(),
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(FrontendAction * WrappedAction)28 CheckAction::CheckAction(FrontendAction *WrappedAction)
29 : WrapperFrontendAction(WrappedAction) {}
30
BeginInvocation(CompilerInstance & CI)31 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
32 return !arcmt::applyTransformations(CI.getInvocation(),
33 getCurrentFile(), getCurrentFileKind(),
34 CI.getDiagnostics().getClient());
35 }
36
ModifyAction(FrontendAction * WrappedAction)37 ModifyAction::ModifyAction(FrontendAction *WrappedAction)
38 : WrapperFrontendAction(WrappedAction) {}
39
BeginInvocation(CompilerInstance & CI)40 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
41 if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(),
42 getCurrentFile(),
43 getCurrentFileKind(),
44 CI.getDiagnostics().getClient(),
45 MigrateDir,
46 EmitPremigrationARCErros,
47 PlistOut))
48 return false; // errors, stop the action.
49
50 // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
51 CI.getDiagnostics().setIgnoreAllWarnings(true);
52 return true;
53 }
54
MigrateAction(FrontendAction * WrappedAction,llvm::StringRef migrateDir,llvm::StringRef plistOut,bool emitPremigrationARCErrors)55 MigrateAction::MigrateAction(FrontendAction *WrappedAction,
56 llvm::StringRef migrateDir,
57 llvm::StringRef plistOut,
58 bool emitPremigrationARCErrors)
59 : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),
60 PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
61 if (MigrateDir.empty())
62 MigrateDir = "."; // user current directory if none is given.
63 }
64