Commit Graph

4588 Commits

Author SHA1 Message Date
Hyrum Wright 4199a73cee [clang-tidy] Add additional patterns to the abseil-duration-unnecessary-conversion check.
Differential Revision: https://reviews.llvm.org/D59183

llvm-svn: 356141
2019-03-14 13:38:16 +00:00
Haojian Wu 7f51b5dc32 [clangd] Using symbol name to map includes for STL symbols.
Summary:
Using suffix path mapping relies on the STL implementations, and it is
not portable. This patch is using symbol name mapping, which should
work with different STL implementations, fix clangd/clangd#9.

To generate the symbol mapping, we parse the cppreference symbol index
page to build a lookup table.

The mapping is not completed, a few TODOs:
  - support symbols from different headers (e.g. std::move)
  - support STL macros
  - support symbols from std's sub-namespaces (e.g. chrono)

Reviewers: ioeric, jfb, serge-sans-paille

Reviewed By: ioeric

Subscribers: sammccall, klimek, ilya-biryukov, ioeric, MaskRay, jkorous, mgrang, arphaman, kadircet, jfb, jdoerfert, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D58345

llvm-svn: 356134
2019-03-14 11:25:26 +00:00
Haojian Wu 1f28a4a17f [clangd] Fix an out-of-date FIXME, NFC.
llvm-svn: 356127
2019-03-14 10:01:07 +00:00
Haojian Wu 7ce0d6cc33 [clangd] Build Dex index after loading all shards in BackgroundIndex.
Summary:
Currently after loadding all shards, we use MemIndex which has poor query
performance, we should use Dex.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59350

llvm-svn: 356126
2019-03-14 09:57:10 +00:00
Kadir Cetinkaya d9c174648e [clangd] Store explicit template specializations in index for code navigation purposes
Summary:
This introduces ~4k new symbols, and ~10k refs for LLVM. We need that
information for providing better code navigation support:
- When references for a class template is requested, we should return these specializations as well.
- When children of a specialization is requested, we should be able to query for those symbols(instead of just class template)

Number of symbols: 378574 -> 382784
Number of refs: 5098857 -> 5110689

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

Subscribers: nridge, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59083

llvm-svn: 356125
2019-03-14 08:35:17 +00:00
Haojian Wu 529bdcd7ce [clangd] Fix a typo in doc.
llvm-svn: 356055
2019-03-13 15:22:31 +00:00
Kadir Cetinkaya 3d8e289f71 [clangd] Default initialize SymInfo
llvm-svn: 356032
2019-03-13 08:42:15 +00:00
Paul Hoad d74c055fe6 Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present"
This reverts commit b358cbb9b78389e20f7be36e1a98e26515c3ecce.

llvm-svn: 356030
2019-03-13 08:15:03 +00:00
Paul Hoad 6d294f28e9 [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present
Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
    if(true) var++;
    else  {
        var--;
    }
```

is reformatted to be

```
  if (true)
    var++;
  else {
    var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

llvm-svn: 356029
2019-03-13 08:07:46 +00:00
Haojian Wu 42810363de [clang-tidy] NOLINT support for "clang-diagnostic-*".
Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59255

llvm-svn: 355934
2019-03-12 16:11:46 +00:00
Hyrum Wright 1603447b03 [clang-tidy] Add the abseil-time-compare check
This is an analog of the abseil-duration-comparison check, but for the
absl::Time domain. It has a similar implementation and tests.

Differential Revision: https://reviews.llvm.org/D58977

llvm-svn: 355835
2019-03-11 16:47:45 +00:00
Kadir Cetinkaya a7cdfd9cb5 [clangd] Respect Origin option in createStaticIndexingAction
Summary:
Currently createStaticIndexingAction always set Origin to Static, which
makes it hard to change it later on by different indexers(One needs to go over
each symbol making a new copy).

This patch changes that behavior to rather respect it if set by user.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59205

llvm-svn: 355820
2019-03-11 11:01:14 +00:00
Haojian Wu 5bca7ff98a [clangd] Add TOC section to clangd doc.
Reviewers: gribozavr

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59132

llvm-svn: 355811
2019-03-11 08:45:56 +00:00
Hyrum Wright 8172a0a5f4 [clang-tidy] NFC: Negate the name and semantics of the isNotInMacro function.
This function is always used in a context where its result was also
negated, which made for confusing naming and code.

llvm-svn: 355702
2019-03-08 15:37:15 +00:00
Kadir Cetinkaya 890dfddef0 [clangd] Remove ./ and ../ in the file paths
Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59084

llvm-svn: 355681
2019-03-08 09:57:33 +00:00
Haojian Wu f07a3fd500 [clangd] Redirect clangd page.
Reviewers: gribozavr

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59128

llvm-svn: 355680
2019-03-08 09:56:42 +00:00
Kadir Cetinkaya 017cc6c190 [clangd] Make sure constructors do not reference class
Reviewers: gribozavr

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58815

llvm-svn: 355679
2019-03-08 09:54:37 +00:00
Haojian Wu f334231176 [clangd] Deduplicate Refs on the fly.
Summary:
Currently, we only do deduplication when we flush final results. We may
have huge duplications (refs from headers) during the indexing period (running
clangd-indexer on Chromium).

With this change, clangd-indexer can index the whole chromium projects
(48 threads, 40 GB peak memory usage).

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59092

llvm-svn: 355676
2019-03-08 09:26:30 +00:00
Kadir Cetinkaya 65944ab50d [clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.

This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.

Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).

Reviewers: gribozavr, hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59086

llvm-svn: 355669
2019-03-08 08:38:25 +00:00
Haojian Wu ea18b36a6d [clangd] Strip plugin arguments in clangd-indexer.
Summary: This would allow clangd-indexer runs on chromium repo.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59022

llvm-svn: 355599
2019-03-07 14:47:17 +00:00
Haojian Wu 24a8f1ccb9 [clangd] Add Source to clangd::Diagnostic.
Summary:
clangd embedder can distinguish diagnostics from clang or clang-tidy.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58600

llvm-svn: 355493
2019-03-06 10:51:38 +00:00
Alexander Kornienko 401997db92 [clang-tidy] Fix bugprone-string-constructor crash
llvm-svn: 355401
2019-03-05 14:09:57 +00:00
Shoaib Meenai 5be71faf4b [build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

Differential Revision: https://reviews.llvm.org/D58791

llvm-svn: 355340
2019-03-04 21:19:53 +00:00
Eric Liu 9f7a767a81 [clangd] Enable SuggestMissingIncludes by default.
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
2019-03-01 14:17:55 +00:00
Fangrui Song ffe9f00cfe Fix file headers. NFC
llvm-svn: 355188
2019-03-01 09:52:53 +00:00
Paul Hoad 68f5e5456f [clang-tidy] add OverrideMacro to modernize-use-override check
Summary:
The usefulness of **modernize-use-override** can be reduced if you have to live in an environment where you support multiple compilers, some of which sadly are not yet fully C++11 compliant

some codebases have to use override as a macro OVERRIDE e.g.

```
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
```

This allows code to be compiled with C++11 compliant compilers and get warnings and errors that clang, MSVC,gcc can give, while still allowing other legacy pre C++11 compilers to compile the code. This can be an important step towards modernizing C++ code whilst living in a legacy codebase.

When it comes to clang tidy, the use of the **modernize-use-override** is one of the most useful checks, but the messages reported are inaccurate for that codebase if the standard approach is to use the macros OVERRIDE and/or FINAL.

When combined with fix-its that introduce the C++11 override keyword, they become fatal, resulting in the modernize-use-override check being turned off to prevent the introduction of such errors.

This revision, allows the possibility for the replacement **override **to be a macro instead, Allowing the clang-tidy check to be run on  both pre and post C++11 code, and allowing fix-its to be applied.

Reviewers: alexfh, JonasToth, hokein, Eugene.Zelenko, aaron.ballman

Reviewed By: alexfh, JonasToth

Subscribers: lewmpk, malcolm.parsons, jdoerfert, xazax.hun, cfe-commits, llvm-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D57087

llvm-svn: 355132
2019-02-28 20:00:48 +00:00
Jonas Toth ab10947b34 [clang-tidy] fix documentation link in list of clang-tidy checks
llvm-svn: 355108
2019-02-28 17:53:51 +00:00
Jonas Toth 5fbeff797a [clang-tidy] redirection in list of checks adjusted
llvm-svn: 355102
2019-02-28 15:56:40 +00:00
Jonas Toth ed571d77d2 [clang-tidy] include cppcoreguidelines-explicit-virtual-functions in list of checks and fix redirection
llvm-svn: 355100
2019-02-28 15:47:10 +00:00
Jonas Toth 3a24cb00eb [clang-tidy] documentation fixing the actual correct file
llvm-svn: 355098
2019-02-28 15:39:47 +00:00
Jonas Toth eae176f142 [clang-tidy] tryfix documenation continued
llvm-svn: 355097
2019-02-28 15:28:36 +00:00
Jonas Toth df58719979 [clang-tidy] another issue in documentation, double empty line seemed to confuse code-block
llvm-svn: 355095
2019-02-28 15:18:54 +00:00
Jonas Toth 0023b130cf [clang-tidy] attempt to fix documentation build-error
llvm-svn: 355094
2019-02-28 15:01:17 +00:00
Jonas Toth da666233fe [clang-tidy] added cppcoreguidelines-explicit-virtual-functions
Addresses the bugzilla bug #30397. (https://bugs.llvm.org/show_bug.cgi?id=30397)
modernize-use-override suggests that destructors require the override specifier
and the CPP core guidelines do not recommend this.

Patch by lewmpk.

Differential Revision: https://reviews.llvm.org/D58731

llvm-svn: 355093
2019-02-28 14:55:12 +00:00
Dmitri Gribenko 2098b86b96 Added missing license headers
Reviewers: ioeric

Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58781

llvm-svn: 355092
2019-02-28 14:01:11 +00:00
Dmitri Gribenko 7344188b72 Use ArrayRef::copy, instead of copying data manually
Reviewers: ioeric

Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58782

llvm-svn: 355091
2019-02-28 14:00:26 +00:00
Dmitri Gribenko cb83ea6274 Moved Ref into its own header and implementation file
Reviewers: ioeric

Subscribers: mgorny, jkorous, mgrang, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58778

llvm-svn: 355090
2019-02-28 13:49:25 +00:00
Clement Courbet 58724a61ac [clang-tidy] bugprone-string-integer-assignment: Reduce false positives.
Summary: Detect a few expressions as likely character expressions, see PR27723.

Reviewers: xazax.hun, alexfh

Subscribers: rnkovacs, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58609

llvm-svn: 355089
2019-02-28 13:39:01 +00:00
Dmitri Gribenko 08b49b5338 Moved Symbol into its own header and implementation file
Reviewers: ioeric

Subscribers: mgorny, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58774

llvm-svn: 355088
2019-02-28 13:23:03 +00:00
Dmitri Gribenko dba22a3908 Moved SymbolOrigin into its own header and implementation file
Reviewers: ioeric

Subscribers: mgorny, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58773

llvm-svn: 355086
2019-02-28 12:31:49 +00:00
Dmitri Gribenko 5306a71480 Moved SymbolLocation into its own header and implementation file
Reviewers: ioeric

Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58768

llvm-svn: 355082
2019-02-28 11:02:01 +00:00
Dmitri Gribenko ed2539a608 Moved DenseMap support for SymbolID into SymbolID.h
llvm-svn: 355081
2019-02-28 11:00:44 +00:00
Clement Courbet ff5e4bcad0 [clang-tidy] misc-string-integer-assignment: fix false positive
Summary:
using CodePoint = uint32_t;
CodePoint cp;
basic_string<CodePoint> s;
s += cp;

See PR27723.

Reviewers: xazax.hun, alexfh

Subscribers: rnkovacs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58606

llvm-svn: 355076
2019-02-28 10:33:32 +00:00
Hyrum Wright c526e02668 [clang-tidy] Add the abseil-time-subtraction check
Differential Revision: https://reviews.llvm.org/D58137

llvm-svn: 355024
2019-02-27 20:08:50 +00:00
Dmitri Gribenko 5d58625e05 Added documentation for clangd v9+ features
Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58717

llvm-svn: 354994
2019-02-27 16:08:04 +00:00
Dmitri Gribenko 47e6241ac4 Added more detailed documentation for clangd
Summary:
The text was written mostly by Sam McCall, screenshots are mostly made
by me.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58710

llvm-svn: 354992
2019-02-27 15:53:05 +00:00
Eric Liu e98b86cbe8 [clangd] Improve global code completion when scope specifier is unresolved.
Summary:
Suppose `clangd::` is unresolved in the following example. Currently,
we simply use "clangd::" as the query scope. We can do better by combining with
accessible scopes in the context. The query scopes can be `{clangd::, clang::clangd::}`.
```
namespace clang { clangd::^ }

```

Reviewers: ilya-biryukov, sammccall, hokein, kadircet

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58448

llvm-svn: 354963
2019-02-27 11:42:37 +00:00
Ilya Biryukov 8e19a65040 [clangd] Set thread priority on Windows
Reviewers: kadircet, gribozavr

Reviewed By: kadircet, gribozavr

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58683

llvm-svn: 354957
2019-02-27 10:16:03 +00:00
Jan Korous cba6eda155 [clangd] Library dependencies in XPC
Patch by Nicholas Allegra

Differential Revision: https://reviews.llvm.org/D58089

llvm-svn: 354949
2019-02-27 02:37:44 +00:00
Jonas Toth c1e8cbd5c3 [clang-tidy] undo bitfields in ExceptionAnalyzer
Scoped enums do induce some problems with some MSVC and GCC versions
if used as bitfields. Therefor this is deactivated for now.

llvm-svn: 354903
2019-02-26 18:15:17 +00:00
Kadir Cetinkaya 60ec08f067 [clangd] Index UsingDecls
Summary:
D58340 enables indexing of USRs, this makes sure test in clangd are
aligned with the change

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58341

llvm-svn: 354879
2019-02-26 14:23:47 +00:00
Kadir Cetinkaya 8335fd1923 [clangd] Update docs to mention YCM integration and new LSP features
Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56718

llvm-svn: 354865
2019-02-26 11:08:04 +00:00
Haojian Wu da79dcc317 [clangd] Drop documentation in static index if symbols are not indexed for completion.
Summary:
This is a further optimization of r350803, we drop docs in static index for
symbols not being indexed for completion, while keeping the docs in dynamic
index (we rely on dynamic index to get docs for class members).

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56539

llvm-svn: 354792
2019-02-25 16:00:00 +00:00
Dmitri Gribenko a06e029081 Moved clangd docs to a separate directory in preparation to restructure them into multiple files
Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58607

llvm-svn: 354786
2019-02-25 13:43:48 +00:00
Clement Courbet 4bfa716f7c [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower
Summary: Tis represents ~20% of false positives. See PR27723.

Reviewers: xazax.hun, alexfh

Subscribers: rnkovacs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58604

llvm-svn: 354780
2019-02-25 13:09:02 +00:00
Dmitri Gribenko cfa0d7a358 Updated the documentation build instructions for the current CMake build system
Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58603

llvm-svn: 354779
2019-02-25 13:03:44 +00:00
Dmitri Gribenko 52bb45f03f Fixed grammar in index.rst
Subscribers: arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58601

llvm-svn: 354778
2019-02-25 12:49:27 +00:00
Dmitri Gribenko a7aac27aaf Removed an unhelpful comment in index.rst
Reviewers: ilya-biryukov

Subscribers: arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58602

llvm-svn: 354777
2019-02-25 12:48:52 +00:00
Kadir Cetinkaya f47177ddb4 [clangd] Add thread priority lowering for MacOS as well
Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58492

llvm-svn: 354765
2019-02-25 09:19:26 +00:00
Marc-Andre Laperle 25e690273a [clangd] Enhance macro hover to see full definition
Summary: Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>

Reviewers: simark, ilya-biryukov, sammccall, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D55250

llvm-svn: 354761
2019-02-24 23:47:03 +00:00
Haojian Wu c8f7496257 [clangd] Don't attach FixIt to the source code in macro.
Summary:
We are less certain it is the correct fix. Also, clang doesn't apply FixIt to
the source code in macro.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58525

llvm-svn: 354664
2019-02-22 09:43:56 +00:00
Kadir Cetinkaya 748211a81f [clangd] Only report explicitly typed symbols during code navigation
Summary:
Clangd was reporting implicit symbols, like results of implicit cast
expressions during code navigation, which is not desired. For example:

```
struct Foo{ Foo(int); };
void bar(Foo);
vod foo() {
  int x;
  bar(^x);
}
```
Performing a GoTo on the point specified by ^ would give two results one
pointing to line `int x` and the other for definition of `Foo(int);`

Reviewers: ilya-biryukov, sammccall

Subscribers: ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58495

llvm-svn: 354585
2019-02-21 14:48:33 +00:00
Kadir Cetinkaya 84b584be62 [clangd] Enable indexing of template type parameters
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36285

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58294

llvm-svn: 354561
2019-02-21 09:55:00 +00:00
Eric Liu 4971436b21 [clangd] Handle another incomplete-type diagnostic case in IncludeFixer.
llvm-svn: 354558
2019-02-21 09:33:49 +00:00
Douglas Yung 38dd1b3726 Attempt to fix VS2015 build breakage from r354517. NFCI.
llvm-svn: 354545
2019-02-21 04:55:31 +00:00
Stephane Moore 3eea706e3e [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈
Summary:
Implicit functions are outside the control of source authors and should
be exempt from style restrictions.

Tested via running clang tools tests.

This is an amended followup to https://reviews.llvm.org/D57207

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jdoerfert, xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58095

llvm-svn: 354534
2019-02-21 00:34:01 +00:00
Jonas Toth 32d5b252b9 [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer
Summary:
The analsis on the throwing behvaiour on functions and statements gave only
a binary answer whether an exception could occur and if yes which types are
thrown.
This refactoring allows keeping track if there is a unknown factor, because the
code calls to some functions with unavailable source code with no `noexcept`
information.
This 'potential Unknown' information is propagated properly and can be queried
separately.

Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh

Reviewed By: lebedev.ri, baloghadamsoftware

Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57883

llvm-svn: 354517
2019-02-20 21:04:36 +00:00
Ilya Biryukov fc83aea6a9 [clangd] Fix a crash in Selection
Summary:
The assertion checking that a range of a node is a token range does
not hold in case of "split" tokens, e.g. between two closing template
argument lists (`vector<vector<int>>`).

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58447

llvm-svn: 354507
2019-02-20 19:26:39 +00:00
Ilya Biryukov 2754942cba [clangd] Store index in '.clangd/index' instead of '.clangd-index'
Summary: To take up the .clangd folder for other potential uses in the future.

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58440

llvm-svn: 354505
2019-02-20 19:08:06 +00:00
Yan Zhang 19bceda879 Update property prefix regex to allow numbers.
Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D56896

llvm-svn: 354485
2019-02-20 17:32:41 +00:00
Ilya Biryukov 97ed3c1e47 [clangd] Fix a typo. NFC
The documentation for -index-file mentioned clang-index instead of
clangd-indexer.

llvm-svn: 354456
2019-02-20 12:31:44 +00:00
Kadir Cetinkaya 592e7c9b0e [clangd] Revert r354442 and r354444
Looks like sysroot is only working on linux.

llvm-svn: 354453
2019-02-20 11:45:20 +00:00
Kadir Cetinkaya 60ba9b4460 [clangd] Try to fix windows build bots
llvm-svn: 354444
2019-02-20 10:32:04 +00:00
Kadir Cetinkaya 30d340839c [clangd] Testcase for bug 39811
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58133

llvm-svn: 354442
2019-02-20 09:41:26 +00:00
Ilya Biryukov 93dfb45256 [clangd] Add an option in the code to not display number of fixes
Summary:
Only to the APIs, which are used by our embedders.
We do not plan to add a user-facing option for this.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58387

llvm-svn: 354349
2019-02-19 16:50:37 +00:00
Eric Liu 4df070a5e3 [clangd] Handle unresolved scope specifier when fixing includes.
Summary:
In the following examples, "clangd" is unresolved, and the fixer will try to fix
include for `clang::clangd`; however, clang::clangd::X is usually intended. So
when handling a qualifier that is unresolved, we change the unresolved name and
scopes so that the fixer will fix "clang::clangd::X" in the following example.
```
  namespace clang {
  	clangd::X
	~~~~~~
  }
  // or
  clang::clangd::X
         ~~~~~~
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58185

llvm-svn: 354330
2019-02-19 14:32:22 +00:00
Kadir Cetinkaya 9b4db445ce [clangd] Add tests for template specializations
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58190

llvm-svn: 354272
2019-02-18 14:23:19 +00:00
Eric Liu b355802910 [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.
Summary:
Multiple diagnostics can be caused by the same unresolved name or incomplete type,
especially if the code is copy-pasted without #includes. The cache can avoid making
repetitive index requests, and thus reduce latency and allow more diagnostics to be
fixed (we limit the number of index requests for each parse).

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58239

llvm-svn: 354268
2019-02-18 13:12:10 +00:00
Alexander Kornienko 958837c640 [clang-tidy] Fix links in docs.
llvm-svn: 354266
2019-02-18 12:50:35 +00:00
Bruno Ricci b73b5cda62 [clang-tidy][NFCI] DanglingHandleCheck: Remove a superflous IgnoreParenImpCasts
ExprWithCleanups is currently not skipped by IgnoreParenImpCasts, but is skipped
by IgnoreImpCasts. In view of fixing this inconsistency in D57267, remove the
IgnoreParenImpCasts between the ReturnStmt and the ExprWithCleanups which
is not needed since ExprWithCleanups is always created as a direct child of
ReturnStmt (by inspection of each ReturnStmt::Create in Sema/SemaStmt.cpp).

NFC intended.

llvm-svn: 354228
2019-02-17 18:21:54 +00:00
Stephane Moore 358f99c7fe [clang-tidy] Delete obsolete objc-property-declaration options ✂️
Summary:
The Acronyms and IncludeDefaultAcronyms options were deprecated in
https://reviews.llvm.org/D51832. These options can be removed.

Tested by running the clang-tidy tests.

This is an amended resubmission of https://reviews.llvm.org/D56945.

Reviewers: Eugene.Zelenko, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57080

llvm-svn: 354195
2019-02-16 04:27:12 +00:00
Sam McCall 0446b40b63 [clangd] Unlink VFS working dir from OS working dir. Reland of r351051
llvm-svn: 354116
2019-02-15 11:04:25 +00:00
Volodymyr Sapsai 8b982cb8a9 [clang-tidy] Mention language version in test explicitly.
"modernize-use-using" check is applicable only to C++11 and later. Spell it out
to avoid relying on default language version.

rdar://problem/47932196

llvm-svn: 354069
2019-02-14 22:37:30 +00:00
Eric Liu da2ed56fea [clangd] Handle a few more diag kinds in include fixer.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58135

llvm-svn: 353926
2019-02-13 08:58:54 +00:00
Kadir Cetinkaya 87731440d4 [clangd] Fix a lit-test.
Summary:
Fixes https://bugs.llvm.org/show_bug.cgi?id=40593.
Non-percent-encoded chars doesn't cause any problems on the input-side since we
assume everything after authority section is data and don't interpret them as
delimeters.

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58126

llvm-svn: 353857
2019-02-12 16:54:47 +00:00
Sam McCall 905438a4b5 [clangd] Fix use-after-free in XRefs
llvm-svn: 353821
2019-02-12 10:38:45 +00:00
Francis Visoiu Mistrih 1608c12027 [NFC][clangd] Remove unused lambda capture
Avoid this warning:

llvm/clang-tools-extra/clangd/ClangdServer.cpp:365:23: warning: lambda
capture 'this' is not used [-Wunused-lambda-capture]

  auto Action = [Sel, this](decltype(CB) CB, std::string File,
                    ~~^~~~
1 warning generated.

llvm-svn: 353760
2019-02-11 22:36:47 +00:00
Haojian Wu e64ee7c645 Revamp the "[clangd] Format tweak's replacements"
Summary:
This patch contains two parts:

1) reverts commit r353306.
2) move the format logic out from tweaks, keep tweaks API unchanged.

Reviewers: sammccall, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58051

llvm-svn: 353712
2019-02-11 15:18:11 +00:00
Eric Liu d11fbf523d [clangd] Prefer location from codegen files when merging symbols.
Summary:
For example, if an index symbol has location in a .proto file and an AST symbol
has location in a generated .proto.h file, then we prefer location in .proto
which is more meaningful to users.

Also use `mergeSymbols` to get the preferred location between AST location and index location in go-to-def.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58037

llvm-svn: 353708
2019-02-11 15:05:29 +00:00
Kadir Cetinkaya 429022995b [clangd] Index parameters in function decls
Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57950

llvm-svn: 353696
2019-02-11 13:03:08 +00:00
Kadir Cetinkaya cf13bfee00 [clangd] Fix broken windows build bots.
llvm-svn: 353694
2019-02-11 13:01:47 +00:00
Kadir Cetinkaya db7fbcb038 [clangd] Make system header mappings available for PreambleParsedCallback
Summary:
SystemHeaderMappings were added only after takeIncludes call, which
resulted in getting mapping on main file ast updates but not on preamble ast
updates.
Fixes https://github.com/clangd/clangd/issues/8

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58029

llvm-svn: 353687
2019-02-11 10:31:13 +00:00
Malcolm Parsons 297b6a2b6e [clang-tidy] Don't use assignment for value-initialized enums
Summary:
The modernize-use-default-member-init check crashes when trying to
create an assignment value for a value-initialized enum because it isn't a
BuiltinType.
An enum cannot be initialized by assigning 0 to it unless a cast is added.
It could be initialized with an enumerator with the value 0, but there might not
be one.
Avoid these issues by ignoring the UseAssignment setting for value-initialized
enums.

Fixes PR35050.

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57852

llvm-svn: 353554
2019-02-08 19:44:42 +00:00
Paul Hoad 6bfd721571 [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals
bugprone-argument-comment only supports identifying those comments which do not match the function parameter name

This revision add 3 options to adding missing argument comments to literals (granularity on type is added to control verbosity of fixit)

```
CheckOptions:
  - key:             bugprone-argument-comment.CommentBoolLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentFloatLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentIntegerLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentStringLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentCharacterLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentUserDefinedLiterals
    value:           '1'
  - key:             bugprone-argument-comment.CommentNullPtrs
    value:           '1'
```

After applying these options, literal arguments will be preceded with /*ParameterName=*/

Reviewers: JonasToth, Eugene.Zelenko, alexfh, hokein, aaron.ballman

Reviewed By: aaron.ballman, Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D57674

llvm-svn: 353535
2019-02-08 17:00:01 +00:00
Yitzhak Mandelbaum f6be5573dc [clang-tidy][NFC] Fix typo.
Fix placement of comma from previous (test) commit.

llvm-svn: 353525
2019-02-08 15:05:57 +00:00
Yitzhak Mandelbaum 01d6bfc94d [clang-tidy][NFC] Test commit. Add missing comma.
llvm-svn: 353523
2019-02-08 14:57:22 +00:00
Eric Liu 37b45dc22c [clangd] Fix an assertion in TypoCorrection.
Summary: https://github.com/clangd/clangd/issues/7

Reviewers: sammccall, hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57944

llvm-svn: 353514
2019-02-08 13:27:47 +00:00
Kadir Cetinkaya b88144e4ba [clangd] Mention indexing in docs.
Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57392

llvm-svn: 353423
2019-02-07 16:10:39 +00:00
Kadir Cetinkaya ee23633eab [clangd] Reduce number of threads used by BackgroundIndex to number of physical cores.
Summary:
clangd is using as many threads as logical cores for BackgroundIndex
by default. We observed that it increases latency of foreground tasks.

This patch aims to change that default to number of physical cores to get rid of
that extra latency.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57819

llvm-svn: 353422
2019-02-07 16:04:30 +00:00
Haojian Wu ddd64a4f50 [clangd] Fix an assertion failure in Selection.
Summary:
The assertion is triggered when the Decl is null.

Details for the assertion:

F0207 09:55:09.069385   47308 logging.cc:84] assert.h assertion failed at llvm/include/llvm/Support/Casting.h:105 in static bool llvm::isa_impl_cl<clang::TranslationUnitDecl, const clang::      Decl *>::doit(const From *) [To = clang::TranslationUnitDecl, From = const clang::Decl *]: Val && "isa<> used on a null pointer"
 15 *** Check failure stack trace: ***
 19     @     0x55615c1f7e06  __assert_fail
 20     @     0x55615a6297d8  clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
 21     @     0x55615a62f48d  clang::RecursiveASTVisitor<>::TraverseTemplateTemplateParmDecl()
 22     @     0x55615a62b264  clang::RecursiveASTVisitor<>::TraverseDecl()
 23     @     0x55615a62979c  clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
 24     @     0x55615a63060c  clang::RecursiveASTVisitor<>::TraverseClassTemplatePartialSpecializationDecl()
 25     @     0x55615a62ae45  clang::RecursiveASTVisitor<>::TraverseDecl()

Reviewers: sammccall

Subscribers: javed.absar, kristof.beyls, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57879

llvm-svn: 353421
2019-02-07 16:00:44 +00:00
Fangrui Song 8ebb854bc2 [ELF] Format lines inadvertently indented by rCTE353380
llvm-svn: 353415
2019-02-07 15:38:14 +00:00
Eric Liu 4b68d910d9 [clangd] Use Dex for dynamic index by default.
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
2019-02-07 15:34:37 +00:00
Jonas Toth a822b1155e [clang-tidy] Fixed a std::bind() transformation
There was an extra semicolon that was somehow working in some contexts.

Patch by oleg.smolsky.

llvm-svn: 353389
2019-02-07 11:00:59 +00:00
Alexander Kornienko 68d5652380 [clang-tidy] Expand and clarify the NOLINT documentation a bit.
llvm-svn: 353382
2019-02-07 10:34:43 +00:00
Eric Liu a9e9c506aa [clangd] Suggest adding missing includes for typos (like include-fixer).
Summary:
This adds include-fixer feature into clangd based on D56903. Clangd now captures
diagnostics caused by typos and attach include insertion fixes to potentially
fix the typo.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, MaskRay, javed.absar, ilya-biryukov, mgorny

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57021

llvm-svn: 353380
2019-02-07 09:23:22 +00:00
Roman Lebedev 058b628264 [clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)
Summary:
The check should ignore the main function, the program entry point.
It is not possible to use `std::array<>` for the `argv`.
The alternative is to use `char** argv`.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40604 | PR40604 ]]

Reviewers: JonasToth, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, hans, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D57787

llvm-svn: 353327
2019-02-06 19:17:30 +00:00
Eric Liu d7cb5b8a33 [clangd] Add type boost to fuzzy find in Dex.
Summary:
No noticeable impact on code completions overall except some improvement on
cross-namespace completion.

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57815

llvm-svn: 353310
2019-02-06 15:36:23 +00:00
Haojian Wu ea27b59a86 [clangd] Bump vscode-clangd v0.0.11
CHANGELOG:
- activate the extension on ObjC files.

llvm-svn: 353309
2019-02-06 15:29:54 +00:00
Haojian Wu 12e194cbb7 [clangd] Format tweak's replacements.
llvm-svn: 353306
2019-02-06 15:24:50 +00:00
Ilya Biryukov 8e42c62240 [clangd] Update dev dependencies of clangd-vscode
Summary:
The version bumps are a result of running `npm audit`, which found
3 security issues in previous versions of our dependencies.

Also add 'package-lock.json' to the repo, it's a common practice to
check in those files into the repository to get consistent versions of
dependencies when running on different machines.

Reviewers: hokein

Reviewed By: hokein

Subscribers: dschuff, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57814

llvm-svn: 353296
2019-02-06 13:53:24 +00:00
Ilya Biryukov 7a621551a3 [clangd] Enable clangd on Objective-C in VSCode
Summary: Thanks to Andreas Ostermeyer for raising this on the mailing list.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57813

llvm-svn: 353295
2019-02-06 13:47:49 +00:00
Haojian Wu ac6d2e1b16 [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.
Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57746

llvm-svn: 353284
2019-02-06 09:10:47 +00:00
Haojian Wu 5dcc66d0b8 [clangd] Some minor fixes.
Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57755

llvm-svn: 353283
2019-02-06 09:08:26 +00:00
Malcolm Parsons a7c957fd81 [clang-tidy] Handle unions with existing default-member-init
Summary:
clang-tidy's modernize-use-default-member-init was crashing for unions
with an existing default member initializer.

Fixes PR40492

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, riccibruno, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D57665

llvm-svn: 353092
2019-02-04 21:09:31 +00:00
Hyrum Wright 1c250bf296 [clang-tidy] Add the abseil-duration-unnecessary-conversion check
Differential Revision: https://reviews.llvm.org/D57353

llvm-svn: 353079
2019-02-04 19:28:20 +00:00
Kadir Cetinkaya c3dcd2673e [clangd] Enable include insertion for static index
Summary:
This enables include insertion by adding canonical includes into
preambledata.

Reviewers: ioeric, ilya-biryukov

Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57508

llvm-svn: 353054
2019-02-04 16:19:57 +00:00
Haojian Wu 8e933c1ccf [clangd] Bump vscode-clangd v0.0.10
CHANGELOG:
- cleanup filestatus caches when clangd crashes
- extension workwith LSP v3.14.0, support go-to-declaration feature

llvm-svn: 353027
2019-02-04 09:26:42 +00:00
Haojian Wu a1b0596916 [clangd] Update vscode dependencies
This allows us to use latest LSP v3.14.0 (for go-to-declaration feature).

llvm-svn: 353026
2019-02-04 09:20:41 +00:00
Simon Pilgrim 22f538ce11 Remove trailing semicolon. NFCI.
llvm-svn: 352991
2019-02-03 14:11:32 +00:00
Simon Pilgrim e9a136b58f Remove trailing semicolon. NFCI.
llvm-svn: 352990
2019-02-03 14:08:30 +00:00
Stephane Moore 003311270b Revert rCTE352968 due to compilation failures 💥
llvm-svn: 352969
2019-02-02 23:01:20 +00:00
Stephane Moore b08a2d4851 [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈
Summary:
Implicit functions are outside the control of source authors and should
be exempt from style restrictions.

Tested via running clang tools tests.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D57207

llvm-svn: 352968
2019-02-02 22:07:00 +00:00
Hyrum Wright e546b53e01 [clang-tidy] Rename time lookup functions; NFC
llvm-svn: 352964
2019-02-02 19:57:37 +00:00
Eric Liu 44d6f9e131 [clangd] Fix heap-use-after-free after r352868
llvm-svn: 352957
2019-02-02 10:35:39 +00:00
Sam McCall 0dbab7feca [Clangd] textDocument/definition and textDocument/declaration "bounce" between definition and declaration location when they are distinct.
Summary:
This helps minimize the disruption of not returning declarations as part of
a find-definition response (r352864).

Reviewers: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, ilya-biryukov

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57580

llvm-svn: 352953
2019-02-02 05:56:00 +00:00
Sam McCall 9c8f432617 [clangd] Expose SelectionTree to code tweaks, and use it for swap if branches.
Summary:
This reduces the per-check implementation burden and redundant work.
It also makes checks range-aware by default (treating the commonAncestor
as if it were a point selection should be good baseline behavior).

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57570

llvm-svn: 352876
2019-02-01 15:09:47 +00:00
Sam McCall 2048f22892 [clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.

It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.

Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.

Reviewers: ilya-biryukov, kadircet

Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57562

llvm-svn: 352875
2019-02-01 15:09:41 +00:00
Sam McCall 3186e3ceb8 [clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.

It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.

Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.

Reviewers: ilya-biryukov, kadircet

Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57562

llvm-svn: 352874
2019-02-01 15:05:11 +00:00
Sam McCall a4cf26b499 [clangd] Penalize file-scope symbols in the ranking for non-completion queries
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D56653

llvm-svn: 352868
2019-02-01 13:07:37 +00:00
Sam McCall 866ba2c924 [clangd] Implement textDocument/declaration from LSP 3.14
Summary:
LSP now reflects the declaration/definition distinction.

Language server changes:
 - textDocument/definition now returns a definition if one is found, otherwise
   the declaration. It no longer returns declaration + definition if they are
   distinct.
 - textDocument/declaration returns the best declaration we can find.
 - For macros, the active macro definition is returned for both methods.
 - For include directive, the top of the target file is returned for both.
There doesn't appear to be a discovery mechanism (we can't return everything to
clients that only know about definition), so this changes existing behavior.
In practice, it should greatly reduce the fraction of the time we need to show
the user a menu of options.

C++ API changes:
 - findDefinitions is replaced by locateSymbolAt, which returns a
   vector<LocatedSymbol> - one for each symbol under the cursor.
 - this contains the preferred declaration, the definition (if found), and
   the symbol name
This API enables some potentially-neat extensions, like swapping between decl
and def, and exposing the symbol name to the UI in the case of multiple symbols.

Reviewers: hokein

Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57388

llvm-svn: 352864
2019-02-01 11:26:13 +00:00
Sam McCall b34fca6b47 [clangd] Use delimited style to make life easier for the fuzzer
llvm-svn: 352863
2019-02-01 11:20:20 +00:00
Sam McCall 554644e512 [clangd] Unbreak fuzzer target
llvm-svn: 352857
2019-02-01 11:09:06 +00:00
Roman Lebedev 3440c33989 [clangd] clangDaemonTweaks - fix -DBUILD_SHARED_LIBS=ON build
Followup for rL352841.

llvm-svn: 352843
2019-02-01 08:58:37 +00:00
Roman Lebedev 11f7969256 [clangd] Fix -DBUILD_SHARED_LIBS=ON build - SwapIfBranches needs clangAST.
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
2019-02-01 08:23:23 +00:00
Sam McCall 8a32f3b7a0 [clangd] Fix crash in applyTweak, remove TweakID alias.
Strings are complicated, giving them opaque names makes us forget
they're complicated.

llvm-svn: 352837
2019-02-01 05:41:50 +00:00
Ilya Biryukov 4399878082 [clangd] A code action to swap branches of an if statement
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56611

llvm-svn: 352796
2019-01-31 21:30:05 +00:00
Eric Liu 00eaf6732e [clangd] Append "(fix available)" to diagnostic message when fixes are present.
Summary:
This would make diagnostic fixits more discoverable, especially for
plugins like YCM.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57509

llvm-svn: 352764
2019-01-31 16:09:25 +00:00
Jonas Toth 9b127421b6 [clang-tidy] refactor bugprone-exception-escape analysis into class
Summary:
The check `bugprone-exception-escape` does an AST-based analysis to determine
if a function might throw an exception and warns based on that information.
The analysis part is refactored into a standalone class similiar to
`ExprMutAnalyzer` that is generally useful.
I intent to use that class in a new check to automatically introduce `noexcept`
if possible.

Reviewers: aaron.ballman, alexfh, hokein, baloghadamsoftware, lebedev.ri

Reviewed By: baloghadamsoftware, lebedev.ri

Subscribers: lebedev.ri, mgorny, xazax.hun, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D57100

llvm-svn: 352741
2019-01-31 10:46:37 +00:00
Ilya Biryukov c6ed77812b [clangd] Drop fixes if replying with tweaks resulted in an error
This should not happen in normal operation, as it implies that the diagnostics
with some available fixes were produced but the AST is invalid.
Moreover, the code had an error: always returned code actions ignoring the
SupportsCodeAction capability and writing a test for this is impossible,
since this can only happen due to programmer's error rather than invalid inputs.

llvm-svn: 352624
2019-01-30 14:24:17 +00:00
Ilya Biryukov c9409c6d86 [clangd] Fix a use after move
Introduced in r352494.

llvm-svn: 352612
2019-01-30 09:39:01 +00:00
James Y Knight 5d71fc5d7b Adjust documentation for git migration.
This fixes most references to the paths:
 llvm.org/svn/
 llvm.org/git/
 llvm.org/viewvc/
 github.com/llvm-mirror/
 github.com/llvm-project/
 reviews.llvm.org/diffusion/

to instead point to https://github.com/llvm/llvm-project.

This is *not* a trivial substitution, because additionally, all the
checkout instructions had to be migrated to instruct users on how to
use the monorepo layout, setting LLVM_ENABLE_PROJECTS instead of
checking out various projects into various subdirectories.

I've attempted to not change any scripts here, only documentation. The
scripts will have to be addressed separately.

Additionally, I've deleted one document which appeared to be outdated
and unneeded:
  lldb/docs/building-with-debug-llvm.txt

Differential Revision: https://reviews.llvm.org/D57330

llvm-svn: 352514
2019-01-29 16:37:27 +00:00
Ilya Biryukov dd471681d0 [clangd] Remove extra ';' to fix -Wpedantic warning. NFC
llvm-svn: 352511
2019-01-29 16:04:39 +00:00
Ilya Biryukov d2167ec732 [clangd] Attempt to fix failing buildbots after r352494
For failures see:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/38501/steps/build-unified-tree/logs/stdio

llvm-svn: 352510
2019-01-29 15:57:14 +00:00
Ilya Biryukov 73afee2d7c [clangd] Make -clang-tidy-checks a non-hidden command-line arg
Summary:
This looks like a useful user-facing configuration parameter,
which should be discoverable.

Also fix a small typo in the description.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57384

llvm-svn: 352509
2019-01-29 15:52:05 +00:00
Ilya Biryukov 060f7fe3e3 [clangd] Unit test for sourceLocationInMainFile.
This should have been part of r352494, which added the corresponding
function. The unit test ended up as a separate commit accidentally.

llvm-svn: 352501
2019-01-29 14:31:19 +00:00
Ilya Biryukov cce67a32cf [clangd] Interfaces for writing code tweaks
Summary:
The code tweaks are an implementation of mini-refactorings exposed
via the LSP code actions. They run in two stages:
  - Stage 1. Decides whether the action is available to the user and
    collects all the information required to finish the action.
    Should be cheap, since this will run over all the actions known to
    clangd on each textDocument/codeAction request from the client.

  - Stage 2. Uses information from stage 1 to produce the actual edits
    that the code action should perform. This stage can be expensive and
    will only run if the user chooses to perform the specified action in
    the UI.

One unfortunate consequence of this change is increased latency of
processing the textDocument/codeAction requests, which now wait for an
AST. However, we cannot avoid this with what we have available in the LSP
today.

Reviewers: kadircet, ioeric, hokein, sammccall

Reviewed By: sammccall

Subscribers: mgrang, mgorny, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56267

llvm-svn: 352494
2019-01-29 14:17:36 +00:00
Haojian Wu e30d87ecea [clangd] dlog clang-tidy configuration
vlog seems to be too spammy in unittests.

llvm-svn: 352485
2019-01-29 12:32:32 +00:00
Kadir Cetinkaya 249ea33ddf [clangd] Make USRs for macros to be position independent
Summary:
USRs for macros were not cannonical due to usage of cursor location
instead of definition location.

Reviewers: jkorous

Subscribers: ilya-biryukov, ioeric, MaskRay, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57228

llvm-svn: 352481
2019-01-29 11:19:15 +00:00
Haojian Wu 7b6f874717 [clangd] Index main-file macros (bug 39761)
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D55739

llvm-svn: 352367
2019-01-28 14:11:49 +00:00
Haojian Wu f02e9f3783 [clang-tidy] Fix a build error.
llvm-svn: 352364
2019-01-28 14:07:45 +00:00
Hyrum Wright 722191be25 [clang-tidy] Add the abseil-duration-addition check
Differential Revision: https://reviews.llvm.org/D57185

llvm-svn: 352362
2019-01-28 14:03:09 +00:00
Eric Liu dd66277c36 [clangd] Suggest adding missing includes for incomplete type diagnostics.
Summary:
This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by
querying index). This patch adds missing includes for incomplete types e.g.
member access into class with only forward declaration. This would allow adding
missing includes for user-typed symbol names that are missing declarations
(e.g. typos) in the future.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56903

llvm-svn: 352361
2019-01-28 14:01:55 +00:00
Kristof Umann 64c3fe9103 Fix a lit test failure after D54438
llvm-svn: 352290
2019-01-26 21:22:58 +00:00
Jonas Toth 09197fac59 [clang-tidy] fix unit tests for dropped _Float16 support in X86
Summary:
Because _Float16 was disabled for X86 targets the unit-tests started failing.
Extract the pieces for _Float16 and run theses tests under AArch64.

Reviewers: aaron.ballman, erichkeane, lebedev.ri

Reviewed By: erichkeane

Subscribers: javed.absar, xazax.hun, kristof.beyls, cfe-commits

Differential Revision: https://reviews.llvm.org/D57249

llvm-svn: 352231
2019-01-25 19:05:12 +00:00
Roman Lebedev 76c9877b56 Temporairly disable readability-uppercase-literal-suffix tests that depend on _Float16, to get bots back to green
llvm-svn: 352224
2019-01-25 18:05:43 +00:00
Haojian Wu aa3ed5a983 [clangd] NFC: fix clang-tidy warnings.
Most are about llvm code style violation (found via
readability-identifier-naming check).

llvm-svn: 352205
2019-01-25 15:14:03 +00:00
Haojian Wu 7a35bdb7ec [clangd] Log clang-tidy configuration, NFC
Summary: This is used for debugging purpose.

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57057

llvm-svn: 352184
2019-01-25 10:14:27 +00:00
Haojian Wu c67dab5bd0 [clang-tidy] Add check for underscores in googletest names.
Summary: Adds a clang-tidy warning for underscores in googletest names.

Patch by Kar Epker!

Reviewers: hokein, alexfh, aaron.ballman

Reviewed By: hokein

Subscribers: Eugene.Zelenko, JonasToth, MyDeveloperDay, lebedev.ri, xazax.hun, mgorny, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D56424

llvm-svn: 352183
2019-01-25 10:03:49 +00:00
Hyrum Wright 1ec465dbfd [clang-tidy] Rename the absl duration helper functions; NFC
llvm-svn: 352088
2019-01-24 19:23:50 +00:00
Haojian Wu 66038ffa13 [clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.
Summary:
Clear the cached file statuses, otherwise we will leave some garbage texts on
the status bar when clangd crashes.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56540

llvm-svn: 352049
2019-01-24 14:25:53 +00:00
Ilya Biryukov c514adef05 [CodeComplete] [clangd] Fix crash on ValueDecl with a null type
Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57093

llvm-svn: 352040
2019-01-24 10:41:43 +00:00
David Carlier 7e37bf26d5 [extra] unit tests enable crash-recovery cases on FreeBSD
Seems the previous statement does not hold up anymore.

Reviewers: steveire

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D57102

llvm-svn: 352031
2019-01-24 07:58:42 +00:00
Ilya Biryukov 88d7d296f4 [clangd] Workaround a test failure after r351941
This should fix failing buildbots.

llvm-svn: 351943
2019-01-23 11:32:07 +00:00
Ilya Biryukov 4e0c400a47 [clangd] Fix crash due to ObjCPropertyDecl
With ObjCPropertyDecl, ASTNode.OrigD can be a ObjCPropertyImplDecl
which is not a NamedDecl, leading to a crash since the code
incorrectly assumes ASTNode.OrigD will always be a NamedDecl.

Change by dgoldman (David Goldman)!

Differential Revision: https://reviews.llvm.org/D56916

llvm-svn: 351941
2019-01-23 10:35:12 +00:00
Haojian Wu 87b0e3fda9 [clangd] Link clangTidy into clangd tests
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D57077

llvm-svn: 351929
2019-01-23 08:04:17 +00:00
Zinovy Nis 79639e9737 [doc] Fix svn property for bugprone-parent-virtual-call.rst
llvm-svn: 351925
2019-01-23 06:46:27 +00:00
Stephane Moore 05a449b481 Revert rCTE351921 to fix documentation geneeration.
Original review: https://reviews.llvm.org/D56945

llvm-svn: 351922
2019-01-23 02:58:59 +00:00
Stephane Moore be9eca442e [clang-tidy] Delete obsolete objc-property-declaration options ✂️
Summary:
The `Acronyms` and `IncludeDefaultAcronyms` options were deprecated in
https://reviews.llvm.org/D51832. These options can be removed.

Tested by running the clang-tidy tests.

Reviewers: benhamilton, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D56945

llvm-svn: 351921
2019-01-23 02:34:21 +00:00
Zinovy Nis 1449277fc0 [doc] Replace 'class' with 'struct' for 'public' by default
Make sample syntax correct.

llvm-svn: 351867
2019-01-22 20:27:02 +00:00
Eugene Zelenko b272ec1347 [Documentation] Use HTTPS whenever possible.
Differential revision: https://reviews.llvm.org/D56926

llvm-svn: 351862
2019-01-22 19:19:48 +00:00
Haojian Wu 32cd41f229 [clangd] Followup fix of rL351818
ClangTidyOptions::getDefaults is not free, it will initialize all
clang-tidy modules to get check-specific options, and we don't use this
information in CodeComplete, so using an empty one (constructed by
default constructor) is sufficient.

llvm-svn: 351826
2019-01-22 14:48:04 +00:00
Simon Pilgrim 6202a3ad67 Fix "missing field 'ClangTidyOpts' initializer" warning. NFCI.
llvm-svn: 351818
2019-01-22 13:35:16 +00:00
Alexander Kornienko 73eb326203 [clang-tidy] Fix whitespace in docs. NFC
Actually, just testing commits via monorepo ;)

llvm-svn: 351814
2019-01-22 12:59:34 +00:00
Eric Liu 464bbe5812 [clangd] NFC: reduce log noise from Diagnostics.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57042

llvm-svn: 351813
2019-01-22 12:55:27 +00:00
Haojian Wu 65e1099eed [clangd] Fix the broken buildbot.
llvm-svn: 351812
2019-01-22 12:55:15 +00:00
Haojian Wu 72ef4510b6 [clangd] Fix the `-Wtype-limits` warning, NFC
The assertion is always true, and triggers a compiler warning, so remove it.

llvm-svn: 351809
2019-01-22 12:21:25 +00:00
Kadir Cetinkaya a65bcbfd9c [clangd] NFC: Use buildCompilerInvocation in CodeComplete
Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56860

llvm-svn: 351793
2019-01-22 09:58:53 +00:00
Haojian Wu 1ca0c58c81 [clangd] Support clang-tidy configuration in clangd.
Summary:
This patch adds some basic supports for clang-tidy configurations in clangd:
      - clangd will respect .clang-tidy configurations for each file
      - we don't aim to support all clang-tidy options in clangd, only a
        small subset of condfigurations (options related to which checks will be
        enabled) are supported.
      - add a `clang-tidy-checks` CLI option that can override options from
        .clang-tidy file

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55256

llvm-svn: 351792
2019-01-22 09:39:05 +00:00
Kadir Cetinkaya be6b35dac4 [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.
Summary:
Some projects make use of clang plugins when building, but clangd is
not aware of those plugins therefore can't work with the same compile command
arguments.

There were multiple places clangd performed commandline manipulations,
 this one also moves them all into OverlayCDB.

Reviewers: ilya-biryukov

Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56841

llvm-svn: 351788
2019-01-22 09:10:20 +00:00
Alexander Kornienko efde822cd1 [clang-tidy] Work around http://llvm.org/PR40392
The readability-else-after-return check should be smarter about cases where the
variable defined in the condition is used in the `else` branch. This patch makes
it just ignore such cases, but alternative solutions may be better (added a
FIXME).

llvm-svn: 351751
2019-01-21 16:26:54 +00:00
Kadir Cetinkaya fd29980f09 [clang-tidy] Use getStripPluginsAdjuster
Summary: See rC351531 for the introduction of getStripPluginsAdjuster.

Reviewers: alexfh

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56902

llvm-svn: 351738
2019-01-21 10:10:18 +00:00
Chandler Carruth 4a1b95bda0 Fix typos throughout the license files that somehow I and my reviewers
all missed!

Thanks to Alex Bradbury for pointing this out, and the fact that I never
added the intended `legacy` anchor to the developer policy. Add that
anchor too. With hope, this will cause the links to all resolve
successfully.

llvm-svn: 351731
2019-01-21 09:52:34 +00:00
Miklos Vajna 61c818f253 [clang-tidy] misc-non-private-member-variables-in-classes: ignore implicit methods
Otherwise we don't warn on a struct containing a single public int, but
we warn on a struct containing a single public std::string, which is
inconsistent.

llvm-svn: 351686
2019-01-20 14:28:27 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
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-19 08:50:56 +00:00
Chandler Carruth 4a50956c07 Convert two more files that were using Windows line endings and remove
a stray single '\r' from one file. These are the last line ending issues
I can find in the files containing parts of LLVM's file headers.

llvm-svn: 351634
2019-01-19 06:36:08 +00:00
Chandler Carruth 79b37483c8 Update some code used in our visual studio plugins to use linux file
endings. We already used them in some cases, and this makes things
consistent. This will also simplify updating the licenses in these
files.

llvm-svn: 351632
2019-01-19 06:29:07 +00:00
Chandler Carruth 469bdefd44 Install new LLVM license structure and new developer policy.
This installs the new developer policy and moves all of the license
files across all LLVM projects in the monorepo to the new license
structure. The remaining projects will be moved independently.

Note that I've left odd formatting and other idiosyncracies of the
legacy license structure text alone to make the diff easier to read.
Critically, note that we do not in any case *remove* the old license
notice or terms, as that remains necessary until we finish the
relicensing process.

I've updated a few license files that refer to the LLVM license to
instead simply refer generically to whatever license the LLVM project is
under, basically trying to minimize confusion.

This is really the culmination of so many people. Chris led the
community discussions, drafted the policy update and organized the
multi-year string of meeting between lawyers across the community to
figure out the strategy. Numerous lawyers at companies in the community
spent their time figuring out initial answers, and then the Foundation's
lawyer Heather Meeker has done *so* much to help refine and get us ready
here. I could keep going on, but I just want to make sure everyone
realizes what a huge community effort this has been from the begining.

Differential Revision: https://reviews.llvm.org/D56897

llvm-svn: 351631
2019-01-19 06:14:24 +00:00
Jonas Toth ae17ff0781 [clang-tidy] add reproducer for PR39949 into test-suite
Summary:
The underlying issue is fixed in https://reviews.llvm.org/D56444
and this test ensures the issue does not creep back into our
code-base.

Reviewers: alexfh, aaron.ballman, hokein, hwright

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56918

llvm-svn: 351569
2019-01-18 18:03:11 +00:00
Ilya Biryukov 1c48f0383c [clangd] Make background index less chatty
Summary:
It is producing too much input in non-verbose mode,
i.e. a message per indexed file

Reviewers: sammccall, kadircet

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56915

llvm-svn: 351563
2019-01-18 17:04:26 +00:00
Hyrum Wright b60de17b51 [clang-tidy] Add abseil-duration-conversion-cast check
Differential Revision: https://reviews.llvm.org/D56532

llvm-svn: 351473
2019-01-17 20:37:35 +00:00
Aaron Ballman b95b6f42f9 Revert r351208 (which was a revert of r350892).
This corresponds to the fix to Clang in r351470.

llvm-svn: 351471
2019-01-17 20:21:44 +00:00
Eugene Zelenko 390b3b34e0 [Documentation] Fix another link in docs/clang-tidy/Contributing.rst.
llvm-svn: 351468
2019-01-17 20:00:23 +00:00
Eugene Zelenko 76c77d9eaf [Documentation] Another attempt to fix link in docs/clang-tidy/Contributing.rst. Use HTTPS for links.
llvm-svn: 351467
2019-01-17 19:47:44 +00:00
Eugene Zelenko 6bea2f21ce [Documentation] Fix link in docs/clang-tidy/Contributing.rst.
llvm-svn: 351466
2019-01-17 19:35:39 +00:00
Eugene Zelenko fb877cb9f2 [Documentation] Add a chapter about Clang-tidy integrations.
Patch by Marina Kalashina.

Differential Revision: https://reviews.llvm.org/D54945

llvm-svn: 351463
2019-01-17 18:31:34 +00:00
Hyrum Wright 56de30fd4b [clang-tidy] Move the macro helper function to a common location; NFC
This is useful for multiple checks.

llvm-svn: 351348
2019-01-16 14:49:32 +00:00
Hans Wennborg 1fe469ae6c Bump the trunk version to 9.0.0svn
llvm-svn: 351320
2019-01-16 10:57:02 +00:00
Pavel Labath 7b5565418f Fix build breakage from llvm r351317
The two-argument version of  llvm::sys::fs::make_absolute no longer
returns an error code.

llvm-svn: 351319
2019-01-16 10:26:52 +00:00
Clement Courbet ae814fcb4c [clang-tidy] bugprone-string-constructor: Catch string from nullptr.
Summary: Context: https://twitter.com/willkirkby/status/1084219580799741953

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56657

llvm-svn: 351308
2019-01-16 08:36:23 +00:00
Sam McCall 5a8e6afff2 [clang-tidy] Avoid fuchsia-overloaded-operator false positive with lambdas after r351047
llvm-svn: 351307
2019-01-16 08:29:54 +00:00