Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- ExtractAPI/FrontendActions.h -----------------------------*- 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 | /// \file |
||
10 | /// This file defines the ExtractAPIAction frontend action. |
||
11 | /// |
||
12 | //===----------------------------------------------------------------------===// |
||
13 | |||
14 | #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H |
||
15 | #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H |
||
16 | |||
17 | #include "clang/ExtractAPI/API.h" |
||
18 | #include "clang/ExtractAPI/APIIgnoresList.h" |
||
19 | #include "clang/Frontend/FrontendAction.h" |
||
20 | |||
21 | namespace clang { |
||
22 | |||
23 | /// ExtractAPIAction sets up the output file and creates the ExtractAPIVisitor. |
||
24 | class ExtractAPIAction : public ASTFrontendAction { |
||
25 | protected: |
||
26 | std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, |
||
27 | StringRef InFile) override; |
||
28 | |||
29 | private: |
||
30 | /// A representation of the APIs this action extracts. |
||
31 | std::unique_ptr<extractapi::APISet> API; |
||
32 | |||
33 | /// A stream to the output file of this action. |
||
34 | std::unique_ptr<raw_pwrite_stream> OS; |
||
35 | |||
36 | /// The product this action is extracting API information for. |
||
37 | std::string ProductName; |
||
38 | |||
39 | /// The synthesized input buffer that contains all the provided input header |
||
40 | /// files. |
||
41 | std::unique_ptr<llvm::MemoryBuffer> Buffer; |
||
42 | |||
43 | /// The list of symbols to ignore during serialization |
||
44 | extractapi::APIIgnoresList IgnoresList; |
||
45 | |||
46 | /// The input file originally provided on the command line. |
||
47 | /// |
||
48 | /// This captures the spelling used to include the file and whether the |
||
49 | /// include is quoted or not. |
||
50 | SmallVector<std::pair<SmallString<32>, bool>> KnownInputFiles; |
||
51 | |||
52 | /// Prepare to execute the action on the given CompilerInstance. |
||
53 | /// |
||
54 | /// This is called before executing the action on any inputs. This generates a |
||
55 | /// single header that includes all of CI's inputs and replaces CI's input |
||
56 | /// list with it before actually executing the action. |
||
57 | bool PrepareToExecuteAction(CompilerInstance &CI) override; |
||
58 | |||
59 | /// Called after executing the action on the synthesized input buffer. |
||
60 | /// |
||
61 | /// Note: Now that we have gathered all the API definitions to surface we can |
||
62 | /// emit them in this callback. |
||
63 | void EndSourceFileAction() override; |
||
64 | |||
65 | static std::unique_ptr<llvm::raw_pwrite_stream> |
||
66 | CreateOutputFile(CompilerInstance &CI, StringRef InFile); |
||
67 | |||
68 | static StringRef getInputBufferName() { return "<extract-api-includes>"; } |
||
69 | }; |
||
70 | |||
71 | } // namespace clang |
||
72 | |||
73 | #endif // LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H |