diff options
author | Zixu Wang <zixu_wang@apple.com> | 2022-03-21 19:11:29 -0700 |
---|---|---|
committer | Zixu Wang <zixu_wang@apple.com> | 2022-03-23 09:45:06 -0700 |
commit | 5bb5704c1b35023b8a6217a6eb7d98a47efe1ca2 (patch) | |
tree | dfdf6f8149f31b13fc83902a211b55cbd5ca8119 /clang/lib/ExtractAPI/DeclarationFragments.cpp | |
parent | 311bdbc9b73f7aadc37be4285c74576600b9bdba (diff) | |
download | llvm-5bb5704c1b35023b8a6217a6eb7d98a47efe1ca2.zip llvm-5bb5704c1b35023b8a6217a6eb7d98a47efe1ca2.tar.gz llvm-5bb5704c1b35023b8a6217a6eb7d98a47efe1ca2.tar.bz2 |
[clang][extract-api] Add struct support
- Add `StructFieldRecord` and `StructRecord` to store API information
for structs
- Implement `VisitRecordDecl` in `ExtractAPIVisitor`
- Implement Symbol Graph serialization for struct records.
- Add test case for struct records.
Depends on D121873
Differential Revision: https://reviews.llvm.org/D122202
Diffstat (limited to 'clang/lib/ExtractAPI/DeclarationFragments.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/DeclarationFragments.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index daa01c7..1980e8e 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -430,6 +430,30 @@ DeclarationFragmentsBuilder::getFragmentsForEnum(const EnumDecl *EnumDecl) { return Fragments; } +DeclarationFragments +DeclarationFragmentsBuilder::getFragmentsForField(const FieldDecl *Field) { + DeclarationFragments After; + return getFragmentsForType(Field->getType(), Field->getASTContext(), After) + .appendSpace() + .append(Field->getName(), DeclarationFragments::FragmentKind::Identifier) + .append(std::move(After)); +} + +DeclarationFragments +DeclarationFragmentsBuilder::getFragmentsForStruct(const RecordDecl *Record) { + // TODO: After we support typedef records, if there's a typedef for this + // struct just use the declaration fragments of the typedef decl. + + DeclarationFragments Fragments; + Fragments.append("struct", DeclarationFragments::FragmentKind::Keyword); + + if (!Record->getName().empty()) + Fragments.appendSpace().append( + Record->getName(), DeclarationFragments::FragmentKind::Identifier); + + return Fragments; +} + FunctionSignature DeclarationFragmentsBuilder::getFunctionSignature(const FunctionDecl *Func) { FunctionSignature Signature; |