aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test
AgeCommit message (Collapse)AuthorFilesLines
11 days[clang] Pass VFS into `ASTUnit::LoadFromASTFile()` (#159166)Jan Svoboda1-3/+4
This PR makes the `VFS` parameter to `ASTUnit::LoadFromASTFile()` required and explicit, rather than silently defaulting to the real file system. This makes it easy to correctly propagate the fully-configured VFS and load any input files like the rest of the compiler does.
2025-06-25[clang-c] introduce queries on GCC-style inline assembly statements (#143424)wieDasDing1-0/+50
[Discourse link](https://discourse.llvm.org/t/a-small-proposal-for-extraction-of-inline-assembly-block-information/86658) We strive for exposing such information using existing stable ABIs. In doing so, queries are limited to what the original source holds or the LLVM IR `asm` block would expose in connection with attributes that the queries are concerned. These APIs opens new opportunities for `rust-bindgen` to translate inline assemblies in reasonably cases into Rust inline assembly blocks, which would further aid better interoperability with other existing code. --------- Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
2025-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda1-9/+11
(#139584)" This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22Revert "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Kazu Hirata1-11/+9
(#139584)" This reverts commit 9e306ad4600c4d3392c194a8be88919ee758425c. Multiple builtbot failures have been reported: https://github.com/llvm/llvm-project/pull/139584
2025-05-22[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)Jan Svoboda1-9/+11
The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted.
2025-05-05Remove duplicate API (#132776)Jugst3r1-3/+3
And adapt the existing code to account for the comments made when introducing the duplicate API. Note that this introduces a retro-incompatibility with LLVM 19. cc @sebastianpoeplau
2025-05-05[NFC] Fix c++ style comment in c file (#138244)Björn Pettersson1-1/+1
Fix "C++ style comments are not allowed in ISO C90" warnings in some C files.
2025-04-25[clang] Do not share ownership of `HeaderSearchOptions` (#132984)Jan Svoboda1-1/+1
This PR makes it so that `CompilerInvocation` is the sole owner of the `HeaderSearchOptions` instance.
2025-03-05[NFC][c-index-test] factor data len out (#129971)Jinsong Ji1-6/+4
Follow up of #129922
2025-03-05c-index-test: fix buffer overflow (#129922)Jinsong Ji1-2/+3
We should not try to overwrite the pointer of struct, also need to add 1 for end of line.
2025-03-04clang-tools: Fix sprintf is deprecated warnings (#120517)Matt Arsenault1-8/+10
2025-02-18[c-index-test] Fix warningsKazu Hirata1-4/+8
This patch fixes: clang/tools/c-index-test/c-index-test.c:1240:15: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement] clang/tools/c-index-test/c-index-test.c:1367:14: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement] clang/tools/c-index-test/c-index-test.c:1468:14: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
2025-02-18[clang] fix use after free in clang/tools/c-index-test/c-index-test.c (#127063)Mikhail Goncharov1-19/+32
recent change e76739eeb952940b2979c70ba44a28fecf592695 has exposed use after free in GetCursorSource() function that returned pointer to a disposed CXString
2025-02-13[NFC] format c-index-test.cMikhail Goncharov1-0/+2
to separate formatting changes from a functional fix later also inlcude CXDiagnostic and CXFile
2024-11-21Reapply "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Kadir Cetinkaya1-3/+6
This reverts commit a1153cd6fedd4c906a9840987934ca4712e34cb2 with fixes to lldb breakages. Fixes https://github.com/llvm/llvm-project/issues/117145.
2024-11-21Revert "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Sylvestre Ledru1-6/+3
Reverted for causing: https://github.com/llvm/llvm-project/issues/117145 This reverts commit bdd10d9d249bd1c2a45e3de56a5accd97e953458.
2024-11-21[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)kadir çetinkaya1-3/+6
Starting with 41e3919ded78d8870f7c95e9181c7f7e29aa3cc4 DiagnosticsEngine creation might perform IO. It was implicitly defaulting to getRealFileSystem. This patch makes it explicit by pushing the decision making to callers. It uses ambient VFS if one is available, and keeps using `getRealFileSystem` if there aren't any VFS.
2024-09-23[Frontend] Teach LoadFromASTFile to take FileName by StringRef (NFC) (#109583)Kazu Hirata1-6/+6
Without this patch, several callers of LoadFromASTFile construct an instance of std::string to be passed as FileName, only to be converted back to StringRef when LoadFromASTFile calls ReadAST. This patch changes the type of FileName to StringRef and updates the callers.
2024-09-05[NFC][SystemZ][z/OS] Rename autoconversion-related functions to be less ↵Abhina Sree1-2/+2
generic (#107399) This patch renames the functions in AutoConvert.h/cpp to have a less generic name because they are z/OS specific.
2024-07-23[clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter ↵Chuanqi Xu2-2/+1
(#99599) Close https://github.com/llvm/llvm-project/issues/99479 See https://github.com/llvm/llvm-project/issues/99479 for details
2024-07-15Fix memory leak in unit testAaron Ballman1-1/+1
2024-07-15Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via ↵Thomas Wucher1-0/+18
libclang and its python interface (#98489) This is a rework of patch [D10833](https://reviews.llvm.org/D10833) previously posted on LLVM Phabricator by arthurp in 2015. It allows to retrieve the type of binary operator via libclangs python bindings. I did clean up the changes, removed unrelated changes and rebased the changeset to the latest main branch. As this is my first contribution to the LLVM project, let me know if any required tests or documentation are missing.
2024-04-24[libclang] Compute the right spelling location (#72400)Sebastian Poeplau1-28/+26
Locations inside macro expansions have different spelling/expansion locations. Apply a FIXME to make the libclang function clang_getSpellingLocation return the right spelling location, and adapt the testsuite driver code to use the file location rather than the spelling location to compute source ranges. Co-authored-by: Matthieu Eyraud <eyraud@adacore.com>
2024-02-23[C++20] [Modules] Allow to compile a pcm with and without -fPICChuanqi Xu1-1/+1
seperately We can compile a module unit in 2 phase compilaton: ``` clang++ -std=c++20 a.cppm --precompile -o a.pcm clang++ -std=c++20 a.pcm -c -o a.o ``` And it is a general requirement that we need to compile a translation unit with and without -fPIC for static and shared libraries. But for C++20 modules with 2 phase compilation, it may be waste of time to compile them 2 times completely. It may be fine to generate one BMI and compile it with and without -fPIC seperately. e.g., ``` clang++ -std=c++20 a.cppm --precompile -o a.pcm clang++ -std=c++20 a.pcm -c -o a.o clang++ -std=c++20 a.pcm -c -fPIC -o a-PIC.o ``` Then we can save the time to parse a.cppm repeatedly.
2024-01-21[Clang] Use const pointer to eliminate warning with libxml 2.12.0 (#76719)FantasqueX1-2/+2
Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2 is above 2.12.0, there will be two warnings when building clang. warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an expression of type 'const xmlError *' (aka 'const struct _xmlError *') discards qualifiers Since this commit https://gitlab.gnome.org/GNOME/libxml2/-/commit/45470611b047db78106dcb2fdbd4164163c15ab7, libxml2 makes cmlGetLastError return a const error. This patch follows libxml2. Making the result a const pointer should be compatible with versions before 2.12.0. Tested on ArchLinux with libxml2 2.12.3 installed.
2024-01-17[clang][tools] Silence const cast warning when building with Clang ToTAlexandre Ganea1-1/+13
This fixes: ``` [4960/7446] Building C object tools\clang\tools\c-index-test\CMakeFiles\c-index-test.dir\c-index-test.c.obj C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(49,19): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 49 | return((char*)path); | ^ C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(239,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 239 | free((char *)unsaved_files[i].Filename); | ^ C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(240,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] 240 | free((char *)unsaved_files[i].Contents); | ^ ```
2023-12-13[SystemZ][z/OS] Complete EBCDIC I/O support (#75212)Abhina Sree1-0/+9
This patch completes the support for EBCDIC I/O support on z/OS using the autoconversion functions.
2023-11-28[clang] Remove unused argument. NFC. (#73594)Juergen Ributzka1-1/+1
2023-11-24[clang] Add missing LinkageSpec case to getCursorKindForDecl (#72401)Sebastian Poeplau1-0/+4
The LinkageSpec case was omitted, and there is a declared CXCursor_Kind for it. Adapt the testsuite drivers to print mangled names for declarations with extern linkage. Also update the test baseline for the recursive-cxx-member-calls.cpp test. Co-authored-by: Matthieu Eyraud <eyraud@adacore.com>
2023-07-19[tools] Use "#pragma GCC" instead of "#pragma clang" to ignore -Wcast-qual ↵Jie Fu1-10/+10
in c-index-test.c (NFC)
2023-07-19[tools] Fix buildbot build failureJie Fu1-0/+8
/buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:234: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:235: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:236:10: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:237:10: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:238: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:3765: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:3766: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:3767:10: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual] /buildbot/worker/arc-folder/llvm-project/clang/tools/c-index-test/c-index-test.c:3768: warning: ignoring '#pragma clang diagnostic' [-Wunknown-pragmas]
2023-07-19[tools] Ignore -Wcast-qual in c-index-test.c after D153911 (NFC)Jie Fu1-0/+6
/Users/jiefu/llvm-project/clang/tools/c-index-test/c-index-test.c:234:18: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual] free((char *)unsaved_files[i].Filename); ^ /Users/jiefu/llvm-project/clang/tools/c-index-test/c-index-test.c:235:18: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual] free((char *)unsaved_files[i].Contents); ^ /Users/jiefu/llvm-project/clang/tools/c-index-test/c-index-test.c:3762:32: error: cast from 'const char *' to 'void *' drops const qualifier [-Werror,-Wcast-qual] return (CXIdxClientContainer)"TU"; ^ 3 errors generated.
2023-05-23[C++20] [Modules] Don't ignore -fmodule-file when we compile pcm filesChuanqi Xu1-1/+3
Close https://github.com/llvm/llvm-project/issues/62843. Previously when we compile .pcm files into .o files, the `-fmodule-file=<module-name>=<module-path>` option is ignored. This is conflicted with our consensus in https://github.com/llvm/llvm-project/issues/62707.
2023-03-30[clang][ExtractAPI] Reland ExtractAPI for libclang improvementsDaniel Grumberg1-0/+21
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-29Revert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656""Mitch Phillips1-20/+0
This reverts commit 79116475124112051625b1a0665e35c861bb13fd. Broke the ASan bots. See more information in https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd
2023-03-29Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656"Daniel Grumberg1-0/+20
This reverts commit 158a431227a876306fe5838936413dd51588d0c6.
2023-03-27Revert ExtractAPI from https://reviews.llvm.org/D146656Daniel Grumberg1-20/+0
2023-03-27[clang][ExtractAPI] Refactor ExtractAPIVisitor to make it more extensibleDaniel Grumberg1-0/+20
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 [clang][ExtractAPI] Improve tests for clang_getSymbolGraphForCursor Adds a new mode to c-index-test that can fetch a single symbol symbol graph for a given source location. This way we can be more precise when writing tests for clang_getSymbolGraphForCursor. Additionaly this makes it easier to debug the function. Differential Revision: https://reviews.llvm.org/D146656
2023-03-07[libclang] Add API to override preamble storage pathIgor Kushnir1-22/+38
TempPCHFile::create() calls llvm::sys::fs::createTemporaryFile() to create a file named preamble-*.pch in a system temporary directory. This commit allows overriding the directory where these often many and large preamble-*.pch files are stored. The referenced bug report requests the ability to override the temporary directory path used by libclang. However, overriding the return value of llvm::sys::path::system_temp_directory() was rejected during code review as improper and because it would negatively affect multithreading performance. Finding all places where libclang uses the temporary directory is very difficult. Therefore this commit is limited to override libclang's single known use of the temporary directory. This commit allows to override the preamble storage path only during CXIndex construction to avoid multithreading issues and ensure that all preambles are stored in the same directory. For the same multithreading and consistency reasons, this commit deprecates clang_CXIndex_setGlobalOptions() and clang_CXIndex_setInvocationEmissionPathOption() in favor of specifying these options during CXIndex construction. Adding a new CXIndex constructor function each time a new initialization argument is needed leads to either a large number of function parameters unneeded by most libclang users or to an exponential number of overloads that support different usage requirements. Therefore this commit introduces a new extensible struct CXIndexOptions and a general function clang_createIndexWithOptions(). A libclang user passes a desired preamble storage path to clang_createIndexWithOptions(), which stores it in CIndexer::PreambleStoragePath. Whenever clang_parseTranslationUnit_Impl() is called, it passes CIndexer::PreambleStoragePath to ASTUnit::LoadFromCommandLine(), which stores this argument in ASTUnit::PreambleStoragePath. Whenever ASTUnit::getMainBufferWithPrecompiledPreamble() is called, it passes ASTUnit::PreambleStoragePath to PrecompiledPreamble::Build(). PrecompiledPreamble::Build() forwards the corresponding StoragePath argument to TempPCHFile::create(). If StoragePath is not empty, TempPCHFile::create() stores the preamble-*.pch file in the directory at the specified path rather than in the system temporary directory. The analysis below proves that this passing around of the PreambleStoragePath string is sufficient to guarantee that the libclang user override is used in TempPCHFile::create(). The analysis ignores API uses in test code. TempPCHFile::create() is called only in PrecompiledPreamble::Build(). PrecompiledPreamble::Build() is called only in two places: one in clangd, which is not used by libclang, and one in ASTUnit::getMainBufferWithPrecompiledPreamble(). ASTUnit::getMainBufferWithPrecompiledPreamble() is called in 3 places: ASTUnit::LoadFromCompilerInvocation() [analyzed below]. ASTUnit::Reparse(), which in turn is called only from clang_reparseTranslationUnit_Impl(), which in turn is called only from clang_reparseTranslationUnit(). clang_reparseTranslationUnit() is never called in LLVM code, but is part of public libclang API. This function's documentation requires its translation unit argument to have been built with clang_createTranslationUnitFromSourceFile(). clang_createTranslationUnitFromSourceFile() delegates its work to clang_parseTranslationUnit(), which delegates to clang_parseTranslationUnit2(), which delegates to clang_parseTranslationUnit2FullArgv(), which delegates to clang_parseTranslationUnit_Impl(), which passes CIndexer::PreambleStoragePath to the ASTUnit it creates. ASTUnit::CodeComplete() passes AllowRebuild = false to ASTUnit::getMainBufferWithPrecompiledPreamble(), which makes it return nullptr before calling PrecompiledPreamble::Build(). Both ASTUnit::LoadFromCompilerInvocation() overloads (one of which delegates its work to another) call ASTUnit::getMainBufferWithPrecompiledPreamble() only if their argument PrecompilePreambleAfterNParses > 0. LoadFromCompilerInvocation() is called in: ASTBuilderAction::runInvocation() keeps the default parameter value of PrecompilePreambleAfterNParses = 0, meaning that the preamble file is never created from here. ASTUnit::LoadFromCommandLine(). ASTUnit::LoadFromCommandLine() is called in two places: CrossTranslationUnitContext::ASTLoader::loadFromSource() keeps the default parameter value of PrecompilePreambleAfterNParses = 0, meaning that the preamble file is never created from here. clang_parseTranslationUnit_Impl(), which passes CIndexer::PreambleStoragePath to the ASTUnit it creates. Therefore, the overridden preamble storage path is always used in TempPCHFile::create(). TempPCHFile::create() uses PreambleStoragePath in the same way as LibclangInvocationReporter() uses InvocationEmissionPath. The existing documentation for clang_CXIndex_setInvocationEmissionPathOption() does not specify ownership, encoding, separator or relative vs absolute path requirements. So the documentation for CXIndexOptions::PreambleStoragePath doesn't either. The assumptions are: no ownership transfer; UTF-8 encoding; native separators. Both relative and absolute paths are supported. The added API works as expected in KDevelop: https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/283 Fixes: https://github.com/llvm/llvm-project/issues/51847 Differential Revision: https://reviews.llvm.org/D143418
2023-01-27Add clang_CXXMethod_isExplicit to libclangLuca Di Sera1-0/+2
The new method is a wrapper of `CXXConstructorDecl::isExplicit` and `CXXConversionDecl::isExplicit`, allowing the user to recognize whether the declaration pointed to by a cursor was marked with the explicit specifier. An export for the function, together with its documentation, was added to "clang/include/clang-c/Index.h" with an implementation provided in "clang/tools/libclang/CIndex.cpp". The implementation is based on similar `clang_CXXMethod` implementations, returning a falsy unsigned value when the cursor is not a declaration, is not a declaration for a constructor or conversion function or is not a relevant declaration that was marked with the `explicit` specifier. The new symbol was added to "clang/tools/libclang/libclang.map" to be exported, under the LLVM16 tag. "clang/tools/c-index-test/c-index-test.c" was modified to print a specific tag, "(explicit)", for cursors that are recognized by `clang_CXXMethod_isExplicit`. Two new regression files, "explicit-constructor.cpp" and "explicit-conversion-function.cpp", were added to "clang/test/Index", to ensure that the behavior of the new function is correct for constructors and conversion functions, respectively. The "get-cursor.cpp", "index-file.cpp" and "recursive-cxx-member-calls.cpp" regression files in "clang/test/Index" were updated as they were affected by the new "(explicit)" tag. A binding for the new function was added to libclang's python's bindings, in "clang/bindings/python/clang/cindex.py", as the "is_explicit_method" method under `Cursor`. An accompanying test was added to "clang/bindings/python/tests/cindex/test_cursor.py", mimicking the regression tests for the C side. The current release note for Clang, "clang/docs/ReleaseNotes.rst" was modified to report the new addition under the "libclang" section. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D140756
2023-01-23Revert "Add clang_CXXMethod_isExplicit to libclang"Luca Di Sera1-2/+0
This is currently failing the build due to some test errors. This reverts commit ddbe14084da7f31d4b4b53e13d9f868d759f3673.
2023-01-23Add clang_CXXMethod_isExplicit to libclangLuca Di Sera1-0/+2
The new method is a wrapper of `CXXConstructorDecl::isExplicit` and `CXXConversionDecl::isExplicit`, allowing the user to recognize whether the declaration pointed to by a cursor was marked with the explicit specifier. An export for the function, together with its documentation, was added to "clang/include/clang-c/Index.h" with an implementation provided in "clang/tools/libclang/CIndex.cpp". The implementation is based on similar `clang_CXXMethod` implementations, returning a falsy unsigned value when the cursor is not a declaration, is not a declaration for a constructor or conversion function or is not a relevant declaration that was marked with the `explicit` specifier. The new symbol was added to "clang/tools/libclang/libclang.map" to be exported, under the LLVM16 tag. "clang/tools/c-index-test/c-index-test.c" was modified to print a specific tag, "(explicit)", for cursors that are recognized by `clang_CXXMethod_isExplicit`. Two new regression files, "explicit-constructor.cpp" and "explicit-conversion-function.cpp", were added to "clang/test/Index", to ensure that the behavior of the new function is correct for constructors and conversion functions, respectively. The "get-cursor.cpp", "index-file.cpp" and "recursive-cxx-member-calls.cpp" regression files in "clang/test/Index" were updated as they were affected by the new "(explicit)" tag. A binding for the new function was added to libclang's python's bindings, in "clang/bindings/python/clang/cindex.py", as the "is_explicit_method" method under `Cursor`. An accompanying test was added to "clang/bindings/python/tests/cindex/test_cursor.py", mimicking the regression tests for the C side. The current release note for Clang, "clang/docs/ReleaseNotes.rst" was modified to report the new addition under the "libclang" section. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D140756
2022-12-13[clang][ExtractAPI] Add support for single symbol SGF and libclang supportDaniel Grumberg1-5/+85
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-11-14Add clang_CXXMethod_isMoveAssignmentOperator to libclangLuca Di Sera1-0/+2
The new method is a wrapper of `CXXMethodDecl::isMoveAssignmentOperator` and can be used to recognized move-assignment operators in libclang. An export for the function, together with its documentation, was added to "clang/include/clang-c/Index.h" with an implementation provided in "clang/tools/libclang/CIndex.cpp". The implementation was based on similar `clang_CXXMethod.*` implementations, following the same structure but calling `CXXMethodDecl::isMoveAssignmentOperator` for its main logic. The new symbol was further added to "clang/tools/libclang/libclang.map" to be exported, under the LLVM16 tag. "clang/tools/c-index-test/c-index-test.c" was modified to print a specific tag, "(move-assignment operator)", for cursors that are recognized by `clang_CXXMethod_isMoveAssignmentOperator`. A new regression test file, "clang/test/Index/move-assignment-operator.cpp", was added to ensure whether the correct constructs were recognized or not by the new function. The "clang/test/Index/get-cursor.cpp" regression test file was updated as it was affected by the new "(move-assignment operator)" tag. A binding for the new function was added to libclang's python's bindings, in "clang/bindings/python/clang/cindex.py", adding a new method for `Cursor`, `is_move_assignment_operator_method`. An accompanying test was added to `clang/bindings/python/tests/cindex/test_cursor.py`, testing the new function with the same methodology as the corresponding libclang test. The current release note, `clang/docs/ReleaseNotes.rst`, was modified to report the new addition under the "libclang" section. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D137246
2022-11-14Revert "[libclang] Expose completion result kind in `CXCompletionResult`"Muhammad Omair Javaid1-4/+1
This reverts commit 97105e5bf70fae5d9902081e917fd178b57f1717. It breaks clang-armv8-quick buildbot: https://lab.llvm.org/buildbot/#/builders/245/builds/761
2022-11-10[libclang] Expose completion result kind in `CXCompletionResult`Egor Zhdan1-1/+4
This allows clients of libclang to check whether a completion result is a keyword. Previously, keywords had `CursorKind == CXCursor_NotImplemented` and it wasn't trivial to distinguish a keyword from a pattern. This change moves `CodeCompletionResult::ResultKind` to `clang-c` under a new name `CXCompletionResultKind`. It also tweaks `c-index-test` to print the result kind instead of `NotImplemented`, and adjusts the tests for the new output. rdar://91852088 Differential Revision: https://reviews.llvm.org/D136844
2022-10-27Add clang_CXXMethod_isCopyAssignmentOperator to libclangLuca Di Sera1-0/+2
The new method is a wrapper of `CXXMethodDecl::isCopyAssignmentOperator` and can be used to recognized copy-assignment operators in libclang. An export for the method, together with its documentation, was added to "clang/include/clang-c/Index.h" with an implementation provided in "clang/tools/libclang/CIndex.cpp". The implementation was based on similar `clang_CXXMethod.*` implementations, following the same structure but calling `CXXMethodDecl::isCopyAssignmentOperator` for its main logic. The new symbol was further added to "clang/tools/libclang/libclang.map" to be exported, under the LLVM16 tag. "clang/tools/c-index-test/c-index-test.c" was modified to print a specific tag, "(copy-assignment operator)", for cursors that are recognized by `clang_CXXMethod_isCopyAssignmentOperator`. A new regression test file, "clang/test/Index/copy-assignment-operator.cpp", was added to ensure that the correct constructs were recognized or not by the new function. The "clang/test/Index/get-cursor.cpp" regression test file was updated as it was affected by the new "(copy-assignment operator)" tag. A binding for the new function was added to libclang's python's bindings, in "clang/bindings/python/clang/cindex.py", adding a new method for `Cursor`, `is_copy_assignment_operator_method`. The current release note, `clang/docs/ReleaseNotes.rst`, was modified to report the new addition under the "libclang" section. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D136604
2022-09-23Allow getting template args for ClassTemplateSpecializationsAnders Langlands1-1/+4
Modifies clang_Cursor_getNumTemplateArguments() and friends to work on Struct, Class and ClassTemplatePartialSpecialization decls as well as functions. Differential Revision: https://reviews.llvm.org/D134416
2022-09-21Add clang_CXXMethod_isDeleted functionAnders Langlands1-0/+2
Adds a function to check if a method has been deleted by copy-pasting the existing implementation of clang_CXXMethod_isDefaulted and changing it to call CXXMethod::isDeleted() instead. Differential Revision: https://reviews.llvm.org/D133924
2022-05-24[libclang] add supporting for indexing/visiting C++ conceptsAlex Lorenz1-0/+2
This commit builds upon recently added indexing support for C++ concepts from https://reviews.llvm.org/D124441 by extending libclang to support indexing and visiting concepts, constraints and requires expressions as well. Differential Revision: https://reviews.llvm.org/D126031