12 #include "llvm/ADT/SmallString.h"
13 #include "llvm/ADT/StringRef.h"
19 std::pair<GlobalRecord *, FrontendAttrs *> FrontendRecordsSlice::addGlobal(
25 llvm::MachO::RecordsSlice::addGlobal(Name,
Linkage, GV, Flags, Inlined);
26 auto Result = FrontendRecords.insert(
28 return {GR, &(Result.first->second)};
31 std::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)};
48 std::pair<ObjCCategoryRecord *, FrontendAttrs *>
49 FrontendRecordsSlice::addObjCCategory(StringRef ClassToExtend,
50 StringRef CategoryName,
54 llvm::MachO::RecordsSlice::addObjCCategory(ClassToExtend, CategoryName);
55 auto Result = FrontendRecords.insert(
57 return {ObjCR, &(Result.first->second)};
60 std::pair<ObjCIVarRecord *, FrontendAttrs *> FrontendRecordsSlice::addObjCIVar(
66 if ((
Linkage == RecordLinkage::Exported) &&
67 ((AC == ObjCIvarDecl::Private) || (AC == ObjCIvarDecl::Package)))
68 Linkage = RecordLinkage::Internal;
70 llvm::MachO::RecordsSlice::addObjCIVar(Container, IvarName,
Linkage);
71 auto Result = FrontendRecords.insert(
74 return {ObjCR, &(Result.first->second)};
77 std::optional<HeaderType>
78 InstallAPIContext::findAndRecordFile(
const FileEntry *FE,
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;
109 void InstallAPIContext::addKnownHeader(
const HeaderFile &H) {
110 auto FE = FM->getFile(H.
getPath());
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
static std::string getName(const CallEvent &Call)
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
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
Representations of a library's headers for InstallAPI.
std::unique_ptr< llvm::MemoryBuffer > createInputBuffer(InstallAPIContext &Ctx)
Create a buffer that contains all headers to scan for global symbols with.
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.
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.
void addKnownHeader(const HeaderFile &H)
Populate entries of headers that should be included for TextAPI generation.
HeaderType Type
Active header access type.
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.