aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test
AgeCommit message (Collapse)AuthorFilesLines
2022-05-10[Frontend] Flip default of CreateInvocationOptions::ProbePrecompiled to falseSam McCall1-0/+1
This is generally a better default for tools other than the compiler, which shouldn't assume a PCH file on disk is something they can consume. Preserve the old behavior in places associated with libclang/c-index-test (including ASTUnit) as there are tests relying on it and most important consumers are out-of-tree. It's unclear whether the tests are specifically trying to test this functionality, and what the downstream implications of removing it are. Hopefully someone more familiar can clean this up in future. Differential Revision: https://reviews.llvm.org/D125149
2022-05-06[clang] createInvocationFromCommandLine -> createInvocation, delete former. NFCSam McCall1-1/+4
(Followup from 40c13720a4b977d4347bbde53c52a4d0703823c2) Differential Revision: https://reviews.llvm.org/D125012
2022-04-08Add some function prototypes; NFCAaron Ballman1-3/+3
(This file is compiled with -pedantic enabled in some two-stage builds)
2022-01-21[clang][cmake] Use `GNUInstallDirs` to support custom installation dirsJohn Ericson1-1/+1
I am breaking apart D99484 so the cause of build failures is easier to understand. Differential Revision: https://reviews.llvm.org/D117419
2022-01-16Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."John Ericson1-1/+1
https://lab.llvm.org/buildbot/#/builders/46/builds/21146 Still have this odd error, not sure how to reproduce, so I will just try breaking up my patch. This reverts commit 4a678f8072004eff9214c1a4e1836a14abb69535.
2022-01-16[cmake] Use `GNUInstallDirs` to support custom installation dirs.John Ericson1-1/+1
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece! It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested. - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`. These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder. Reviewed By: #libunwind, #libc, #libc_abi, compnerd Differential Revision: https://reviews.llvm.org/D99484
2022-01-15Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."John Ericson1-1/+1
Sorry for the disruption, I will try again later. This reverts commit efeb50197091b2ade24c00b9d55814bc433a7fd1.
2022-01-15[cmake] Use `GNUInstallDirs` to support custom installation dirs.John Ericson1-1/+1
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece! It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested. - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself. I figured it was time to make a new revision. I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful. --- As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`. These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder. Reviewed By: #libunwind, #libc, #libc_abi, compnerd Differential Revision: https://reviews.llvm.org/D99484
2021-09-25[CMake] Consistently use the LibXml2::LibXml2 target instead of ↵Markus Böck1-6/+1
LIBXML2_LIBRARIES Linking against the LibXml2::LibXml2 target has the advantage of not only importing the library, but also adding the include path as well as any definitions the library requires. In case of a static build of libxml2, eg. a define is set on Windows to remove any DLL imports and export. LLVM already makes use of the target, but c-index-test and lldb were still linking against the library only. The workaround for Mac OS-X that I removed seems to have also been made redundant since https://reviews.llvm.org/D84563 I believe Differential Revision: https://reviews.llvm.org/D109975
2021-04-06[index] Improve macro indexing supportBen Langmuir1-2/+8
The major change here is to index macro occurrences in more places than before, specifically * In non-expansion references such as `#if`, `#ifdef`, etc. * When the macro is a reference to a builtin macro such as __LINE__. * When using the preprocessor state instead of callbacks, we now include all definition locations and undefinitions instead of just the latest one (which may also have had the wrong location previously). * When indexing an existing module file (.pcm), we now include module macros, and we no longer report unrelated preprocessor macros during indexing the module, which could have caused duplication. Additionally, we now correctly obey the system symbol filter for macros, so by default in system headers only definition/undefinition occurrences are reported, but it can be configured to report references as well if desired. Extends FileIndexRecord to support occurrences of macros. Since the design of this type is to keep a single list of entities organized by source location, we incorporate macros into the existing DeclOccurrence struct. Differential Revision: https://reviews.llvm.org/D99758
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis2-2/+40
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-09Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFCDuncan P. N. Exon Smith1-1/+1
This parameter is always set to `None`. Remove it. Differential Revision: https://reviews.llvm.org/D90889
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-11-17[Frontend] Add flag to allow PCM generation despite compiler errorsBen Barham1-1/+1
As with precompiled headers, it's useful for indexers to be able to continue through compiler errors in dependent modules. Resolves rdar://69816264 Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D91580
2020-04-16Expose AtomicType in the libclang C API.Henry Jen1-0/+6
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-3/+2
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-12-21[Wdocumentation] Implement \anchorMark de Wever1-0/+3
Differential revision: https://reviews.llvm.org/D69223
2019-12-16[NFC] Fix typos in Clangd and ClangKirill Bobyrev1-8/+8
Reviewed by: Jim Differential Revision: https://reviews.llvm.org/D71455
2019-11-25Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber1-4/+4
This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
2019-11-26Use InitLLVM to setup a pretty stack printerRui Ueyama1-4/+4
InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
2019-09-05[clang][Index] Replace CodegenNameGenerator with ASTNameGeneratorJan Korous1-4/+4
Follow-up to: 3ff8c3b73f6, d5d15b4c1fd Should be NFC since the original patch just moved the code. llvm-svn: 371117
2019-08-29[Index] Stopped wrapping FrontendActions in libIndex and its usersDmitri Gribenko1-3/+2
Exposed a new function, createIndexingASTConsumer, that creates an ASTConsumer. ASTConsumers compose well. Removed wrapping functionality from createIndexingAction. llvm-svn: 370337
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-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-1/+1
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
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 Kosjar2-1/+3
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-02-20[clang] Switch to LLVM_ENABLE_IDEShoaib Meenai1-1/+1
r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more directly and can be overridden by a user. Make the corresponding change in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should be available for both standalone and integrated builds. Differential Revision: https://reviews.llvm.org/D58284 llvm-svn: 354525
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
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-09-18[index] Enhance indexing for module referencesArgyrios Kyrtzidis1-3/+12
* Create a USR for the occurrences of the 'module' symbol kind * Record module references for each identifier in an import declaration llvm-svn: 342484
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
2018-08-03[libclang 6/8] Add support for reading implicit attributesMichael Wu1-0/+22
Summary: Having access to implicit attributes is sometimes useful so users of libclang don't have to duplicate some of the logic in sema. This depends on D49081 since it also adds a CXTranslationUnit flag. Reviewers: yvvan, jbcoe Reviewed By: yvvan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49631 llvm-svn: 338815
2018-08-03[libclang 4/8] Add the clang_Type_getNullability() APIMichael Wu1-0/+28
Summary: This patch adds a clang-c API for querying the nullability of an AttributedType. The test here also tests D49081 Reviewers: yvvan, jbcoe Reviewed By: yvvan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49082 llvm-svn: 338809
2018-08-03[libclang 1/8] Add support for ObjCObjectTypeMichael Wu1-1/+36
Summary: This patch adds support to the clang-c API for identifying ObjCObjects in CXTypes, enumerating type args and protocols on ObjCObjectTypes, and retrieving the base type of ObjCObjectTypes. Currently only ObjCInterfaceTypes are exposed, which do not have type args or protocols. Reviewers: yvvan, jbcoe Reviewed By: yvvan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49063 llvm-svn: 338804
2018-08-02[c-index-test] Use correct executable path to discover resource directory.Volodymyr Sapsai1-5/+10
Driver builds resource directory path based on provided executable path. Instead of string "clang" use actual executable path. rdar://problem/42699514 Reviewers: nathawes, akyrtzi, bob.wilson Reviewed By: akyrtzi Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D50160 llvm-svn: 338741
2018-07-20[Index] Set OrigD before D is changed.Eric Liu1-0/+2
Reviewers: akyrtzi, arphaman Reviewed By: akyrtzi Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49476 llvm-svn: 337529
2018-07-09[Index] Add indexing support for MACROs.Eric Liu1-0/+38
Reviewers: akyrtzi, arphaman, sammccall Reviewed By: sammccall Subscribers: malaperle, sammccall, cfe-commits Differential Revision: https://reviews.llvm.org/D48961 llvm-svn: 336524
2018-06-14[CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2Bruno Cardoso Lopes1-1/+5
On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools installed, we currently get the include path for libxml2 as /usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2. Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when possible. rdar://problem/41103601 llvm-svn: 334747
2018-06-13[libclang] Make c-index-test.c ISO C90 compliant.Matt Morehouse1-1/+1
Fixes a build bot breakage caused by r334593. llvm-svn: 334612
2018-06-13[libclang] Optionally add code completion results for arrow instead of dotIvan Donchevskii1-5/+45
Follow up for D41537 - libclang part. Differential Revision: https://reviews.llvm.org/D46862 llvm-svn: 334593
2018-05-17[libclang] Allow skipping function bodies in preamble onlyIvan Donchevskii1-0/+2
Second attempt. Fix line endings and warning. As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D45815 llvm-svn: 332587
2018-05-17Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815Ivan Donchevskii1-8/+6
Windows line endings. Requires proper resubmission. llvm-svn: 332585
2018-05-17[libclang] Allow skipping function bodies in preamble onlyIvan Donchevskii1-6/+8
As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D45815 llvm-svn: 332578
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-2/+2
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-23[index] Fix methods that take a shared_ptr to just take a reference.Benjamin Kramer1-2/+2
There is no ownership here, passing a shared_ptr just adds confusion. No functionality change intended. llvm-svn: 330595
2018-04-09[Index] Return SourceLocation to consumers, not FileID/Offset pair.Sam McCall1-7/+10
Summary: The FileID/Offset conversion is lossy. The code takes the fileLoc, which loses e.g. the spelling location in some macro cases. Instead, pass the original SourceLocation which preserves all information, and update consumers to match current behavior. This allows us to fix two bugs in clangd that need the spelling location. Reviewers: akyrtzi, arphaman Subscribers: ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D45014 llvm-svn: 329570
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399