clang 8.0.0

ARCMTActions.cpp
Go to the documentation of this file.
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
17 bool CheckAction::BeginInvocation(CompilerInstance &CI) {
18 if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
19 CI.getPCHContainerOperations(),
20 CI.getDiagnostics().getClient()))
21 return false; // errors, stop the action.
22
23 // We only want to see warnings reported from arcmt::checkForManualIssues.
24 CI.getDiagnostics().setIgnoreAllWarnings(true);
25 return true;
26 }
27
28 CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
29 : WrapperFrontendAction(std::move(WrappedAction)) {}
30
31 bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
32 return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
33 CI.getPCHContainerOperations(),
34 CI.getDiagnostics().getClient());
35 }
36
37 ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
38 : WrapperFrontendAction(std::move(WrappedAction)) {}
39
40 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
41 if (arcmt::migrateWithTemporaryFiles(
42 CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
43 CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErros,
44 PlistOut))
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;
50 }
51
52 MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
53 StringRef migrateDir,
54 StringRef plistOut,
55 bool emitPremigrationARCErrors)
56 : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
57 PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
58 if (MigrateDir.empty())
59 MigrateDir = "."; // user current directory if none is given.
60 }
clang::CompilerInstance::getInvocation
CompilerInvocation & getInvocation()
Definition: CompilerInstance.h:240
clang::DiagnosticsEngine::getClient
DiagnosticConsumer * getClient()
Definition: Diagnostic.h:510
clang::CompilerInstance::getPCHContainerOperations
std::shared_ptr< PCHContainerOperations > getPCHContainerOperations() const
Definition: CompilerInstance.h:529
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:31
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:384
std
Definition: Format.h:2072
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:237
clang::CompilerInstance
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Definition: CompilerInstance.h:73
clang::arcmt::CheckAction::CheckAction
CheckAction(std::unique_ptr< FrontendAction > WrappedAction)
Definition: ARCMTActions.cpp:28
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:392
clang::arcmt::ModifyAction::ModifyAction
ModifyAction(std::unique_ptr< FrontendAction > WrappedAction)
Definition: ARCMTActions.cpp:37
clang::DiagnosticsEngine::setIgnoreAllWarnings
void setIgnoreAllWarnings(bool Val)
When set to true, any unmapped warnings are ignored.
Definition: Diagnostic.h:588
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
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:17
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:40
clang::CompilerInstance::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
Definition: CompilerInstance.h:345
ARCMTActions.h
clang::arcmt::MigrateAction::MigrateAction
MigrateAction(std::unique_ptr< FrontendAction > WrappedAction, StringRef migrateDir, StringRef plistOut, bool emitPremigrationARCErrors)
Definition: ARCMTActions.cpp:52