[clang][extract-api] Add global record support
authorZixu Wang <zixu_wang@apple.com>
Thu, 10 Feb 2022 21:42:35 +0000 (13:42 -0800)
committerZixu Wang <zixu_wang@apple.com>
Wed, 16 Mar 2022 22:13:55 +0000 (15:13 -0700)
commit5aab45f430669d7d2af51386819d071b26c3c89c
tree5a94b9543831365d3ce7f4bf8b0771a6eda77328
parent07b176646134c3d88a4cecef5e0058e2de6b2409
[clang][extract-api] Add global record support

Add facilities for extract-api:
- Structs/classes to hold collected API information: `APIRecord`, `API`
- Structs/classes for API information:
  - `AvailabilityInfo`: aggregated availbility information
  - `DeclarationFragments`: declaration fragments
    - `DeclarationFragmentsBuilder`: helper class to build declaration
      fragments for various types/declarations
  - `FunctionSignature`: function signature
- Serialization: `Serializer`
- Add output file for `ExtractAPIAction`
- Refactor `clang::RawComment::getFormattedText` to provide an
  additional `getFormattedLines` for a more detailed view of comment lines
  used for the SymbolGraph format

Add support for global records (global variables and functions)
- Add `GlobalRecord` based on `APIRecord` to store global records'
  information
- Implement `VisitVarDecl` and `VisitFunctionDecl` in `ExtractAPIVisitor` to
  collect information
- Implement serialization for global records
- Add test case for global records

Differential Revision: https://reviews.llvm.org/D119479
20 files changed:
clang/include/clang/AST/RawCommentList.h
clang/include/clang/Frontend/FrontendActions.h
clang/include/clang/SymbolGraph/API.h [new file with mode: 0644]
clang/include/clang/SymbolGraph/AvailabilityInfo.h [new file with mode: 0644]
clang/include/clang/SymbolGraph/DeclarationFragments.h [new file with mode: 0644]
clang/include/clang/SymbolGraph/FrontendActions.h [new file with mode: 0644]
clang/include/clang/SymbolGraph/Serialization.h [new file with mode: 0644]
clang/lib/AST/RawCommentList.cpp
clang/lib/CMakeLists.txt
clang/lib/Frontend/CMakeLists.txt
clang/lib/Frontend/ExtractAPIConsumer.cpp [deleted file]
clang/lib/FrontendTool/CMakeLists.txt
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/lib/SymbolGraph/API.cpp [new file with mode: 0644]
clang/lib/SymbolGraph/CMakeLists.txt [new file with mode: 0644]
clang/lib/SymbolGraph/DeclarationFragments.cpp [new file with mode: 0644]
clang/lib/SymbolGraph/ExtractAPIConsumer.cpp [new file with mode: 0644]
clang/lib/SymbolGraph/Serialization.cpp [new file with mode: 0644]
clang/test/Driver/extract-api.c
clang/test/SymbolGraph/global_record.c [new file with mode: 0644]