clang API Documentation

ARCMTActions.cpp
Go to the documentation of this file.
00001 //===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "clang/ARCMigrate/ARCMTActions.h"
00011 #include "clang/ARCMigrate/ARCMT.h"
00012 #include "clang/Frontend/CompilerInstance.h"
00013 
00014 using namespace clang;
00015 using namespace arcmt;
00016 
00017 bool CheckAction::BeginInvocation(CompilerInstance &CI) {
00018   if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
00019                                   CI.getDiagnostics().getClient()))
00020     return false; // errors, stop the action.
00021 
00022   // We only want to see warnings reported from arcmt::checkForManualIssues.
00023   CI.getDiagnostics().setIgnoreAllWarnings(true);
00024   return true;
00025 }
00026 
00027 CheckAction::CheckAction(FrontendAction *WrappedAction)
00028   : WrapperFrontendAction(WrappedAction) {}
00029 
00030 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
00031   return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
00032                                       CI.getDiagnostics().getClient());
00033 }
00034 
00035 ModifyAction::ModifyAction(FrontendAction *WrappedAction)
00036   : WrapperFrontendAction(WrappedAction) {}
00037 
00038 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
00039   if (arcmt::migrateWithTemporaryFiles(CI.getInvocation(),
00040                                        getCurrentInput(),
00041                                        CI.getDiagnostics().getClient(),
00042                                        MigrateDir,
00043                                        EmitPremigrationARCErros,
00044                                        PlistOut))
00045     return false; // errors, stop the action.
00046 
00047   // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
00048   CI.getDiagnostics().setIgnoreAllWarnings(true);
00049   return true;
00050 }
00051 
00052 MigrateAction::MigrateAction(FrontendAction *WrappedAction,
00053                              StringRef migrateDir,
00054                              StringRef plistOut,
00055                              bool emitPremigrationARCErrors)
00056   : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),
00057     PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
00058   if (MigrateDir.empty())
00059     MigrateDir = "."; // user current directory if none is given.
00060 }