33 Commits

Author SHA1 Message Date
Erick Velez
08f034f952 [clang][ExtractAPI] Add support for namespaces
Serialize namespaces, nested namespaces, and class relationships inside them.

Depends on D157076

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D158239
2023-08-22 09:56:34 -07:00
Erick Velez
634b2fd2ca [clang][ExtractAPI] Add support for C++ member templates
Visit and serialize C++ fields by checking if a var template's context is a CXXRecordDecl in VisitVarTemplateDecl.

Depends on D158027

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D158029
2023-08-21 10:17:58 -07:00
Erick Velez
80b787e803 [clang][ExtractAPI] Add support for C++ global function templates
Add records, serialization for global function templates and their specializations

Depends on D157350

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D157579
2023-08-18 17:42:05 -07:00
Erick Velez
8d8c8981ca [clang][ExtractAPI] Add support for C++ variable templates
Serialize global C++ variable templates and specializations.

Depends on D157076

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D157350
2023-08-18 13:57:02 -07:00
Erick Velez
7ba37f4e46 [clang][ExtractAPI] Add support for C++ class templates and concepts
Add has_template template, DeclarationFragmentBuilder functions, and tests for class templates, specializations/partial specs, and concepts.

Depends on D157007

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D157076
2023-08-18 13:40:22 -07:00
Erick Velez
75f55eb331 [clang][ExtractAPI] Add support for C++ classes with fix
Reintroduce D153557 with fix for use-after-free from f4de606ef271 and minor changes.

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D157007
2023-08-04 07:19:24 -07:00
Erick Velez
20f7cc0df3 Revert "[clang][ExtractAPI] Add support for C++ classes"
This reverts commit 8b76b44e46ac5b4efbf8cb3702f09d353af2a112.
2023-08-02 13:23:45 -07:00
Augie Fackler
f4de606ef2 fix use-after-free introduced in 8b76b44e46ac
ASan catches this easily enough.
2023-08-02 14:38:08 -04:00
Erick Velez
8b76b44e46 [clang][ExtractAPI] Add support for C++ classes
Add ExtractAPI support C++ classes, fields,  methods, and various qualifiers and specifiers

Differential Revision: https://reviews.llvm.org/D153557
2023-08-02 10:19:05 -07:00
Erick Velez
422bcd10c4 [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON
Differential Revision: https://reviews.llvm.org/D154038
2023-07-31 23:29:04 -07:00
NagaChaitanya Vellanki
14805dcb0d [clang][ExtractAPI] Add semicolon to function declaration fragments
Add missing semicolon at the end of function declarations to fragments

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D149737
2023-05-04 11:46:43 -07:00
Usman Akinyemi
32b53cf9d0 [ExtractAPI] Remove extra attributes in property declaration fragments
Use `getPropertyAttributesAsWritten` instead of `getPropertyAttributes`
to get property attributes actually specified in the source code.
Resolves issue #61478.

https://reviews.llvm.org/D146759

Reviewed By: zixuw, dang

Differential Revision: https://reviews.llvm.org/D146759
2023-04-04 10:00:34 -07:00
NagaChaitanya Vellanki
a590d86343 [clang][ExtractAPI] Remove extra pointer indirection from declaration fragments for Obj-C lightweight generics on id
Fixes https://github.com/llvm/llvm-project/issues/61479

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D146866
2023-03-30 11:36:16 -07:00
Daniel Grumberg
142c3d9d14 [clang][ExtractAPI] Reland ExtractAPI for libclang improvements
This relands the changes that were originally introduced by:
- https://reviews.llvm.org/D146656
- https://reviews.llvm.org/D147138

This also fixes the leak that led to these changes being reverted

Differential Revision: https://reviews.llvm.org/D147234
2023-03-30 18:13:58 +01:00
Mitch Phillips
3be6c4d413 Revert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656""
This reverts commit 79116475124112051625b1a0665e35c861bb13fd.

Broke the ASan bots. See more information in
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd
2023-03-29 11:39:44 -07:00
Daniel Grumberg
7911647512 Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656"
This reverts commit 158a431227a876306fe5838936413dd51588d0c6.
2023-03-29 10:51:13 +01:00
Daniel Grumberg
158a431227 Revert ExtractAPI from https://reviews.llvm.org/D146656 2023-03-27 22:12:36 +01:00
Daniel Grumberg
ea35740e7e [clang][ExtractAPI] Refactor ExtractAPIVisitor to make it more extensible
Use CRTP to enable creating statically dispatched subclasses of
ExtractAPIVisitor.
This enables adding extension points and customising the behavior more
easily.

This is used in CXExtractAPI.cpp to create a specialized visitor for
Libclang as well as streamlining the batch implementation in ExtractAPIConsumer.cpp
2023-03-27 17:24:10 +01:00
NagaChaitanya Vellanki
c13ccf1fba [clang][ExtractAPI]Fix Declaration fragments for instancetype in the type position degrade to id
Fixes https://github.com/llvm/llvm-project/issues/61481

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D146671
2023-03-23 15:10:27 -07:00
NagaChaitanya Vellanki
afce10c5b6 [clang][ExtractAPI] Add semicolons for enum, typedef, struct declaration fragments
Fixes https://github.com/llvm/llvm-project/issues/61480

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D146354
2023-03-20 15:43:00 +00:00
Daniel Grumberg
7a85192166 [clang][ExtractAPI] Add support for single symbol SGF and libclang support
This is mainly adding an entry point to `SymbolGraphSerializer` at
`serializeSingleSymbolSGF` and exposing the necessary data to make this
possible.  Additionaly there are some changes to how symbol kinds and
path components are serialized to make the usage more ergonomic in
`serializeSingleSymbolSGF`.

On the libclang side this introduces APIs to:
- create an APISet from a TU
- dispose of an APISet
- query an APISet for a single symbol SGF for a given USR.
- generate a single symbol SGF for a given CXCursor, this only traverses
the necessary AST nodes to construct the result as oppposed as going
through the entire AST.

Differential Revision: https://reviews.llvm.org/D139115
2022-12-13 11:18:11 +00:00
Fangrui Song
3f18f7c007 [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D131346
2022-08-08 09:12:46 -07:00
Daniel Grumberg
7f0387de4c [clang][ExtractAPI] Add a space between type and name in property declaration fragments
Differential Revision: https://reviews.llvm.org/D130583
2022-07-27 11:02:21 +01:00
Zixu Wang
4048aad85a [clang][ExtractAPI] Fix declaration fragments for ObjC methods
Objective-C methods selector parts should be considered as identifiers.

Depends on D123259

Differential Revision: https://reviews.llvm.org/D123261
2022-04-07 10:22:41 -07:00
Zixu Wang
fe2c77a006 [clang][ExtractAPI] Fix appendSpace in DeclarationFragments
There is a bug in `DeclarationFragments::appendSpace` where the space
character is added to a local copy of the last fragment.

Differential Revision: https://reviews.llvm.org/D123259
2022-04-07 09:17:30 -07:00
Zixu Wang
178aad9b94 [clang][extract-api] Add Objective-C Category support
Add (partial) support for Objective-C category records in ExtractAPI.
The current ExtractAPI collects everything for an Objective-C category,
but not fully serialized in the SymbolGraphSerializer. Categories
extending external interfaces are disgarded during serialization, and
categories extending known interfaces are merged (all members surfaced)
into the interfaces.

Differential Revision: https://reviews.llvm.org/D122774
2022-04-06 12:00:12 -07:00
Daniel Grumberg
9fc45ca00a [clang][extract-api] Add support for typedefs
Typedef records consist of the symbol associated with the underlying
TypedefDecl and a SymbolReference to the underlying type. Additionally
typedefs for anonymous TagTypes use the typedef'd name as the symbol
name in their respective records and USRs. As a result the declaration
fragments for the anonymous TagType are those for the associated
typedef. This means that when the user is defining a typedef to a
typedef to a anonymous type, we use a reference the anonymous TagType
itself and do not emit the typedef to the anonymous type in the
generated symbol graph, including in the type destination of further
typedef symbol records.

Differential Revision: https://reviews.llvm.org/D123019
2022-04-06 19:14:05 +01:00
Daniel Grumberg
529a0570f7 [clang][extract-api] Add support for macros
To achieve this we hook into the preprocessor during the
ExtractAPIAction and record definitions for macros that don't get
undefined during preprocessing.
2022-03-30 18:33:10 +01:00
Zixu Wang
d1d34bafef [clang][extract-api] Add Objective-C protocol support
Add support for Objective-C protocol declarations in ExtractAPI.

Depends on D122446

Differential Revision: https://reviews.llvm.org/D122511
2022-03-29 14:44:49 -07:00
Zixu Wang
9b36e126fd [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
2022-03-29 14:29:39 -07:00
Zixu Wang
5bb5704c1b [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
2022-03-23 09:45:06 -07:00
Zixu Wang
71b4c22612 [clang][extract-api] Add enum support
Add support for enum records
- Add `EnumConstantRecord` and `EnumRecord` to store API information for
  enums
- Implement `VisitEnumDecl` in `ExtractAPIVisitor`
- Implement serializatin for enum records and `MemberOf` relationship
- Add test case for enum records
- Few other improvements

Depends on D122160

Differential Revision: https://reviews.llvm.org/D121873
2022-03-23 09:41:21 -07:00
Zixu Wang
89f6b26f1b [clang][extract-api] Refactor ExtractAPI and improve docs
- The name SymbolGraph is inappropriate and confusing for the new library
  for clang-extract-api. Refactor and rename things to make it clear that
  ExtractAPI is the core functionality and SymbolGraph is one serializer
  for the API information.
- Add documentation comments to ExtractAPI classes and methods to improve
  readability and clearness of the ExtractAPI work.

Differential Revision: https://reviews.llvm.org/D122160
2022-03-22 13:21:57 -07:00