clang 10.0.0git

ARCMTActions.cpp
Go to the documentation of this file.
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
9 #include "clang/ARCMigrate/ARCMTActions.h"
10 #include "clang/ARCMigrate/ARCMT.h"
11 #include "clang/Frontend/CompilerInstance.h"
12
13 using namespace clang;
14 using namespace arcmt;
15
16 bool CheckAction::BeginInvocation(CompilerInstance &CI) {
17 if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
18 CI.getPCHContainerOperations(),
19 CI.getDiagnostics().getClient()))
20 return false; // errors, stop the action.
21
22 // We only want to see warnings reported from arcmt::checkForManualIssues.
23 CI.getDiagnostics().setIgnoreAllWarnings(true);
24 return true;
25 }
26
27 CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
28 : WrapperFrontendAction(std::move(WrappedAction)) {}
29
30 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
31 return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
32 CI.getPCHContainerOperations(),
33 CI.getDiagnostics().getClient());
34 }
35
36 ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
37 : WrapperFrontendAction(std::move(WrappedAction)) {}
38
39 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
40 if (arcmt::migrateWithTemporaryFiles(
41 CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
42 CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErros,
43 PlistOut))
44 return false; // errors, stop the action.
45
46 // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
47 CI.getDiagnostics().setIgnoreAllWarnings(true);
48 return true;
49 }
50
51 MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
52 StringRef migrateDir,
53 StringRef plistOut,
54 bool emitPremigrationARCErrors)
55 : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
56 PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
57 if (MigrateDir.empty())
58 MigrateDir = "."; // user current directory if none is given.
59 }
clang::CompilerInstance::getInvocation
CompilerInvocation & getInvocation()
Definition: CompilerInstance.h:232
clang::DiagnosticsEngine::getClient
DiagnosticConsumer * getClient()
Definition: Diagnostic.h:516
clang::CompilerInstance::getPCHContainerOperations
std::shared_ptr< PCHContainerOperations > getPCHContainerOperations() const
Definition: CompilerInstance.h:524
clang::arcmt::ModifyAction::BeginInvocation
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: ARCMTActions.cpp:30
clang::arcmt::applyTransformations
bool applyTransformations(CompilerInvocation &origCI, const FrontendInputFile &Input, std::shared_ptr< PCHContainerOperations > PCHContainerOps, DiagnosticConsumer *DiagClient)
Works similar to checkForManualIssues but instead of checking, it applies automatic modifications to ...
Definition: ARCMT.cpp:383
std
Definition: Format.h:2445
ARCMT.h
CompilerInstance.h
clang::arcmt::checkForManualIssues
bool checkForManualIssues(CompilerInvocation &CI, const FrontendInputFile &Input, std::shared_ptr< PCHContainerOperations > PCHContainerOps, DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors=false, StringRef plistOut=StringRef())
Creates an AST with the provided CompilerInvocation but with these changes: -if a PCH/PTH is set...
Definition: ARCMT.cpp:236
clang::CompilerInstance
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Definition: CompilerInstance.h:72
clang::arcmt::CheckAction::CheckAction
CheckAction(std::unique_ptr< FrontendAction > WrappedAction)
Definition: ARCMTActions.cpp:27
clang::arcmt::migrateWithTemporaryFiles
bool migrateWithTemporaryFiles(CompilerInvocation &origCI, const FrontendInputFile &Input, std::shared_ptr< PCHContainerOperations > PCHContainerOps, DiagnosticConsumer *DiagClient, StringRef outputDir, bool emitPremigrationARCErrors, StringRef plistOut)
Applies automatic modifications and produces temporary files and metadata into the outputDir path...
Definition: ARCMT.cpp:391
clang::arcmt::ModifyAction::ModifyAction
ModifyAction(std::unique_ptr< FrontendAction > WrappedAction)
Definition: ARCMTActions.cpp:36
clang::DiagnosticsEngine::setIgnoreAllWarnings
void setIgnoreAllWarnings(bool Val)
When set to true, any unmapped warnings are ignored.
Definition: Diagnostic.h:594
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::FrontendAction::getCurrentInput
const FrontendInputFile & getCurrentInput() const
Definition: FrontendAction.h:135
clang::WrapperFrontendAction
A frontend action which simply wraps some other runtime-specified frontend action.
Definition: FrontendAction.h:304
clang::arcmt::CheckAction::BeginInvocation
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: ARCMTActions.cpp:16
clang::arcmt::MigrateAction::BeginInvocation
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: ARCMTActions.cpp:39
clang::CompilerInstance::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
Definition: CompilerInstance.h:337
ARCMTActions.h
clang::arcmt::MigrateAction::MigrateAction
MigrateAction(std::unique_ptr< FrontendAction > WrappedAction, StringRef migrateDir, StringRef plistOut, bool emitPremigrationARCErrors)
Definition: ARCMTActions.cpp:51