clang API Documentation
00001 //===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H 00011 #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H 00012 00013 #include "clang/Frontend/FrontendAction.h" 00014 00015 namespace clang { 00016 class FixItRewriter; 00017 class FixItOptions; 00018 00019 //===----------------------------------------------------------------------===// 00020 // AST Consumer Actions 00021 //===----------------------------------------------------------------------===// 00022 00023 class HTMLPrintAction : public ASTFrontendAction { 00024 protected: 00025 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, 00026 StringRef InFile) override; 00027 }; 00028 00029 class FixItAction : public ASTFrontendAction { 00030 protected: 00031 std::unique_ptr<FixItRewriter> Rewriter; 00032 std::unique_ptr<FixItOptions> FixItOpts; 00033 00034 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, 00035 StringRef InFile) override; 00036 00037 bool BeginSourceFileAction(CompilerInstance &CI, 00038 StringRef Filename) override; 00039 00040 void EndSourceFileAction() override; 00041 00042 bool hasASTFileSupport() const override { return false; } 00043 00044 public: 00045 FixItAction(); 00046 ~FixItAction(); 00047 }; 00048 00049 /// \brief Emits changes to temporary files and uses them for the original 00050 /// frontend action. 00051 class FixItRecompile : public WrapperFrontendAction { 00052 public: 00053 FixItRecompile(FrontendAction *WrappedAction) 00054 : WrapperFrontendAction(WrappedAction) {} 00055 00056 protected: 00057 bool BeginInvocation(CompilerInstance &CI) override; 00058 }; 00059 00060 class RewriteObjCAction : public ASTFrontendAction { 00061 protected: 00062 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, 00063 StringRef InFile) override; 00064 }; 00065 00066 class RewriteMacrosAction : public PreprocessorFrontendAction { 00067 protected: 00068 void ExecuteAction() override; 00069 }; 00070 00071 class RewriteTestAction : public PreprocessorFrontendAction { 00072 protected: 00073 void ExecuteAction() override; 00074 }; 00075 00076 class RewriteIncludesAction : public PreprocessorFrontendAction { 00077 protected: 00078 void ExecuteAction() override; 00079 }; 00080 00081 } // end namespace clang 00082 00083 #endif