summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/tool
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Add path mappings functionalitySam McCall2020-01-071-1/+22
| | | | | | | | | | | | | | | | Summary: Add path mappings to clangd which translate file URIs on inbound and outbound LSP messages. This mapping allows clangd to run in a remote environment (e.g. docker), where the source files and dependencies may be at different locations than the host. See http://lists.llvm.org/pipermail/clangd-dev/2019-January/000231.htm for more. Patch by William Wagner! Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: usaxena95, ormris, mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64305
* [clangd] Shutdown cleanly on signals.Sam McCall2019-11-271-6/+11
| | | | | | | | | | | | | | | | Summary: This avoids leaking PCH files if editors don't use the LSP shutdown protocol. This is one fix for https://github.com/clangd/clangd/issues/209 (Though I think we should *also* be unlinking the files) Reviewers: kadircet, jfb Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70684
* [clangd] Implement cross-file rename.Haojian Wu2019-11-261-0/+11
| | | | | | | | | | | | | | | | | Summary: This is the initial version. The cross-file rename is purely based on the index. It is hidden under a command-line flag, and only available for a small set of symbols. Reviewers: ilya-biryukov, sammccall Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69263
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-251-2/+1
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-261-1/+2
| | | | | | | | | | | | | | 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
* [clangd] abort if shutdown takes more than a minute.Sam McCall2019-10-231-2/+21
| | | | | | | | | | | | | | | | | | | | Summary: A certain class of bug (e.g. infloop on an AST worker thread) currently means clangd never terminates, even if the editor shuts down the protocol and closes our stdin, and the main thread recognizes that. Instead, let's wait 60 seconds for threads to finish cleanly, and then crash if they haven't. (Obviously, we should still fix these bugs). Reviewers: kadircet Subscribers: MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D69329
* [clangd] Add the missing dependency on `clangLex`.Michael Liao2019-10-161-0/+1
| | | | llvm-svn: 375039
* [clang-tools-extra] [cmake] Link against libclang-cpp whenever possibleMichal Gorny2019-10-041-3/+6
| | | | | | | | | Use clang_target_link_libraries() in order to support linking against libclang-cpp instead of static libraries. Differential Revision: https://reviews.llvm.org/D68448 llvm-svn: 373786
* [clangd][NFC] Update background-index command line descriptionKadir Cetinkaya2019-08-291-2/+1
| | | | | | | | | | | | | | | | Summary: We didn't change this in D64019 just in case we revert it back. Deleting it now. Reviewers: hokein, sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66943 llvm-svn: 370367
* [clangd] Fix ExtractFunction dependenciesHeejin Ahn2019-08-281-0/+1
| | | | | | | | | | | | | | Summary: Without these dependencies, builds with `-DBUILD_SHARED_LIBS=ON` fail. Reviewers: SureYeaah Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66910 llvm-svn: 370273
* Remove \brief commands from doxygen comments.Dmitri Gribenko2019-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: 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 [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | 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: 368944
* clangd: use -j for background index poolSam McCall2019-08-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clangd supports a -j option to limit the amount of threads to use for parsing TUs. However, when using -background-index (the default in later versions of clangd), the parallelism used by clangd defaults to the hardware_parallelisn, i.e. number of physical cores. On shared hardware environments, with large projects, this can significantly affect performance with no way to tune it down. This change makes the -j parameter apply equally to parsing and background index. It's not perfect, because the total number of threads is 2x the -j value, which may still be unexpected. But at least this change allows users to prevent clangd using all CPU cores. Reviewers: kadircet, sammccall Reviewed By: sammccall Subscribers: javed.absar, jfb, sammccall, ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66031 llvm-svn: 368498
* [clangd] Expose -offset-encoding=utf-32, which has been implemented for agesSam McCall2019-08-051-1/+3
| | | | llvm-svn: 367812
* [clangd] Provide help text to users who run `clangd` in a terminal.Sam McCall2019-07-251-0/+5
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65201 llvm-svn: 366992
* [clangd] Also accept flags from CLANGD_FLAGS variable.Sam McCall2019-07-251-8/+15
| | | | | | | | | | | | | | | | This simplifies various workflows, particularly in debugging/development. e.g. editors will tend to propagate flags, so you can run `env CLANGD_FLAGS=-input-mirror-file=/tmp/mirror vim foo.cc` rather than change the configuration in a persistent way. (This also gives us a generic lever when we don't know how to customize the flags in some particular LSP client). While here, add a test for this and other startup logging, and fix a couple of direct writes to errs() that should have been logs. Differential Revision: https://reviews.llvm.org/D65153 llvm-svn: 366991
* [clangd] Add categories to help options, and only show clangd options.Sam McCall2019-07-241-190/+232
| | | | | | | | | | | | | | | | | | | Summary: Restricting the categories prevents extra unwanted options from creeping into help (D60663), and removes a bunch of noise from --help-hidden. While here, remove `static` from the opts in favor of an anon namespace, to reduce the noise level. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65200 llvm-svn: 366900
* [clangd] Reformat use of cl::opt: use unqualified name and don't bin-pack ↵Sam McCall2019-07-241-175/+225
| | | | | | | | | | | | | | attributes. NFC Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65154 llvm-svn: 366880
* [clangd] Log version, cwd, args, and transport on startup. NFCSam McCall2019-07-231-0/+13
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65146 llvm-svn: 366811
* [clangd] Disable background-index on lit-tests by defaultKadir Cetinkaya2019-07-191-1/+5
| | | | | | | | | | | | | | | | Summary: Since background-index can perform disk writes, we don't want to turn it on tests that won't clear it. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64990 llvm-svn: 366575
* [clangd] Don't run the prepare for tweaks that are disabled.Haojian Wu2019-07-121-6/+8
| | | | | | | | | | | | | | Summary: Previously, we ran the prepare, even for the tweaks that are disabled. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64565 llvm-svn: 365882
* [clangd] Add priorities to background index queue, extract to separate classSam McCall2019-07-111-1/+1
| | | | | | | | | | | | Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64560 llvm-svn: 365773
* [clangd] Rewrite of logic to rebuild the background index serving structures.Sam McCall2019-07-091-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously it was rebuilding every 5s by default, which was much too frequent in the long run - the goal was to provide an early build. There were also some bugs. There were also some bugs, and a dedicated thread was used in production but not tested. - rebuilds are triggered by #TUs built, rather than time. This should scale more sensibly to fast vs slow machines. - there are two separate indexed-TU thresholds to trigger index build: 5 TUs for the first build, 100 for subsequent rebuilds. - rebuild is always done on the regular indexing threads, and is affected by blockUntilIdle. This means unit/lit tests run the production configuration. - fixed a bug where we'd rebuild after attempting to load shards, even if there were no shards. - the BackgroundIndexTests don't really test the subtleties of the rebuild policy (for determinism, we call blockUntilIdle, so rebuild-on-idle is enough to pass the tests). Instead, we expose the rebuilder as a separate class and have fine-grained tests for it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64291 llvm-svn: 365531
* [clangd] Use -completion-style=bundled by default if signature help is availableSam McCall2019-07-081-3/+3
| | | | | | | | | | | | | | | | Summary: I didn't manage to find something nicer than optional<bool>, but at least I found a sneakier comment. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64216 llvm-svn: 365356
* [clangd] Mark a couple of unimportant flags as hidden. NFCSam McCall2019-07-041-2/+3
| | | | llvm-svn: 365151
* [clangd] Turn background-index on by defaultKadir Cetinkaya2019-07-041-1/+1
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64019 llvm-svn: 365124
* Summary: [Clangd] Added hidden command line option -tweaks to specify which ↵Shaurya Gupta2019-07-011-0/+11
| | | | | | | | | | | | | | | | tweaks to enable - Only for development purposes - Disabled tweaks in fixits-duplications test Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63989 llvm-svn: 364809
* [clangd] Enable extraction of system includes from custom toolchainsKadir Cetinkaya2019-06-261-0/+10
| | | | | | | | | | | | | | | | | | Summary: Some custom toolchains come with their own header files and compiler drivers. Those compiler drivers implicitly know about include search path for those headers. This patch aims to extract that information from drivers and add it to the command line when invoking clang frontend. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62804 llvm-svn: 364389
* [clangd] Link and initialize target infosKadir Cetinkaya2019-06-261-0/+2
| | | | llvm-svn: 364387
* [clangd] Collect tokens of main files when building the ASTIlya Biryukov2019-06-191-0/+1
| | | | | | | | | | | | | | | | | | | | Summary: The first use of this is a code tweak to expand macro calls. Will later be used to build syntax trees. The memory overhead is small as we only store tokens of the main file. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62956 llvm-svn: 363803
* [clangd] Add hidden tweaks to dump AST/selection.Sam McCall2019-06-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: This introduces a few new concepts: - tweaks have an Intent (they don't all advertise as refactorings) - tweaks may produce messages (for ShowMessage notification). Generalized Replacements -> Effect. - tweaks (and other features) may be hidden (clangd -hidden-features flag). We may choose to promote these one day. I'm not sure they're worth their own feature flags though. Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62538 llvm-svn: 363680
* [clangd] Remove old hidden -use-dex-index flagSam McCall2019-06-101-6/+0
| | | | llvm-svn: 362978
* [clangd] Fix a crash when clang-tidy is disabledIlya Biryukov2019-06-041-7/+7
| | | | llvm-svn: 362469
* [clangd] Never end command-line flag description with a period. NFCIlya Biryukov2019-05-281-20/+20
| | | | | | | For consistency. Not having a period at the end is much more common and seems to be the preferred style for command-line options. llvm-svn: 361800
* [clangd] Rename -run-synchronously to -syncIlya Biryukov2019-05-281-16/+15
| | | | llvm-svn: 361798
* [clangd] improve help message for limit-resultsKadir Cetinkaya2019-05-221-1/+1
| | | | | | | | | | | | | | | | | | Summary: Make it clear that the default is 100. Patch by Brennan Vincent(@umanwizard)! Reviewers: #clang-tools-extra, kadircet Reviewed By: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61865 llvm-svn: 361388
* [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag ↵Sam McCall2019-05-211-8/+13
| | | | | | | | | | | | | | to force it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62135 llvm-svn: 361258
* [clangd] Make it possible to use VFS from parsing for getting tidy optionsIlya Biryukov2019-05-201-2/+12
| | | | | | | | | | | | | | | | | | | Summary: To give an option for clangd embedders with snapshotted filesystem to read config files from exact snapshots, possibly loosing some performance from caching capabilities of the current implementations. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62143 llvm-svn: 361178
* [clangd] Support -fallback-style, similar to clang-format.Sam McCall2019-05-061-0/+9
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61519 llvm-svn: 360016
* [clangd] Use llvm::set_thread_priority in background-indexKadir Cetinkaya2019-04-181-1/+3
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: krytarowski, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60865 llvm-svn: 358664
* [clangd] Log verbosely (LSP bodies) in lit tests. NFCSam McCall2019-04-181-1/+2
| | | | llvm-svn: 358655
* [clangd] Enable clang-tidy by default.Haojian Wu2019-04-121-1/+1
| | | | | | | | | | | | | | | | | | | Summary: We have turned on the flag internally for a while, and we don't receive complains. Should be good to turn it on now. If the projects doesn't have .clang-tidy files, no clang-tidy check will be run. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60560 llvm-svn: 358282
* [clangd] Add -header-insertion=never flag to disable include insertion in ↵Sam McCall2019-04-101-1/+17
| | | | | | | | | | | | | | | | code completion Summary: One clear use case: use with an editor that reacts poorly to edits above the cursor. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60409 llvm-svn: 358075
* [clangd] Add fallback mode for code completion when compile command or ↵Eric Liu2019-04-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | preamble is not ready. Summary: When calling TUScehduler::runWithPreamble (e.g. in code compleiton), allow entering a fallback mode when compile command or preamble is not ready, instead of waiting. This allows clangd to perform naive code completion e.g. using identifiers in the current file or symbols in the index. This patch simply returns empty result for code completion in fallback mode. Identifier-based plus more advanced index-based completion will be added in followup patches. Reviewers: ilya-biryukov, sammccall Reviewed By: sammccall Subscribers: sammccall, javed.absar, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59811 llvm-svn: 357916
* [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extensionSam McCall2019-03-271-1/+17
| | | | | | | | | | | | | | | | Summary: Still some pieces to go here: unit tests for new SourceCode functionality and a command-line flag to force utf-8 mode. But wanted to get early feedback. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58275 llvm-svn: 357102
* [clangd] Enable SuggestMissingIncludes by default.Eric Liu2019-03-011-1/+1
| | | | | | | | | | | | | | Summary: This seems to work stably now. Turn on by default. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58772 llvm-svn: 355200
* [clangd] Fix a typo. NFCIlya Biryukov2019-02-201-1/+1
| | | | | | | The documentation for -index-file mentioned clang-index instead of clangd-indexer. llvm-svn: 354456
* [clangd] Use Dex for dynamic index by default.Eric Liu2019-02-071-1/+1
| | | | | | | | | | | | | | | | | Summary: Memory usage for a sample TU: Without Dex: 17.9M With Dex: 24.4M The memory increase is considerable but seems tolerable. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57878 llvm-svn: 353413
* [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.Haojian Wu2019-02-061-9/+18
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57746 llvm-svn: 353284
* [clangd] Fix -DBUILD_SHARED_LIBS=ON build - SwapIfBranches needs clangAST.Roman Lebedev2019-02-011-0/+1
| | | | | | | | | | | | | | | Else, fails with: [1/2] Linking CXX executable bin/clangd FAILED: bin/clangd : && /usr/bin/g++ -pipe -O2 -g0 -UNDEBUG -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pipe -O2 -g0 -UNDEBUG -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o -o bin/clangd -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.so.9svn -lpthread lib/libclangBasic.so.9svn lib/libclangTidy.so.9svn lib/libclangDaemon.so.9svn lib/libclangFormat.so.9svn lib/libclangFrontend.so.9svn lib/libclangSema.so.9svn lib/libclangTooling.so.9svn lib/libclangToolingCore.so.9svn && : ld.lld: error: undefined symbol: clang::FunctionDecl::getBody(clang::FunctionDecl const*&) const >>> referenced by SwapIfBranches.cpp >>> tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o:(clang::FunctionDecl::getBody() const) and so on. llvm-svn: 352841
OpenPOWER on IntegriCloud