Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 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 | |
Argyrios Kyrtzidis | e665d69 | 2011-06-18 00:53:41 +0000 | [diff] [blame] | 17 | bool CheckAction::BeginInvocation(CompilerInstance &CI) { |
Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 18 | if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentFile(), |
| 19 | getCurrentFileKind(), |
| 20 | CI.getDiagnostics().getClient())) |
Argyrios Kyrtzidis | e665d69 | 2011-06-18 00:53:41 +0000 | [diff] [blame] | 21 | return false; // errors, stop the action. |
Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 22 | |
| 23 | // We only want to see warnings reported from arcmt::checkForManualIssues. |
| 24 | CI.getDiagnostics().setIgnoreAllWarnings(true); |
Argyrios Kyrtzidis | e665d69 | 2011-06-18 00:53:41 +0000 | [diff] [blame] | 25 | return true; |
Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | CheckAction::CheckAction(FrontendAction *WrappedAction) |
| 29 | : WrapperFrontendAction(WrappedAction) {} |
| 30 | |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 31 | bool ModifyAction::BeginInvocation(CompilerInstance &CI) { |
| 32 | return !arcmt::applyTransformations(CI.getInvocation(), |
| 33 | getCurrentFile(), getCurrentFileKind(), |
| 34 | CI.getDiagnostics().getClient()); |
Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 37 | ModifyAction::ModifyAction(FrontendAction *WrappedAction) |
Chandler Carruth | f7f8188 | 2011-06-16 16:17:05 +0000 | [diff] [blame] | 38 | : WrapperFrontendAction(WrappedAction) {} |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 39 | |
| 40 | bool MigrateAction::BeginInvocation(CompilerInstance &CI) { |
Argyrios Kyrtzidis | 7ee2049 | 2011-07-19 17:20:03 +0000 | [diff] [blame] | 41 | if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(), |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 42 | getCurrentFile(), |
| 43 | getCurrentFileKind(), |
| 44 | CI.getDiagnostics().getClient(), |
Argyrios Kyrtzidis | 7ee2049 | 2011-07-19 17:20:03 +0000 | [diff] [blame] | 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; |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | MigrateAction::MigrateAction(FrontendAction *WrappedAction, |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 56 | StringRef migrateDir, |
| 57 | StringRef plistOut, |
Argyrios Kyrtzidis | 7ee2049 | 2011-07-19 17:20:03 +0000 | [diff] [blame] | 58 | bool emitPremigrationARCErrors) |
| 59 | : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir), |
| 60 | PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) { |
Argyrios Kyrtzidis | 69325d5 | 2011-07-09 20:00:58 +0000 | [diff] [blame] | 61 | if (MigrateDir.empty()) |
| 62 | MigrateDir = "."; // user current directory if none is given. |
| 63 | } |