94 Commits

Author SHA1 Message Date
Prajwal Nadig
0f48bafafc
[ExtractAPI] Include tilde in destructor name (#146001)
The subheading for a destructor contained only the identifier. The tilde
must also be included as it is necessary to differentiate the destructor
from any constructors present.

rdar://129587608
2025-07-07 09:14:47 -06:00
Prajwal Nadig
53102a395f
[ExtractAPI] Format pointer types correctly (#146182)
Pointer types in function signatures must place the asterisk before the
identifier without a space in between. This patch removes the space and
also ensures that pointers to pointers are formatted correctly.

rdar://131780418
rdar://154533037
2025-06-30 08:55:35 -06:00
Prajwal Nadig
23b66a68f1
[ExtractAPI] Include virtual keyword for methods (#145412)
This information was being left out of the symbol graph.

rdar://131780883
2025-06-23 17:10:43 -06:00
Prajwal Nadig
05b4bfe19e
[ExtractAPI] Include +/- symbols for ObjC methods (#145035)
ObjC methods include a +/- prefix to indicate if they are a class or
instance method. This information is valuable, and must be included in
the navigator generated by ExtractAPI.

rdar://150870936
2025-06-20 09:05:16 -06:00
Cyndy Ishida
88f041f3e0
[clang][Darwin] Align all OS Versions for 26 (#143548)
* Translate the following versions to 26.
  * watchOS 12 -> 26
  * visionOS 3 -> 26
  * macos 16 -> 26
  * iOS 19 -> 26
  * tvOS 19 -> 26

* Emit diagnostics, but allow conversion when clients attempt to use
invalid gaps in OS versioning in availability.

* For target-triples, only allow "valid" versions for implicit
conversions.
2025-06-10 09:50:46 -07:00
Mohammad Bashir
bcdce987c0
Fix regression tests with bad FileCheck checks (#140373)
Fixes https://github.com/llvm/llvm-project/issues/140149
2025-05-22 07:59:57 +03:00
QuietMisdreavus
6ef978b8c4
[clang][ExtractAPI] combine typedef records if the underlying type's name is underscored (#125964)
fixes rdar://137214218

When 'typedef struct' decls are encountered, the records are combined if
the underlying type is either anonymous or has the same name as the
typedef. Extend this behavior to also combine records when the
underlying type has an underscored name that is equivalent to the
typedef name when the leading underscores are removed.
2025-02-07 13:23:10 -07:00
QuietMisdreavus
a368402d63
[ExtractAPI] merge anon declarators even if they're array types (#120801) 2025-01-29 13:03:33 -07:00
QuietMisdreavus
1be4a67454
[ExtractAPI] reorder the module names in extension symbol graph file names (#119925)
Resolves rdar://140298287

ExtractAPI's support for printing Objective-C category extensions from
other modules emits symbol graphs with an
`ExtendedModule@HostModule.symbols.json`. However, this is backwards
from existing symbol graph practices, causing issues when these symbol
graphs are consumed alongside symbol graphs generated with other tools
like Swift. This PR flips the naming scheme to be in line with existing
symbol graph tooling.
2024-12-16 13:36:19 -07:00
Daniel Grumberg
949177dabc
[clang][ExtractAPI] Fix up casting from CXXClassRecord (#110983)
`RecordRecord::classOfKind` and `TagRecord::classofKind` didn't
correctly capture `RK_CXXClass` and derived variants, e.g.
`RK_ClassTemplate`. This materialized by anonymous C++ tag types not
being correctly detected when they need to be merged with another
record.
2024-10-16 09:45:43 +01:00
Daniel Grumberg
33fa40cc96
[clang][ExtractAPI] Generate subheading for typedef'd anonymous types (#110689)
When an anonymous type has a typedef we normally use the typedef's name
in places where we expect a named identifier in the symbol graph. This
extends this logic to apply to subheadings.

rdar://136690614
2024-10-02 11:14:27 +01:00
Daniel Grumberg
cf1ad28169
[clang][ExtractAPI] Handle AttributedType fragments transparently (#107262)
rdar://131958623
2024-09-05 09:15:09 +01:00
Daniel Grumberg
b1b24d7517
[clang][ExtractAPI] Fix quirks in interaction with submodules (#105868)
Extension SGFs require the module system to be enabled in order to discover which module defines the extended external type.
This patch ensures the following:
- Associate symbols with their top level module name, and that only top level modules are considered as modules for emitting extension SGFs.
- Ensure we don't drop macro definitions that came from a submodule. To this end look at all defined macros in `PPCalbacks::EndOfMainFile` instead of relying on `PPCallbacks::MacroDefined` being called to detect a macro definition.
2024-08-27 13:50:41 +01:00
Daniel Grumberg
8f4f3df3c0
Reenable anon structs (#104922)
Add back missing includes and revert revert "[clang][ExtractAPI] Stop
dropping fields of nested anonymous record types when they aren't
attached to variable declaration (#104600)"
2024-08-20 15:36:46 +01:00
Daniel Grumberg
b18b4547f1 Revert "[clang][ExtractAPI] Stop dropping fields of nested anonymous record types when they aren't attached to variable declaration (#104600)"
This reverts commit c60da1a271a6bb271e7703b2f7c71fbece67ab78.
2024-08-19 16:06:43 +01:00
Daniel Grumberg
c60da1a271
[clang][ExtractAPI] Stop dropping fields of nested anonymous record types when they aren't attached to variable declaration (#104600)
- Introduce primitives for removing records from `APISet` and managing
the record chain of `RecordContext`
- Detect nested anonymous record types and remove them from the `APISet`
after they have been fully traversed and transfer ownership of child
records to the parent context (if any)
2024-08-19 15:57:43 +01:00
Daniel Grumberg
57abd4e4ab
[clang][ExtractAPI] Emit environment component of target triple in SGF (#103273)
rdar://133533830
2024-08-15 16:23:31 +01:00
Daniel Grumberg
026d963cb0
[clang][ExtractAPI] Compute inherited availability information (#103040)
Additionally this computes availability information for all platforms
ahead of possibly introducing a flag to enable this behavior.

rdar://123513706
2024-08-15 14:19:49 +01:00
Daniel Grumberg
fa649df8e5
[clang][ExtractAPI] Flatten all enum cases from anonymous enums at top level (#93559)
rdar://128863241
2024-05-29 09:47:23 +01:00
Daniel Grumberg
ab7e6b66fd
[clang][ExtractAPI] Ensure TemplateArgumentLocations are only accessed if available (#93205) 2024-05-24 16:32:25 +01:00
Daniel Grumberg
50b2bd4a25
[clang][ExtractAPI] Remove symbols defined in categories to external types unless requested (#92522)
rdar://128259890
2024-05-20 08:59:02 +01:00
Daniel Grumberg
7a67479392
[clang][ExtractAPI] Correctly generate declaration fragments for non-type template parameters (#91958)
Previously we only generated declaration fragments for template type
parameters/arguments, this adds supports for most other possible
template parameters/arguments.

rdar://127732598
2024-05-17 10:33:31 +01:00
Daniel Grumberg
2bcbe40f8a
[clang][ExtractAPI] Fix handling of anonymous TagDecls (#87772)
This changes the handling of anonymous TagDecls to the following rules:
- If the TagDecl is embedded in the declaration for some VarDecl (this
is the only possibility for RecordDecls), then pretend the child decls
belong to the VarDecl
- If it's an EnumDecl proceed as we did previously, i.e., embed it in
the enclosing DeclContext.

Additionally this fixes a few issues with declaration fragments not
consistently including "{ ... }" for anonymous TagDecls. To make testing
these additions easier this patch fixes some text declaration fragments
merging issues and updates tests accordingly.

rdar://121436298
2024-04-24 13:53:29 +01:00
Daniel Grumberg
05c1447b3e
[clang][ExtractAPI] Serialize platform specific unavailable attribute in symbol graphs (#89277)
rdar://125622225
2024-04-23 09:00:08 +01:00
Daniel Grumberg
e05c1b46d0
Reenable external categories (#87357)
Reenables b31414bf4f9898f7817a9fcf8a91f62ec26f3eaf.

Also adds a new warning for missing `--symbol-graph-dir` arg when
`--emit-extension-symbol-graphs` is provided. This also reverts the
commit that removed.
2024-04-03 10:18:05 +01:00
Daniel Grumberg
209a1e8dfd Revert "[clang][ExtractAPI] Add ability to create multiple symbol graphs (#86676)"
This failed the test suite due to missing DiagGroup for a new warning.

This reverts commit b31414bf4f9898f7817a9fcf8a91f62ec26f3eaf.
2024-04-02 15:34:52 +01:00
Daniel Grumberg
b31414bf4f
[clang][ExtractAPI] Add ability to create multiple symbol graphs (#86676)
This extends ExtractAPI to take into account symbols defined in categories to types defined in an external module.
This introduces 2 new command line flags, `--symbol-graph-dir=DIR` and `--emit-extension-symbol-graphs`, when used together this generates additional symbol graph files at `DIR/ExtendedModule@ProductName.symbols.json` for each external module that is extended in this way.

Additionally this makes some cleanups to tests to make them more resilient and cleans up the `APISet` data structure.
2024-04-02 15:03:46 +01:00
Daniel Grumberg
c5532124dc
[clang][ExtractAPI] Ensure typedef to pointer types are preserved (#78584)
When generating declaration fragments for types that use typedefs to
pointer types ensure that we keep the user-defined typedef form instead
of desugaring the typedef.

rdar://102137655
2024-01-22 15:41:29 +00:00
Daniel Grumberg
69fedaf830
[clang][ExtractAPI] Add support C unions in non C++ parsing mode (#77451)
Ensure that we generate correct symbol kinds and declaration fragments
for unions in C and Objective-C parsing modes.

rdar://120544091
2024-01-22 15:32:57 +00:00
Sofía Rodríguez
3d4128f7ff
[clang][ExtractAPI] Record availability information only for the target platform (#76823)
Currently, ExtractAPI provides availability information for all
platforms within a given domain. With this change, we narrow down the
output to include availability details only for the specified target
platform, so users can generate the symbol graph with only the
availability information they need, omitting information of the other
platforms.

This change reverts the functionality introduced in
[`57c9780`](https://github.com/llvm/llvm-project/commit/57c9780).

rdar://120419037
2024-01-19 10:56:53 +00:00
Daniel Grumberg
789a5bbb7d
[clang][ExtractAPI] Allow serialization for ObjC++ headers (#74733)
rdar://79874441
2023-12-07 17:30:02 +00:00
Daniel Grumberg
14e991740b
[clang][ExtractAPI] Ensure LocationFileChecker doesn't try to traverse VFS when determining file path (#74071)
As part of https://reviews.llvm.org/D154130 the logic of
LocationFileChecker changed slightly to try and get the absolute
external file path instead of the name as requested when the file was
openened which would be before VFS mappings in our usage. Ensure that we
only check against the name as requested instead of trying to generate
the external canonical file path.

rdar://115195433
2023-12-01 15:54:36 +00:00
Daniel Grumberg
6b89fab897
[clang][ExtractAPI] Add support for blocks in declaration fragments (#73369)
Ensure that block types get represented correctly in declaration
fragments, as block parameter names are important for documentation
clients we need a separate system from getFragmentsForType in order to
have access to full ParmVarDecls for the parameters.

rdar://118257401
2023-11-28 12:55:27 +00:00
QuietMisdreavus
63537872ae
ExtractAPI: use zero-based indices for line/column in symbol graph (#71753)
Other implementations of the symbol graph format use zero-based indices
for source locations, which causes problems when combined with clang's
current one-based indices. This commit sets ExtractAPI's symbol graph
output to use zero-based indices to align with other implementations.

rdar://107639783
2023-11-14 11:46:12 +00:00
Daniel Grumberg
6b43764a95
[clang][ExtractAPI] Update availability serialization in SGF (#71418)
The prevailiing symbol graph parsing library expects availability
attributes to just be "introduced" instead of "introducedVersion"

rdar://117823923
2023-11-07 10:44:45 +00:00
Erick Velez
e81744563a [clang][ExtractAPI] Fix bool spelling coming from the macro definition.
getFragmentsForType resulted in a bool typeIdentifier fragment to be spelled "_Bool".
This fixes the spelling to be "bool" and checks it in C and C++.

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D158474
2023-08-22 15:00:14 -07:00
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
3bb4855308 [clang][ExtractAPI] Refactor C++ method and field visitation
Refactor visitation for C++ record children by following the Visitor's CRTP.
Expand VisitCXXField, VisitCXXMethod for non-templates and introduce VisitCXXConstructor, VisitCXXDestructor.
Handle relationships by finding the parent's Record via USR from DeclContext.

Depends on D158029

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D158031
2023-08-21 10:38:01 -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
d8e9c5d9ca [clang][ExtractAPI] Visit method templates with better scheme
Visit and serialize method templates and template specializations. Introduces a new scheme of visiting child Decls via VisitCXXMethodDecl which will be followed in future patches for Fields and non-template methods.

Depends on D157579

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D158027
2023-08-21 09:05:57 -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
ruturaj4
1849318539 [clang][ExtractAPI] Add support for Objective-C categories
Differential Revision: https://reviews.llvm.org/D152770
2023-08-15 10:34:21 -05: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
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
Ankur
8e9145e431 [clang][ExtractAPI] Add --emit-symbol-graph option
Add new --emit-symbol-graph=<DIR> option which generates ExtractAPI symbol
graph information of .c/.m files on regular compilation job and put them in
the provided "DIR" directory.

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D152356
2023-07-03 17:32:30 +05:30
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