12#include "llvm/ADT/SmallString.h"
13#include "llvm/ADT/StringRef.h"
25 llvm::MachO::RecordsSlice::addGlobal(Name,
Linkage, GV, Flags, Inlined);
26 auto Result = FrontendRecords.insert(
28 return {GR, &(
Result.first->second)};
31std::pair<ObjCInterfaceRecord *, FrontendAttrs *>
37 ObjCIFSymbolKind::Class | ObjCIFSymbolKind::MetaClass;
39 SymType |= ObjCIFSymbolKind::EHType;
42 llvm::MachO::RecordsSlice::addObjCInterface(Name,
Linkage, SymType);
43 auto Result = FrontendRecords.insert(
45 return {ObjCR, &(
Result.first->second)};
48std::pair<ObjCCategoryRecord *, FrontendAttrs *>
50 StringRef CategoryName,
54 llvm::MachO::RecordsSlice::addObjCCategory(ClassToExtend, CategoryName);
55 auto Result = FrontendRecords.insert(
57 return {ObjCR, &(
Result.first->second)};
66 if ((
Linkage == RecordLinkage::Exported) &&
68 Linkage = RecordLinkage::Internal;
70 llvm::MachO::RecordsSlice::addObjCIVar(Container, IvarName,
Linkage);
71 auto Result = FrontendRecords.insert(
74 return {ObjCR, &(
Result.first->second)};
77std::optional<HeaderType>
85 auto It = KnownFiles.find(FE);
86 if (It != KnownFiles.end()) {
97 auto BackupIt = KnownIncludes.find(IncludeName.str());
98 if (BackupIt != KnownIncludes.end()) {
99 KnownFiles[FE] = BackupIt->second;
100 return BackupIt->second;
124 llvm_unreachable(
"Unexpected language option.");
138 "unexpected access level for parsing");
140 raw_svector_ostream OS(Contents);
153 OS <<
"\"" << H.
getPath() <<
"\"\n";
157 if (Contents.empty())
161 {
"installapi-includes-", Ctx.
Slice->getTriple().str(),
"-",
163 return llvm::MemoryBuffer::getMemBufferCopy(Contents, BufferName);
171 [&](
const StringRef FullPath) -> std::optional<std::string> {
174 replace_extension(TextAPIFilePath,
".tbd");
177 return std::string(TextAPIFilePath);
180 return std::string(FullPath);
185 const StringRef
Filename = sys::path::filename(InstallName);
186 const bool IsFramework = sys::path::parent_path(InstallName)
187 .ends_with((
Filename +
".framework").str());
189 for (
const StringRef
Path : FrameworkSearchPaths) {
192 if (
auto LibOrNull = getLibrary(FullPath))
198 bool IsEmbeddedDylib = (sys::path::extension(InstallName) ==
".dylib") &&
199 InstallName.contains(
".framework/");
200 if (!IsEmbeddedDylib) {
201 for (
const StringRef
Path : LibrarySearchPaths) {
203 sys::path::append(FullPath,
Filename);
204 if (
auto LibOrNull = getLibrary(FullPath))
210 for (
const StringRef
Path : SearchPaths) {
212 sys::path::append(FullPath, InstallName);
213 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.
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
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.
HeaderType Type
Active header access type.
FileManager * FM
FileManager for all I/O operations.
std::shared_ptr< FrontendRecordsSlice > Slice
Active TargetSlice for symbol record collection.
Language LangMode
Active language mode to parse in.
HeaderSeq InputHeaders
All headers that represent a library.