ARCMTActions.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "clang/ARCMigrate/ARCMTActions.h"
  9. #include "clang/ARCMigrate/ARCMT.h"
  10. #include "clang/Frontend/CompilerInstance.h"
  11. using namespace clang;
  12. using namespace arcmt;
  13. bool CheckAction::BeginInvocation(CompilerInstance &CI) {
  14. if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
  15. CI.getPCHContainerOperations(),
  16. CI.getDiagnostics().getClient()))
  17. return false; // errors, stop the action.
  18. // We only want to see warnings reported from arcmt::checkForManualIssues.
  19. CI.getDiagnostics().setIgnoreAllWarnings(true);
  20. return true;
  21. }
  22. CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
  23. : WrapperFrontendAction(std::move(WrappedAction)) {}
  24. bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
  25. return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
  26. CI.getPCHContainerOperations(),
  27. CI.getDiagnostics().getClient());
  28. }
  29. ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
  30. : WrapperFrontendAction(std::move(WrappedAction)) {}
  31. bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
  32. if (arcmt::migrateWithTemporaryFiles(
  33. CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
  34. CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErrors,
  35. PlistOut))
  36. return false; // errors, stop the action.
  37. // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
  38. CI.getDiagnostics().setIgnoreAllWarnings(true);
  39. return true;
  40. }
  41. MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
  42. StringRef migrateDir,
  43. StringRef plistOut,
  44. bool emitPremigrationARCErrors)
  45. : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
  46. PlistOut(plistOut), EmitPremigrationARCErrors(emitPremigrationARCErrors) {
  47. if (MigrateDir.empty())
  48. MigrateDir = "."; // user current directory if none is given.
  49. }