diff options
author | Zixu Wang <zixu_wang@apple.com> | 2022-03-24 18:19:30 -0700 |
---|---|---|
committer | Zixu Wang <zixu_wang@apple.com> | 2022-03-29 14:29:39 -0700 |
commit | 9b36e126fdb1da4d7e255e089ef225dfb130ef63 (patch) | |
tree | 1b7b71ed8d09993adad441b97bb918d16bbb75b0 /clang/lib/ExtractAPI/API.cpp | |
parent | 686dcbe8b018759b5443c05bfeeb7abf4d9cf09c (diff) | |
download | llvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.zip llvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.tar.gz llvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.tar.bz2 |
[clang][extract-api] Add Objective-C interface support
Add support for Objective-C interface declarations in ExtractAPI.
Depends on D122495
Differential Revision: https://reviews.llvm.org/D122446
Diffstat (limited to 'clang/lib/ExtractAPI/API.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/API.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp index 92c4e0e..2456022 100644 --- a/clang/lib/ExtractAPI/API.cpp +++ b/clang/lib/ExtractAPI/API.cpp @@ -109,6 +109,58 @@ StructRecord *APISet::addStruct(StringRef Name, StringRef USR, PresumedLoc Loc, return Result.first->second.get(); } +ObjCInterfaceRecord *APISet::addObjCInterface( + StringRef Name, StringRef USR, PresumedLoc Loc, + const AvailabilityInfo &Availability, LinkageInfo Linkage, + const DocComment &Comment, DeclarationFragments Declaration, + DeclarationFragments SubHeading, SymbolReference SuperClass) { + auto Result = ObjCInterfaces.insert({Name, nullptr}); + if (Result.second) { + // Create the record if it does not already exist. + auto Record = std::make_unique<ObjCInterfaceRecord>( + Name, USR, Loc, Availability, Linkage, Comment, Declaration, SubHeading, + SuperClass); + Result.first->second = std::move(Record); + } + return Result.first->second.get(); +} + +ObjCMethodRecord *APISet::addObjCMethod( + ObjCContainerRecord *Container, StringRef Name, StringRef USR, + PresumedLoc Loc, const AvailabilityInfo &Availability, + const DocComment &Comment, DeclarationFragments Declaration, + DeclarationFragments SubHeading, FunctionSignature Signature, + bool IsInstanceMethod) { + auto Record = std::make_unique<ObjCMethodRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading, Signature, + IsInstanceMethod); + return Container->Methods.emplace_back(std::move(Record)).get(); +} + +ObjCPropertyRecord *APISet::addObjCProperty( + ObjCContainerRecord *Container, StringRef Name, StringRef USR, + PresumedLoc Loc, const AvailabilityInfo &Availability, + const DocComment &Comment, DeclarationFragments Declaration, + DeclarationFragments SubHeading, + ObjCPropertyRecord::AttributeKind Attributes, StringRef GetterName, + StringRef SetterName, bool IsOptional) { + auto Record = std::make_unique<ObjCPropertyRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading, + Attributes, GetterName, SetterName, IsOptional); + return Container->Properties.emplace_back(std::move(Record)).get(); +} + +ObjCInstanceVariableRecord *APISet::addObjCInstanceVariable( + ObjCContainerRecord *Container, StringRef Name, StringRef USR, + PresumedLoc Loc, const AvailabilityInfo &Availability, + const DocComment &Comment, DeclarationFragments Declaration, + DeclarationFragments SubHeading, + ObjCInstanceVariableRecord::AccessControl Access) { + auto Record = std::make_unique<ObjCInstanceVariableRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading, Access); + return Container->Ivars.emplace_back(std::move(Record)).get(); +} + StringRef APISet::recordUSR(const Decl *D) { SmallString<128> USR; index::generateUSRForDecl(D, USR); @@ -130,8 +182,14 @@ StringRef APISet::copyString(StringRef String) { APIRecord::~APIRecord() {} +ObjCContainerRecord::~ObjCContainerRecord() {} + void GlobalRecord::anchor() {} void EnumConstantRecord::anchor() {} void EnumRecord::anchor() {} void StructFieldRecord::anchor() {} void StructRecord::anchor() {} +void ObjCPropertyRecord::anchor() {} +void ObjCInstanceVariableRecord::anchor() {} +void ObjCMethodRecord::anchor() {} +void ObjCInterfaceRecord::anchor() {} |