1 //===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
11 #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
13 #include "clang/Frontend/FrontendAction.h"
14 #include "llvm/Support/raw_ostream.h"
20 //===----------------------------------------------------------------------===//
21 // AST Consumer Actions
22 //===----------------------------------------------------------------------===//
24 class HTMLPrintAction : public ASTFrontendAction {
26 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
27 StringRef InFile) override;
30 class FixItAction : public ASTFrontendAction {
32 std::unique_ptr<FixItRewriter> Rewriter;
33 std::unique_ptr<FixItOptions> FixItOpts;
35 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
36 StringRef InFile) override;
38 bool BeginSourceFileAction(CompilerInstance &CI) override;
40 void EndSourceFileAction() override;
42 bool hasASTFileSupport() const override { return false; }
46 ~FixItAction() override;
49 /// \brief Emits changes to temporary files and uses them for the original
51 class FixItRecompile : public WrapperFrontendAction {
53 FixItRecompile(std::unique_ptr<FrontendAction> WrappedAction)
54 : WrapperFrontendAction(std::move(WrappedAction)) {}
57 bool BeginInvocation(CompilerInstance &CI) override;
60 class RewriteObjCAction : public ASTFrontendAction {
62 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
63 StringRef InFile) override;
66 class RewriteMacrosAction : public PreprocessorFrontendAction {
68 void ExecuteAction() override;
71 class RewriteTestAction : public PreprocessorFrontendAction {
73 void ExecuteAction() override;
76 class RewriteIncludesAction : public PreprocessorFrontendAction {
77 std::shared_ptr<raw_ostream> OutputStream;
78 class RewriteImportsListener;
80 bool BeginSourceFileAction(CompilerInstance &CI) override;
81 void ExecuteAction() override;
84 } // end namespace clang