clang  14.0.0git
FrontendActions.h
Go to the documentation of this file.
1 //===-- FrontendActions.h - Useful 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 #ifndef LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
10 #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
11 
13 #include "llvm/Support/raw_ostream.h"
14 
15 namespace clang {
16 class FixItRewriter;
17 class FixItOptions;
18 
19 //===----------------------------------------------------------------------===//
20 // AST Consumer Actions
21 //===----------------------------------------------------------------------===//
22 
24 protected:
25  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
26  StringRef InFile) override;
27 };
28 
30 protected:
31  std::unique_ptr<FixItRewriter> Rewriter;
32  std::unique_ptr<FixItOptions> FixItOpts;
33 
34  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
35  StringRef InFile) override;
36 
37  bool BeginSourceFileAction(CompilerInstance &CI) override;
38 
39  void EndSourceFileAction() override;
40 
41  bool hasASTFileSupport() const override { return false; }
42 
43 public:
44  FixItAction();
45  ~FixItAction() override;
46 };
47 
48 /// Emits changes to temporary files and uses them for the original
49 /// frontend action.
51 public:
52  FixItRecompile(std::unique_ptr<FrontendAction> WrappedAction)
54 
55 protected:
56  bool BeginInvocation(CompilerInstance &CI) override;
57 };
58 
60 protected:
61  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
62  StringRef InFile) override;
63 };
64 
66 protected:
67  void ExecuteAction() override;
68 };
69 
71 protected:
72  void ExecuteAction() override;
73 };
74 
76  std::shared_ptr<raw_ostream> OutputStream;
78 protected:
79  bool BeginSourceFileAction(CompilerInstance &CI) override;
80  void ExecuteAction() override;
81 };
82 
83 } // end namespace clang
84 
85 #endif
clang::FixItRecompile
Emits changes to temporary files and uses them for the original frontend action.
Definition: FrontendActions.h:50
clang::RewriteTestAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:194
clang::PreprocessorFrontendAction
Abstract base class to use for preprocessor-based frontend actions.
Definition: FrontendAction.h:287
clang::FixItAction::FixItAction
FixItAction()
Definition: FrontendActions.cpp:48
clang::RewriteIncludesAction
Definition: FrontendActions.h:75
FrontendAction.h
clang::FixItRecompile::FixItRecompile
FixItRecompile(std::unique_ptr< FrontendAction > WrappedAction)
Definition: FrontendActions.h:52
clang::RewriteMacrosAction
Definition: FrontendActions.h:65
clang::RewriteIncludesAction::BeginSourceFileAction
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
Definition: FrontendActions.cpp:270
clang::FixItAction::hasASTFileSupport
bool hasASTFileSupport() const override
Does this action support use with AST files?
Definition: FrontendActions.h:41
clang::CompilerInstance
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Definition: CompilerInstance.h:74
clang::HTMLPrintAction
Definition: FrontendActions.h:23
clang::RewriteIncludesAction::RewriteImportsListener
Definition: FrontendActions.cpp:203
clang::FixItAction::BeginSourceFileAction
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
Definition: FrontendActions.cpp:96
clang::RewriteTestAction
Definition: FrontendActions.h:70
clang::RewriteObjCAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:164
clang::HTMLPrintAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:41
clang::FixItAction::~FixItAction
~FixItAction() override
Definition: FrontendActions.cpp:49
clang::FixItAction::CreateASTConsumer
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Definition: FrontendActions.cpp:52
clang::FixItAction::FixItOpts
std::unique_ptr< FixItOptions > FixItOpts
Definition: FrontendActions.h:32
clang::FixItAction::Rewriter
std::unique_ptr< FixItRewriter > Rewriter
Definition: FrontendActions.h:31
std
Definition: Format.h:4034
clang::RewriteIncludesAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:304
clang
Definition: CalledOnceCheck.h:17
clang::RewriteMacrosAction::ExecuteAction
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Definition: FrontendActions.cpp:185
clang::WrapperFrontendAction::WrappedAction
std::unique_ptr< FrontendAction > WrappedAction
Definition: FrontendAction.h:306
clang::FixItRecompile::BeginInvocation
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Definition: FrontendActions.cpp:115
clang::FixItAction::EndSourceFileAction
void EndSourceFileAction() override
Callback at the end of processing a single input.
Definition: FrontendActions.cpp:110
clang::ASTFrontendAction
Abstract base class to use for AST consumer-based frontend actions.
Definition: FrontendAction.h:243
clang::FixItAction
Definition: FrontendActions.h:29
clang::WrapperFrontendAction
A frontend action which simply wraps some other runtime-specified frontend action.
Definition: FrontendAction.h:304
clang::RewriteObjCAction
Definition: FrontendActions.h:59