12#include "llvm/ADT/StringRef.h"
24 llvm::MachO::RecordsSlice::addGlobal(Name,
Linkage, GV, Flags, Inlined);
25 auto Result = FrontendRecords.insert(
27 return {GR, &(
Result.first->second)};
30std::pair<ObjCInterfaceRecord *, FrontendAttrs *>
36 ObjCIFSymbolKind::Class | ObjCIFSymbolKind::MetaClass;
38 SymType |= ObjCIFSymbolKind::EHType;
41 llvm::MachO::RecordsSlice::addObjCInterface(Name,
Linkage, SymType);
42 auto Result = FrontendRecords.insert(
44 return {ObjCR, &(
Result.first->second)};
47std::pair<ObjCCategoryRecord *, FrontendAttrs *>
49 StringRef CategoryName,
53 llvm::MachO::RecordsSlice::addObjCCategory(ClassToExtend, CategoryName);
54 auto Result = FrontendRecords.insert(
56 return {ObjCR, &(
Result.first->second)};
65 if ((
Linkage == RecordLinkage::Exported) &&
67 Linkage = RecordLinkage::Internal;
69 llvm::MachO::RecordsSlice::addObjCIVar(Container, IvarName,
Linkage);
70 auto Result = FrontendRecords.insert(
73 return {ObjCR, &(
Result.first->second)};
76std::optional<HeaderType>
84 auto It = KnownFiles.find(FE);
85 if (It != KnownFiles.end()) {
96 auto BackupIt = KnownIncludes.find(IncludeName);
97 if (BackupIt != KnownIncludes.end()) {
98 KnownFiles[FE] = BackupIt->second;
99 return BackupIt->second;
123 llvm_unreachable(
"Unexpected language option.");
137 "unexpected access level for parsing");
139 raw_svector_ostream OS(Contents);
140 for (
const HeaderFile &H : Ctx.InputHeaders) {
152 OS <<
"\"" << H.
getPath() <<
"\"\n";
154 Ctx.addKnownHeader(H);
156 if (Contents.empty())
160 {
"installapi-includes-", Ctx.Slice->getTriple().str(),
"-",
162 return llvm::MemoryBuffer::getMemBufferCopy(Contents, BufferName);
170 [&](
const StringRef FullPath) -> std::optional<std::string> {
173 replace_extension(TextAPIFilePath,
".tbd");
176 return std::string(TextAPIFilePath);
179 return std::string(FullPath);
184 const StringRef
Filename = sys::path::filename(InstallName);
185 const bool IsFramework = sys::path::parent_path(InstallName)
186 .ends_with((
Filename +
".framework").str());
188 for (
const StringRef
Path : FrameworkSearchPaths) {
191 if (
auto LibOrNull = getLibrary(FullPath))
197 bool IsEmbeddedDylib = (sys::path::extension(InstallName) ==
".dylib") &&
198 InstallName.contains(
".framework/");
199 if (!IsEmbeddedDylib) {
200 for (
const StringRef
Path : LibrarySearchPaths) {
202 sys::path::append(FullPath,
Filename);
203 if (
auto LibOrNull = getLibrary(FullPath))
209 for (
const StringRef
Path : SearchPaths) {
211 sys::path::append(FullPath, InstallName);
212 if (
auto LibOrNull = getLibrary(FullPath))
llvm::MachO::ObjCIVarRecord ObjCIVarRecord
llvm::MachO::SymbolFlags SymbolFlags
llvm::MachO::ObjCCategoryRecord ObjCCategoryRecord
llvm::MachO::GlobalRecord GlobalRecord
llvm::MachO::ObjCInterfaceRecord ObjCInterfaceRecord
llvm::MachO::ObjCIFSymbolKind ObjCIFSymbolKind
llvm::MachO::RecordLinkage RecordLinkage
llvm::MachO::ObjCContainerRecord ObjCContainerRecord
Decl - This represents one declaration (or definition), e.g.
Cached information about one file (either on disk or in the virtual file system).
Implements support for file system lookup, file system caching, and directory search management.
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
HeaderSearch & getHeaderSearchInfo() const
std::pair< ObjCIVarRecord *, FrontendAttrs * > addObjCIVar(ObjCContainerRecord *Container, StringRef IvarName, RecordLinkage Linkage, const clang::AvailabilityInfo Avail, const Decl *D, HeaderType Access, const clang::ObjCIvarDecl::AccessControl AC)
Add ObjC IVar record with attributes from AST.
std::pair< GlobalRecord *, FrontendAttrs * > addGlobal(StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV, const clang::AvailabilityInfo Avail, const Decl *D, const HeaderType Access, SymbolFlags Flags=SymbolFlags::None, bool Inlined=false)
Add non-ObjC global record with attributes from AST.
std::pair< ObjCInterfaceRecord *, FrontendAttrs * > addObjCInterface(StringRef Name, RecordLinkage Linkage, const clang::AvailabilityInfo Avail, const Decl *D, HeaderType Access, bool IsEHType)
Add ObjC Class record with attributes from AST.
std::pair< ObjCCategoryRecord *, FrontendAttrs * > addObjCCategory(StringRef ClassToExtend, StringRef CategoryName, const clang::AvailabilityInfo Avail, const Decl *D, HeaderType Access)
Add ObjC Category record with attributes from AST.
The DirectoryScanner for collecting library files on the file system.
@ Unknown
Unset or unknown type.
std::unique_ptr< llvm::MemoryBuffer > createInputBuffer(InstallAPIContext &Ctx)
Create a buffer that contains all headers to scan for global symbols with.
StringRef getName(const HeaderType T)
static StringRef getFileExtension(clang::Language Lang)
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.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Language
The language for the input, used to select and validate the language standard and possible actions.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
Diagnostic wrappers for TextAPI types for error reporting.
Storage of availability attributes for a declaration.
Frontend information captured about records.
Struct used for generating validating InstallAPI.
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...
void addKnownHeader(const HeaderFile &H)
Populate entries of headers that should be included for TextAPI generation.
FileManager * FM
FileManager for all I/O operations.