clang 17.0.0git
FrontendActions.h
Go to the documentation of this file.
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
20
21namespace clang {
22
23/// ExtractAPIAction sets up the output file and creates the ExtractAPIVisitor.
25protected:
26 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
27 StringRef InFile) override;
28
29private:
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
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
This file defines the APIRecord-based structs and the APISet class.
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
Abstract base class to use for AST consumer-based frontend actions.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
ExtractAPIAction sets up the output file and creates the ExtractAPIVisitor.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
A type that provides access to a new line separated list of symbol names to ignore when extracting AP...