Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:59

0001 //===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
0010 #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
0011 
0012 #include "clang/Frontend/FrontendAction.h"
0013 #include "llvm/Support/raw_ostream.h"
0014 
0015 namespace clang {
0016 class FixItRewriter;
0017 class FixItOptions;
0018 
0019 //===----------------------------------------------------------------------===//
0020 // AST Consumer Actions
0021 //===----------------------------------------------------------------------===//
0022 
0023 class HTMLPrintAction : public ASTFrontendAction {
0024 protected:
0025   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
0026                                                  StringRef InFile) override;
0027 };
0028 
0029 class FixItAction : public ASTFrontendAction {
0030 protected:
0031   std::unique_ptr<FixItRewriter> Rewriter;
0032   std::unique_ptr<FixItOptions> FixItOpts;
0033 
0034   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
0035                                                  StringRef InFile) override;
0036 
0037   bool BeginSourceFileAction(CompilerInstance &CI) override;
0038 
0039   void EndSourceFileAction() override;
0040 
0041   bool hasASTFileSupport() const override { return false; }
0042 
0043 public:
0044   FixItAction();
0045   ~FixItAction() override;
0046 };
0047 
0048 /// Emits changes to temporary files and uses them for the original
0049 /// frontend action.
0050 class FixItRecompile : public WrapperFrontendAction {
0051 public:
0052   FixItRecompile(std::unique_ptr<FrontendAction> WrappedAction)
0053     : WrapperFrontendAction(std::move(WrappedAction)) {}
0054 
0055 protected:
0056   bool BeginInvocation(CompilerInstance &CI) override;
0057 };
0058 
0059 class RewriteObjCAction : public ASTFrontendAction {
0060 protected:
0061   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
0062                                                  StringRef InFile) override;
0063 };
0064 
0065 class RewriteMacrosAction : public PreprocessorFrontendAction {
0066 protected:
0067   void ExecuteAction() override;
0068 };
0069 
0070 class RewriteTestAction : public PreprocessorFrontendAction {
0071 protected:
0072   void ExecuteAction() override;
0073 };
0074 
0075 class RewriteIncludesAction : public PreprocessorFrontendAction {
0076   std::shared_ptr<raw_ostream> OutputStream;
0077   class RewriteImportsListener;
0078 protected:
0079   bool BeginSourceFileAction(CompilerInstance &CI) override;
0080   void ExecuteAction() override;
0081 };
0082 
0083 }  // end namespace clang
0084 
0085 #endif