|
|
|||
File indexing completed on 2026-05-10 08:36:54
0001 //===- ExtractAPI/FrontendActions.h -----------------------------*- 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 /// \file 0010 /// This file defines the ExtractAPIAction and WrappingExtractAPIAction frontend 0011 /// actions. 0012 /// 0013 //===----------------------------------------------------------------------===// 0014 0015 #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H 0016 #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H 0017 0018 #include "clang/ExtractAPI/ExtractAPIActionBase.h" 0019 #include "clang/Frontend/FrontendAction.h" 0020 0021 namespace clang { 0022 0023 /// ExtractAPIAction sets up the output file and creates the ExtractAPIVisitor. 0024 class ExtractAPIAction : public ASTFrontendAction, 0025 private ExtractAPIActionBase { 0026 protected: 0027 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, 0028 StringRef InFile) override; 0029 0030 private: 0031 0032 /// The input file originally provided on the command line. 0033 /// 0034 /// This captures the spelling used to include the file and whether the 0035 /// include is quoted or not. 0036 SmallVector<std::pair<SmallString<32>, bool>> KnownInputFiles; 0037 0038 /// Prepare to execute the action on the given CompilerInstance. 0039 /// 0040 /// This is called before executing the action on any inputs. This generates a 0041 /// single header that includes all of CI's inputs and replaces CI's input 0042 /// list with it before actually executing the action. 0043 bool PrepareToExecuteAction(CompilerInstance &CI) override; 0044 0045 /// Called after executing the action on the synthesized input buffer. 0046 /// 0047 /// Note: Now that we have gathered all the API definitions to surface we can 0048 /// emit them in this callback. 0049 void EndSourceFileAction() override; 0050 0051 static StringRef getInputBufferName() { return "<extract-api-includes>"; } 0052 }; 0053 0054 /// Wrap ExtractAPIAction on top of a pre-existing action 0055 /// 0056 /// Used when the ExtractAPI action needs to be executed as a side effect of a 0057 /// regular compilation job. Unlike ExtarctAPIAction, this is meant to be used 0058 /// on regular source files ( .m , .c files) instead of header files 0059 class WrappingExtractAPIAction : public WrapperFrontendAction, 0060 private ExtractAPIActionBase { 0061 public: 0062 WrappingExtractAPIAction(std::unique_ptr<FrontendAction> WrappedAction) 0063 : WrapperFrontendAction(std::move(WrappedAction)) {} 0064 0065 protected: 0066 /// Create ExtractAPI consumer multiplexed on another consumer. 0067 /// 0068 /// This allows us to execute ExtractAPI action while on top of 0069 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, 0070 StringRef InFile) override; 0071 0072 private: 0073 /// Flag to check if the wrapper front end action's consumer is 0074 /// craeted or not 0075 bool CreatedASTConsumer = false; 0076 0077 void EndSourceFile() override { FrontendAction::EndSourceFile(); } 0078 0079 /// Called after executing the action on the synthesized input buffer. 0080 /// 0081 /// Executes both Wrapper and ExtractAPIBase end source file 0082 /// actions. This is the place where all the gathered symbol graph 0083 /// information is emited. 0084 void EndSourceFileAction() override; 0085 }; 0086 0087 } // namespace clang 0088 0089 #endif // LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|