1//===-- The main header generation class ------------------------*- 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#ifndef LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H
10#define LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H
11
12#include "Command.h"
13
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/ADT/StringRef.h"
16
17#include <memory>
18#include <string>
19#include <unordered_map>
20
21namespace llvm {
22
23class raw_ostream;
24class RecordKeeper;
25
26} // namespace llvm
27
28namespace llvm_libc {
29
30class Command;
31
32class Generator {
33 llvm::StringRef HeaderDefFile;
34 const std::vector<std::string> &EntrypointNameList;
35 llvm::StringRef StdHeader;
36 std::unordered_map<std::string, std::string> &ArgMap;
37
38 std::unique_ptr<Command> IncludeFileCmd;
39 std::unique_ptr<Command> PublicAPICmd;
40
41 Command *getCommandHandler(llvm::StringRef CommandName);
42
43 void parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args);
44
45 void printError(llvm::StringRef Msg);
46
47public:
48 Generator(const std::string &DefFile, const std::vector<std::string> &EN,
49 const std::string &Header,
50 std::unordered_map<std::string, std::string> &Map)
51 : HeaderDefFile(DefFile), EntrypointNameList(EN), StdHeader(Header),
52 ArgMap(Map) {}
53
54 void generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records);
55 void generateDecls(llvm::raw_ostream &OS, llvm::RecordKeeper &Records);
56};
57
58} // namespace llvm_libc
59
60#endif // LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H
61

source code of libc/utils/HdrGen/Generator.h