aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test/c-index-test.c
AgeCommit message (Collapse)AuthorFilesLines
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-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-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-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-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-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-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-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
2022-04-08Add some function prototypes; NFCAaron Ballman1-3/+3
(This file is compiled with -pedantic enabled in some two-stage builds)
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis1-0/+17
disabled for a PCH vs a module file This addresses an issue with how the PCH preable works, specifically: 1. When using a PCH/preamble the module hash changes and a different cache directory is used 2. When the preamble is used, PCH & PCM validation is disabled. Due to combination of #1 and #2, reparsing with preamble enabled can end up loading a stale module file before a header change and using it without updating it because validation is disabled and it doesn’t check that the header has changed and the module file is out-of-date. rdar://72611253 Differential Revision: https://reviews.llvm.org/D95159
2020-12-07[clang] Add a new nullability annotation for swift async: _Nullable_resultErik Pilkington1-4/+14
_Nullable_result generally like _Nullable, except when being imported into a swift async method. rdar://70106409 Differential revision: https://reviews.llvm.org/D92495
2020-04-16Expose AtomicType in the libclang C API.Henry Jen1-0/+6
2019-12-21[Wdocumentation] Implement \anchorMark de Wever1-0/+3
Differential revision: https://reviews.llvm.org/D69223
2019-08-27[preprocessor] Add an opportunity to retain excluded conditional blocksEvgeny Mankov1-0/+30
It is handy for clang tooling, for instance, in source to source transformation. Reviewers: vpykhtin (Valery Pykhtin), erichkeane (Erich Keane) Subscribers: rsmith (Richard Smith), akyrtzi (Argyrios Kyrtzidis) Tags: #clang Differential Revision: https://reviews.llvm.org/D66597 llvm-svn: 370123
2019-06-26Print NULL as "(null)" in diagnostic messageXing Xue1-4/+6
Summary: Passing a null pointer to the printf family for a %s format specifier leads to undefined behaviour. The tests currently expect (null). Explicitly test for a null pointer and provide the expected string. Authored By: andusy Reviewers: hubert.reinterpretcast, xingxue, jasonliu, daltenty, cebowleratibm Reviewed By: hubert.reinterpretcast Subscribers: arphaman, jsji, cfe-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63786 llvm-svn: 364462
2019-06-11[libclang] Allow skipping warnings from all included filesNikolai Kosjar1-0/+2
Depending on the included files and the used warning flags, e.g. - Weverything, a huge number of warnings can be reported for included files. As processing that many diagnostics comes with a performance impact and not all clients are interested in those diagnostics, add a flag to skip them. Differential Revision: https://reviews.llvm.org/D48116 llvm-svn: 363067
2019-05-10[libclang] Forward isInline for NamespaceDecl to libclangNikolai Kosjar1-0/+7
llvm-svn: 360428
2019-04-29[libclang] Restore old clang_Cursor_isAnonymous behaviourIvan Donchevskii1-0/+6
D54996 Changed the behaviour of clang_Cursor_isAnonymous, but there is no alternative available to get the old behaviour in some cases, which is essential for determining if a record is syntactically accessible, e.g. struct { int x; int y; } foo; struct { struct { int x; int y; }; } bar; void fun(struct { int x; int y; } *param); The only 'anonymous' struct here is the one nested in bar, since there is no way to reference the struct itself, only the fields within. Though the anonymity applies to the instance itself, not the type. To avoid confusion, I have added a new function called clang_Cursor_isAnonymousRecordDecl which has the old behaviour of clang_Cursor_isAnonymous (and updated the doc for the latter as well, which was seemingly forgotten). Patch by Jorn Vernee. Differential Revision: https://reviews.llvm.org/D61232 llvm-svn: 359448
2019-02-26[libclang] Avoid crashing when getting layout info of an undeduced type.Emilio Cobos Alvarez1-11/+28
When the type is not deducible, return an error instead of crashing. This fixes https://bugs.llvm.org/show_bug.cgi?id=40813. Differential Revision: https://reviews.llvm.org/D58569 llvm-svn: 354885
2019-01-10[libclang] Fix clang_Cursor_isAnonymousIvan Donchevskii1-7/+8
Use the same logic as in TypePrinter::printTag to determine that the tag is anonymous and the separate check for namespaces. Differential Revision: https://reviews.llvm.org/D54996 llvm-svn: 350805
2018-08-03[libclang 7/8] Add support for getting property setter and getter namesMichael Wu1-0/+28
Summary: This allows libclang to access the actual names of property setters and getters without needing to go through the indexer API. Usually default names are used, but the property can specify a different name. Reviewers: yvvan, jbcoe Reviewed By: yvvan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49634 llvm-svn: 338816