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