129 Commits

Author SHA1 Message Date
Nathan Lanza
e66b670f3b
[CIR][Basic][NFC] Add the CIR language to the Language enum
Add the CIR language to the Language enum and the standard usages of it.

commit-id:fd12b2c2

Reviewers: bcardosolopes, AaronBallman, erichkeane

Reviewed By: AaronBallman, bcardosolopes

Pull Request: https://github.com/llvm/llvm-project/pull/86072
2024-03-21 19:53:48 -04:00
Cyndy Ishida
4c6043de0b
[clang][InstallAPI] Add input file support to library (#81701)
This patch adds support for expected InstallAPI inputs. InstallAPI
accepts a well defined filelist of headers and how those headers
represent a single library.

InstallAPI captures header files to determine linkable symbols to then
compare against what was compiled in a binary dylib and generate TBD
files.
2024-02-20 09:39:00 -08:00
Cyndy Ishida
e606dc1daf
[clang] Move AvailabilityInfo into AST library (#81897)
Previously this class was only used by ExtractAPI, but it will soon also
be needed by InstallAPI. This patch should not change availability
behavior but just centralizes the information next to what already is
captured about availability for AST traversal.
2024-02-15 17:14:54 -08:00
Kazu Hirata
26648daeb2 [ExtractAPI] Use StringRef::starts_with (NFC) 2024-01-28 10:47:05 -08: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
Kazu Hirata
f3dcc2351c
[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-13 08:54:13 -08: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
Vlad Serebrennikov
4ad2ada521 [clang][NFC] Refactor ElaboratedTypeKeyword
This patch moves ElaboratedTypeKeyword before `Type` definition so that the enum is complete where bit-field for it is declared. It also converts it to scoped enum and removes `ETK_` prefix.
2023-10-31 20:46:07 +03:00
Vlad Serebrennikov
49fd28d960 [clang][NFC] Refactor ArrayType::ArraySizeModifier
This patch moves `ArraySizeModifier` before `Type` declaration so that it's complete at `ArrayTypeBitfields` declaration. It's also converted to scoped enum along the way.
2023-10-31 18:06:34 +03:00
Kazu Hirata
18d199116f Stop including llvm/ADT/STLFunctionalExtras.h (NFC)
These source files do not use function_ref.
2023-10-13 20:50:58 -07:00
Manna, Soumi
06c9cc7eaa [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto
Reviewed By: tahonermann

Differential Revision: https://reviews.llvm.org/D159474
2023-09-28 09:00:55 -07:00
Jan Svoboda
5a3130e3b6 [clang] NFCI: Use FileEntryRef in FileManager::getCanonicalName() 2023-09-13 15:31:58 -07:00
Antonio Frighetto
ffb8434f6a [clang] Prevent unnecessary copies in SymbolGraphSerializer (NFC) 2023-09-08 17:19:06 +02:00
Elizabeth Andrews
847186eb94 [NFC][Clang] Fix static analyzer concern
Fix a few static analyzer concerns about dereferencing
null value.

Differential Revision: https://reviews.llvm.org/D158671
2023-08-25 13:03:06 -07: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
Justin Bogner
314a5d707f Simplify a conditional in order to avoid a warning under MSVC
We were using some convoluted logic here to check if the result of a
`bool` returning function was false, causing MSVC to give a warning
about "'>': unsafe use of type 'bool' in operation". This just removes
the greater-than comparison of the bool against zero.
2023-08-16 16:19:57 -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
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
Saleem Abdulrasool
05d613ea93 [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations
Running lit tests on Windows can fail because its use of
`os.path.realpath` expands substitute drives, which are used to keep
paths short and avoid hitting MAX_PATH limitations.

Changes lit logic to:

Use `os.path.abspath` on Windows, where `MAX_PATH` is a concern that we
can work around using substitute drives, which `os.path.realpath` would
resolve.

Use `os.path.realpath` on Unix, where the current directory always has
symlinks resolved, so it is impossible to preserve symlinks in the
presence of relative paths, and so we must make sure that all code paths
use real paths.

Also updates clang's `FileManager::getCanonicalName` and `ExtractAPI`
code to avoid resolving substitute drives (i.e. resolving to a path
under a different root).

How tested: built with `-DLLVM_ENABLE_PROJECTS=clang` and built `check-all` on both Windows

Differential Revision: https://reviews.llvm.org/D154130
Reviewed By: @benlangmuir

Patch by Tristan Labelle <tristan@thebrowser.company>!
2023-08-01 11:00:27 -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
Kazu Hirata
c4933940f7 [clang] Use DenseMapBase::lookup (NFC) 2023-06-13 00:24:43 -07:00
Erick Velez
06ff977047 [clang][ExtractAPI] Refactor serializer to the CRTP
Refactor SerializerBase and SymbolGraphSerializer to use a visitor pattern described by the CRTP.

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D151477
2023-05-30 19:00:35 +01: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
Mitch Phillips
96f028c0a2 Revert "[clang][ExtractAPI] Add queried symbol to parent contexts in libclang"
This reverts commit 1cfe1e732ad8e8148f6fa8fc0f0c86f4b965d567.

Depends on reverted commit 158a431227a876306fe5838936413dd51588d0c6. See
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd for
more information, this broke the ASan bots.
2023-03-29 11:39:32 -07:00
Daniel Grumberg
1cfe1e732a [clang][ExtractAPI] Add queried symbol to parent contexts in libclang
Ensure that the current symbol is added to the parent contexts in the
output of libclang function for generating symbol graphs for single symbols.

Differential Revision: https://reviews.llvm.org/D147138
2023-03-29 16:32:26 +01: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
d0dd151eed Address code review feedback 2023-03-27 17:24:10 +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