clang 20.0.0git
Context.h
Go to the documentation of this file.
1//===- InstallAPI/Context.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#ifndef LLVM_CLANG_INSTALLAPI_CONTEXT_H
10#define LLVM_CLANG_INSTALLAPI_CONTEXT_H
11
17#include "llvm/ADT/DenseMap.h"
18
19namespace clang {
20namespace installapi {
22
23/// Struct used for generating validating InstallAPI.
24/// The attributes captured represent all necessary information
25/// to generate TextAPI output.
27
28 /// Library attributes that are typically passed as linker inputs.
30
31 /// Install names of reexported libraries of a library.
33
34 /// All headers that represent a library.
36
37 /// Active language mode to parse in.
39
40 /// Active header access type.
42
43 /// Active TargetSlice for symbol record collection.
44 std::shared_ptr<FrontendRecordsSlice> Slice;
45
46 /// FileManager for all I/O operations.
47 FileManager *FM = nullptr;
48
49 /// DiagnosticsEngine for all error reporting.
51
52 /// Verifier when binary dylib is passed as input.
53 std::unique_ptr<DylibVerifier> Verifier = nullptr;
54
55 /// File Path of output location.
56 llvm::StringRef OutputLoc{};
57
58 /// What encoding to write output as.
59 FileType FT = FileType::TBD_V5;
60
61 /// Populate entries of headers that should be included for TextAPI
62 /// generation.
63 void addKnownHeader(const HeaderFile &H);
64
65 /// Record visited files during frontend actions to determine whether to
66 /// include their declarations for TextAPI generation.
67 ///
68 /// \param FE Header that is being parsed.
69 /// \param PP Preprocesser used for querying how header was imported.
70 /// \return Access level of header if it should be included for TextAPI
71 /// generation.
72 std::optional<HeaderType> findAndRecordFile(const FileEntry *FE,
73 const Preprocessor &PP);
74
75private:
76 using HeaderMap = llvm::DenseMap<const FileEntry *, HeaderType>;
77
78 // Collection of parsed header files and their access level. If set to
79 // HeaderType::Unknown, they are not used for TextAPI generation.
80 HeaderMap KnownFiles;
81
82 // Collection of expected header includes and the access level for them.
83 llvm::DenseMap<StringRef, HeaderType> KnownIncludes;
84};
85
86/// Lookup the dylib or TextAPI file location for a system library or framework.
87/// The search paths provided are searched in order.
88/// @rpath based libraries are not supported.
89///
90/// \param InstallName The install name for the library.
91/// \param FrameworkSearchPaths Search paths to look up frameworks with.
92/// \param LibrarySearchPaths Search paths to look up dylibs with.
93/// \param SearchPaths Fallback search paths if library was not found in earlier
94/// paths.
95/// \return The full path of the library.
96std::string findLibrary(StringRef InstallName, FileManager &FM,
97 ArrayRef<std::string> FrameworkSearchPaths,
98 ArrayRef<std::string> LibrarySearchPaths,
99 ArrayRef<std::string> SearchPaths);
100} // namespace installapi
101} // namespace clang
102
103#endif // LLVM_CLANG_INSTALLAPI_CONTEXT_H
Defines the Diagnostic-related interfaces.
Defines the clang::FileManager interface and associated types.
llvm::MachO::FileType FileType
Definition: MachO.h:46
llvm::MachO::RecordsSlice::BinaryAttrs BinaryAttrs
Definition: MachO.h:43
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:300
Implements support for file system lookup, file system caching, and directory search management.
Definition: FileManager.h:53
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:137
The base class of the type hierarchy.
Definition: Type.h:1829
llvm::StringMap< ArchitectureSet > LibAttrs
Definition: DylibVerifier.h:28
std::vector< HeaderFile > HeaderSeq
Definition: HeaderFile.h:150
@ Unknown
Unset or unknown type.
std::string findLibrary(StringRef InstallName, FileManager &FM, ArrayRef< std::string > FrameworkSearchPaths, ArrayRef< std::string > LibrarySearchPaths, ArrayRef< std::string > SearchPaths)
Lookup the dylib or TextAPI file location for a system library or framework.
Definition: Frontend.cpp:166
The JSON file list parser is used to communicate input to InstallAPI.
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
Struct used for generating validating InstallAPI.
Definition: Context.h:26
std::optional< HeaderType > findAndRecordFile(const FileEntry *FE, const Preprocessor &PP)
Record visited files during frontend actions to determine whether to include their declarations for T...
Definition: Frontend.cpp:78
void addKnownHeader(const HeaderFile &H)
Populate entries of headers that should be included for TextAPI generation.
Definition: Frontend.cpp:109
llvm::StringRef OutputLoc
File Path of output location.
Definition: Context.h:56
FileManager * FM
FileManager for all I/O operations.
Definition: Context.h:47
LibAttrs Reexports
Install names of reexported libraries of a library.
Definition: Context.h:32
std::shared_ptr< FrontendRecordsSlice > Slice
Active TargetSlice for symbol record collection.
Definition: Context.h:44
BinaryAttrs BA
Library attributes that are typically passed as linker inputs.
Definition: Context.h:29
FileType FT
What encoding to write output as.
Definition: Context.h:59
std::unique_ptr< DylibVerifier > Verifier
Verifier when binary dylib is passed as input.
Definition: Context.h:53
DiagnosticsEngine * Diags
DiagnosticsEngine for all error reporting.
Definition: Context.h:50
Language LangMode
Active language mode to parse in.
Definition: Context.h:38
HeaderSeq InputHeaders
All headers that represent a library.
Definition: Context.h:35