Commit Graph

6267 Commits

Author SHA1 Message Date
Adam Czachorowski 8e7bb37dfb [clangd] Fix crash in AddUsing tweak due to non-identifier DeclName
Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79582
2020-05-08 14:26:21 +02:00
Kirill Bobyrev 9c198b550e
[clangd] NFC: Use deprecated grpc++ headers for compatibility
Summary:
Ubuntu 18.04 and older versions do not provide latest gRCP packages and the
ones that are in the repository use deprecated headers. Use these headers to
make builds possible.

https://packages.ubuntu.com/bionic/amd64/libgrpc++-dev/filelist

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79487
2020-05-08 11:04:52 +02:00
Adam Czachorowski 9108715321 [clangd] Fix AddUsing tweak for out-of-line functions.
Summary:
We used getEnclosingNamespaceContext(), which calls getParent() rather
than getLexicalParent(), so we would end up adding the "using" line in
places that do not affect the cursor location, or just return an error
when declaration was in another file.

Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79496
2020-05-07 12:50:04 +02:00
Kadir Cetinkaya 717bef6623
[clangd] Preserve line information while build PreamblePatch
Summary: Depends on D78740.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78743
2020-05-07 12:24:28 +02:00
Haojian Wu 2a3498e24f [clang-tidy] Exclude function calls in std namespace for bugprone-argument-comment.
Reviewers: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79494
2020-05-07 09:00:49 +02:00
Kadir Cetinkaya 6d6d48add8
[clangd] Reland 'Handle PresumedLocations in IncludeCollector'
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 17:57:03 +02:00
Adam Czachorowski 319787315d [clangd] Do not offer "Add using" tweak in header files.
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79488
2020-05-06 15:50:54 +02:00
Kadir Cetinkaya 9b509bca85
Revert "[clangd] Handle PresumedLocations in IncludeCollector"
This reverts commit 4f7917c269 as it is
breaking windows build bots.
2020-05-06 13:17:08 +02:00
Kadir Cetinkaya 4f7917c269
[clangd] Handle PresumedLocations in IncludeCollector
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 13:06:49 +02:00
Tamás Zolnai fedd52682e [clang-tidy]: Add cert-str34-c alias for bugprone-signed-char-misuse.
Summary:
Added `DiagnoseSignedUnsignedCharComparisons` option to
filter out unrelated use cases. The SEI cert catches explicit
integer casts (two use cases), while in the case of
`signed char` \ `unsigned char` comparison, we have implicit
conversions.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79334
2020-05-06 12:36:01 +02:00
Dmitri Gribenko 3adaa97f01 Fix ForRangeCopyCheck not triggering on iterators returning elements by value in C++17.
Summary:
The AST is different in C++17 in that there is no MaterializeTemporaryExpr for in the AST for a loop variable that is initialized from an iterator that returns its elements by value.

Account for this by checking that the variable is not initialized by an operator* call that returns a value type.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79440
2020-05-06 09:42:13 +02:00
Konrad Kleine 24b4965ce6 [clang/clang-tools-extra] Fix BZ44437 - add_new_check.py does not work with Python 3
Summary:
This fixes https://bugs.llvm.org/show_bug.cgi?id=44437.

Thanks to Arnaud Desitter for providing the patch in the bug report!

A simple example program to reproduce this error is this:

```lang=python

import sys

with open(sys.argv[0], 'r') as f:
  lines = f.readlines()
lines = iter(lines)
line = lines.next()
print(line)
```

which will error with this in python python 3:

```
Traceback (most recent call last):
  File "./mytest.py", line 8, in <module>
    line = lines.next()
AttributeError: 'list_iterator' object has no attribute 'next'
```

Here's the same strategy applied to my test program as applied to the `add_new_check.py` file:

```lang=python

import sys

with open(sys.argv[0], 'r') as f:
  lines = f.readlines()
lines = iter(lines)
line = next(lines)
print(line)
```

The built-in function `next()` is new since Python 2.6: https://docs.python.org/2/library/functions.html#next

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79419
2020-05-05 17:22:50 -04:00
Yitzhak Mandelbaum c5b1a03525 [clang-tidy] In TransformerClangTidyCheck, support option IncludeStyle.
Summary:
The new option allows the user to specify which file naming convention is used
by the source code ('llvm' or 'google').

Reviewers: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79380
2020-05-05 10:38:31 -04:00
Kadir Cetinkaya d870016bfc
[clangd] Get rid of Inclusion::R
Summary:
This is only used by documentlink and go-to-definition. We are pushing
range detection logic from Inclusion creation to users. This would make using
stale preambles easier.

For document links we make use of the spelledtokens stored in tokenbuffers to
figure out file name range.

For go-to-def, we keep storing the line number we've seen the include directive.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79315
2020-05-05 12:23:58 +02:00
Kirill Bobyrev 07f8ca6ab1 [clangd] NFC: Cleanup unused headers and libraries
Summary: Extended version of D78843.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79313
2020-05-05 11:46:28 +02:00
Hans Wennborg 3c2c7760d9 Fix building with GCC5 after e64f99c51a
It was failing with:

  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp: In lambda function:
  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp:374:75:
  error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
                                                  trace::Metric::Distribution);
                                                                             ^
2020-05-04 11:12:39 +02:00
Sam McCall 6fe20a44fd [clangd] Fix yet-another gratuitous llvm::Error crash 2020-05-03 22:13:58 +02:00
Kadir Cetinkaya 81e48ae2b4
[clangd] Reland LSP latency test 2020-05-03 21:06:57 +02:00
Kadir Cetinkaya 7016043d0d
[clangd] Change include to be relative to current directory 2020-05-03 18:09:50 +02:00
Kadir Cetinkaya af28c74e8f
[clangd] Drop duplicate header 2020-05-03 15:20:20 +02:00
Kadir Cetinkaya 6c24b59ca1
[clangd] Fix name hiding in TestTracer and disable racy test for now 2020-05-03 11:51:23 +02:00
Kadir Cetinkaya e64f99c51a
[clangd] Metric tracking through Tracer
Summary: Introduces an endpoint to Tracer for tracking metrics on
internal events.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78429
2020-05-03 10:50:32 +02:00
Sam McCall d10c995b4d std::isspace -> llvm::isSpace (where locale should be ignored)
I've left out some cases where I wasn't totally sure this was right or
whether the include was ok (compiler-rt) or idiomatic (flang).
2020-05-02 15:36:04 +02:00
Sam McCall b283ae7af8 [ADT] Add locale-independent isSpace() to StringExtras. NFC
Use this in clangd, will follow up with replacements for isspace where
locale-dependent is clearly not intended.
2020-05-02 15:20:05 +02:00
Sam McCall fa1f4cf843 [clangd] Rename FormattedString -> Markup, move to support. NFC 2020-05-02 14:53:47 +02:00
Sam McCall ec170b7ccd [clangd] Fix whitespace between chunks in markdown paragraphs.
Summary:
Old model: chunks are always separated by one space.
           This makes it impossible to render "Foo `bar`." correctly.

New model: chunks are separated by space if the left had trailing space, or
           the right had leading space, or space was explicitly requested.
           (Only leading/trailing space in plaintext chunks count, not code)

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79139
2020-05-02 14:39:54 +02:00
Tamás Zolnai 030ff901f4 [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.
Summary:
To cover STR34-C rule's second use case, where ``signed char`` is
used for array subscript after an integer conversion. In the case
of non-ASCII character this conversion will result in a value
in excess of UCHAR_MAX.

There is another clang-tidy check which catches these cases.
cppcoreguidelines-pro-bounds-constant-array-index catches any
indexing which is not integer constant. I think this check is
very strict about the index (e.g. constant), so it's still useful
to cover the ``signed char`` use case in this check, so we
can provide a way to catch the SEI cert rule's use cases on a
codebase, where this CPP guideline is not used.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D78904
2020-05-02 14:05:05 +02:00
Sam McCall 2cf93ef9fe [clangd] Render doc-comment code spans with `backticks` in plaintext mode
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79142
2020-04-30 20:16:51 +02:00
Sam McCall 54d7db165d [clangd] Move inserted include from detail -> documentation.
Summary: Many clients try to display all the detail inline, with poor results.

See https://github.com/clangd/clangd/issues/284

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79106
2020-04-30 19:58:53 +02:00
Sam McCall a3a27a7aee [clangd] Render code complete documentation as plaintext/markdown.
Summary:
Structure is parsed from the raw comment using the existing heuristics used
for hover.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79157
2020-04-30 19:00:49 +02:00
Kadir Cetinkaya ad2da0521a
[clangd] Get rid of move semantics to unbreak windows build bots 2020-04-30 16:43:50 +02:00
Kadir Cetinkaya 594be179c9
[clangd] Second attempt at fixing VS2019 build bots 2020-04-30 15:37:33 +02:00
Kadir Cetinkaya 932a2b8264
[clangd] Fix VS2019 build bots too 2020-04-30 14:01:09 +02:00
Kadir Cetinkaya 7a3be975b9
[clangd][Hover] Get rid of unused private field in Paragraph 2020-04-30 12:13:18 +02:00
Kadir Cetinkaya 0dedb43153
[clangd] Fix windows build bots without rvalue refs 2020-04-30 10:25:22 +02:00
Kadir Cetinkaya 97c407db77
[clangd] Make use of URIs in FileShardedIndex
Summary:
This makes FileShardedIndex more robust and gets rid of the need for a
URIToFileCache, as it is done by the callers now and it is only once per file,
rather than once per symbol.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79079
2020-04-30 09:47:59 +02:00
Sam McCall 30d17d8852 [clangd] Parse `foo` in documentation comments and render as code.
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77456
2020-04-30 00:22:15 +02:00
Sam McCall e7a7deb60a [clangd] Fix BUILD_SHARED_LIBS build more. 2020-04-29 22:46:41 +02:00
Sam McCall bc029fa6c5 [clangd] Still need pthreads in clangDaemon. 2020-04-29 21:41:12 +02:00
Kirill Bobyrev 4645ef17ff
[clangd] Add CMake dependencies for Protobuf-generated files
Summary:
Dependencies ensure that Protobufs are generated before all libraries
depending on the headers are **built**, not linked.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79085
2020-04-29 17:01:03 +02:00
Sam McCall ad97ccf6b2 [clangd] Move non-clang base pieces into separate support/ lib. NFCI
Summary:
This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.

Reviewers: kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79014
2020-04-29 15:57:12 +02:00
Richard Smith c35f3f8679 Fix up clangd after clang commit llvmorg-11-init-13375-g0a088ead85f.
It's not clear whether clangd should really consider #import to mark a
header as self-contained or not, but this change preserves the old (and
unit-tested) behavior.
2020-04-28 23:49:35 -07:00
Saleem Abdulrasool 216833b32b Revert "Temporarily revert "build: use `find_package(Python3)` if available""
This reverts commit 35edd704e0.

Revert the revert and extend the patch further to account for the use of
the `PYTHONINTERP_FOUND`.
2020-04-29 01:38:08 +00:00
Paula Toth 8683f5de53 [clang-tidy] Add check callee-namespace.
Summary:
This check will ensure that all calls to functions resolve to one inside the `__llvm_libc` namespace.

This is done to ensure that if we include a public header then we don't accidentally call into the a function within the global namespace.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

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

Tags: #clang-tools-extra, #libc-project, #clang

Differential Revision: https://reviews.llvm.org/D78890
2020-04-28 17:22:23 -07:00
Eric Christopher 35edd704e0 Temporarily revert "build: use `find_package(Python3)` if available"
as it seems to be causing multiple people problems with running tests
and building.

This reverts commit c4c3883b00.
2020-04-28 16:41:22 -07:00
Sam McCall 4e769e93b9 Reland "Add a facility to get system cache directory and use it in clangd"
This reverts commit faf2dce1dd.
2020-04-29 00:56:36 +02:00
Eric Christopher faf2dce1dd Temporarily revert "Add a facility to get system cache directory and use it in clangd"
This reverts commit ad38f4b371.

As it broke building the unittests:

.../sources/llvm-project/llvm/unittests/Support/Path.cpp:334:5: error: use of undeclared identifier 'set'
    set(Value);
    ^
1 error generated.
2020-04-28 15:49:46 -07:00
Vojtěch Štěpančík ad38f4b371 Add a facility to get system cache directory and use it in clangd
Summary:
This patch adds a function that is similar to `llvm::sys::path::home_directory`, but provides access to the system cache directory.

For Windows, that is %LOCALAPPDATA%, and applications should put their files under %LOCALAPPDATA%\Organization\Product\.

For *nixes, it adheres to the XDG Base Directory Specification, so it first looks at the XDG_CACHE_HOME environment variable and falls back to ~/.cache/.

Subsequently, the Clangd Index storage leverages this new API to put index files somewhere else than the users home directory.

Fixes https://github.com/clangd/clangd/issues/341

Reviewers: sammccall, chandlerc, Bigcheese

Reviewed By: sammccall

Subscribers: hiraditya, ilya-biryukov, MaskRay, jkorous, dexonsmith, arphaman, kadircet, ormris, usaxena95, cfe-commits, llvm-commits

Tags: #clang-tools-extra, #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78501
2020-04-28 23:18:31 +02:00
Kirill Bobyrev 9ff3f339e8
[clangd] Fix remote index build without shared libs mode
Summary:
Generated Protobuf library has to be in CLANG_EXPORTS and should also be
installed appropriately. The easiest way to do that is via CMake's
add_clang_library. That unfortunately applies "one directory - one
clang_(library|tool)" policy so .proto files should be in a separate directory
and complicates the layout.

This setup works both in shared and static libs mode.

Resolves: https://github.com/clangd/clangd/issues/351

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78885
2020-04-28 19:16:37 +02:00
Saleem Abdulrasool c4c3883b00 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 09:24:27 -07:00
Saleem Abdulrasool be884b7935 Revert "build: use `find_package(Python3)` if available"
This reverts commit cd84bfb814.  Although
this passed the CI in phabricator, some of the bots are missing python3
packages, revert it temporarily.
2020-04-27 20:03:32 -07:00
Saleem Abdulrasool cd84bfb814 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 01:33:10 +00:00
Matthias Gehre 145dcef8bd [clang-tidy] modernize-use-using: Fix broken fixit with InjectedClassName
Summary:
Before this PR, `modernize-use-using` would transform the typedef in
```
template <int A>
struct InjectedClassName {
  typedef InjectedClassName b;
};
```
into `using b = InjectedClassName<A>;` and
```
template <int>
struct InjectedClassNameWithUnnamedArgument {
  typedef InjectedClassNameWithUnnamedArgument b;
};
```
into `using b = InjectedClassNameWithUnnamedArgument<>;`.
The first fixit is surprising because its different than the code
before, but the second fixit doesn't even compile.

This PR adds an option to the TypePrinter to print InjectedClassNameType without
template parameters (i.e. as written).

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77979
2020-04-27 14:23:23 +02:00
Arthur Eubanks 8000d506af [clangd] Strip /showIncludes in clangd compile commands
In command lines with /showIncludes, clangd would output includes to stdout, breaking clients.

Summary: Fixes https://github.com/clangd/clangd/issues/322.

Reviewers: sammccall, kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78836
2020-04-26 18:57:39 -07:00
Sam McCall 6880c4dfa3 [clangd] Fold buildAST into ParsedAST::build. NFCI 2020-04-27 00:14:03 +02:00
Benjamin Kramer c758181525 [clang-tidy] Use StringSwitch in a bunch of places. NFCI. 2020-04-26 17:24:47 +02:00
Sam McCall 6d7637dc46 [clangd] Disable delayed template parsing in the main file
Summary:
This is on by default in windows and breaks most features in template bodies.
We'd already disabled it in code completion, now disable it for building ASTs.

Potential regressions:
 - we may give spurious errors where files with templates relying on delayed
   parsing are directly opened
 - we may misparse such template bodies that are instantiated (and therefore
   *were* previously parsed)

Still *probably* a win overall. Avoiding the regressions entirely would be
substantial work and we don't have plans for it now.

Fixes https://github.com/clangd/clangd/issues/302 (again)

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78848
2020-04-26 14:29:38 +02:00
Nathan Ridge 230cae89db [clangd] Enable textual fallback for go-to-definition on dependent names
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76451
2020-04-26 00:38:38 -04:00
Kadir Cetinkaya a940a246f5
[clangd] Disable dependency-output lit test on windows 2020-04-25 13:55:38 +02:00
Kadir Cetinkaya 294b9d43ca
[clangd] Disable all dependency outputs
Summary: Fixes https://github.com/clangd/clangd/issues/322

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78833
2020-04-25 13:51:33 +02:00
Sam McCall 226b045b1f [clangd] Look for compilation database in `build` subdirectory of parents.
Summary:
This matches the conventional location of cmake build directories.
It also allows creating a `build` symlink, which seems more flexible than the
compile_commands.json symlinks.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78629
2020-04-25 02:18:17 +02:00
Kirill Bobyrev 9774c34a84 [clangd] NFC: Omit deduced template parameters
Related revision: D78521
2020-04-24 14:27:39 +02:00
Kirill Bobyrev 1ccfe475a7 [clangd] Fix build when CLANGD_REMOTE is not enabled 2020-04-24 14:07:39 +02:00
Kirill Bobyrev 67b2dbd5a3 [clangd] Extend dexp to support remote index
Summary:
* Merge clangd-remote-client into dexp
* Implement `clangd::remote::IndexClient` that is derived from `SymbolIndex`
* Upgrade remote mode-related CMake infrastructure

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78521
2020-04-24 13:59:21 +02:00
Haojian Wu a466e4be38 [clangd] Fix modernize-loop-convert "multiple diag in flight" crash.
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes https://github.com/clangd/clangd/issues/156.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715
2020-04-24 11:16:36 +02:00
Kadir Cetinkaya 89cb5d5588
[clangd] Delete remapped buffers in tests
These buffers normally get freed after being used in a CompilerInstance.
but tests don't make use of those, so we need to free them explicitly.
2020-04-23 16:31:35 +02:00
Andi-Bogdan Postelnicu bbb7921da9 [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`
Summary: Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`.

Reviewers: JonasToth

Subscribers: xazax.hun, baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, Charusso, ASDenysPetrov, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77882
2020-04-23 11:36:50 +03:00
Haojian Wu 7d1ee639cb [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.
Summary: Fixes https://github.com/clangd/clangd/issues/347.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78626
2020-04-22 21:00:20 +02:00
Sam McCall 3f1c2bf171 [clangd] go-to-def on names in comments etc that are used nearby.
Summary:
This is intended as a companion to (and is inspired by) D72874 which attempts to
resolve these cases using the index.
The intent is we'd try this strategy after the AST-based approach but before the
index-based (I think local usages would be more reliable than index matches).

Reviewers: nridge

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75479
2020-04-22 19:46:41 +02:00
Sam McCall 161afc0106 [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd
Summary:
Moving this out of the monorepo for consistency with other editor plugins.
There's no version lock with clangd itself, and we never ran tests with lit.

The first version from the new repo has been published.

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78598
2020-04-22 11:11:13 +02:00
Aaron Ballman 6a30894391 C++2a -> C++20 in some identifiers; NFC. 2020-04-21 15:37:19 -04:00
Sam McCall f5b0591552 [clangd] Bump VSCode version number to allow republish (icon-only change). 2020-04-21 16:09:26 +02:00
Sam McCall 5a68138403 [clangd] Add icon to VSCode extension, and fix URLs 2020-04-21 13:40:47 +02:00
Kadir Cetinkaya 4ccafab076
[clangd] Change field name to prevent shadowing 2020-04-21 11:57:59 +02:00
Kadir Cetinkaya 6b3168f8cd
[clangd] Fix windows buildbots for #import statements 2020-04-21 10:56:34 +02:00
Kadir Cetinkaya 2214b9076f
[clangd] Make signatureHelp work with stale preambles
Summary:
This is achieved by calculating newly added includes and implicitly
parsing them as if they were part of the main file.

This also gets rid of the need for consistent preamble reads.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77392
2020-04-21 10:27:26 +02:00
Kadir Cetinkaya 6e017188b7
[clangd] Store ppdirective in Inclusion
Summary:
This will enable PreamblePatching proposed in D77392 craft a more
informed patch.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78235
2020-04-21 10:27:26 +02:00
Sam McCall 6529b0c48a [clangd] Enable diagnostic fixes within macro argument expansions.
Summary: This seems like a pretty safe case, and common enough to be useful.

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78338
2020-04-20 21:18:31 +02:00
Sam McCall ee12edcb76 [Preamble] Allow recursive inclusion of header-guarded mainfile.
Summary:
This is guaranteed to be a no-op without the preamble, so should be a
no-op with it too.

Partially fixes https://github.com/clangd/clangd/issues/337
This doesn't yet work for #ifndef guards, which are not recognized in preambles.
see D78038

I can't for the life of me work out how to test this outside clangd.
The original reentrant preamble diagnostic was untested, I added a test
to clangd for that too.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78366
2020-04-20 17:28:42 +02:00
Michael Forster b36b889a3b Explicitly move from llvm::json Array/Object to Value
Summary: The implicit conversion fails under Clang 3.8.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78487
2020-04-20 15:18:52 +02:00
Kadir Cetinkaya 3be73dfde7
[clangd][test] Make sed git bash compliant 2020-04-20 08:27:15 +02:00
Sam McCall 098e40eac5 [clangd] Add index export to dexp
Summary: Add a command to dexp that exports index data in chosen format (e.g. YAML).

Reviewers: sammccall

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

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D77385
2020-04-19 14:34:46 +02:00
Sam McCall 8c68de2d63 [clangd] Extend YAML Serialization
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D77938
2020-04-19 14:32:31 +02:00
Kadir Cetinkaya 66b54d586f
[clangd] Fix memory leak in FileIndexTest 2020-04-17 14:00:34 +02:00
Kadir Cetinkaya 4503cf5f23
[clangd] Drop dangling relations while sharding
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78359
2020-04-17 13:57:32 +02:00
Matthias Gehre 0642e5e7a7 [clang-tidy] modernize-use-using: Fix broken fixit with 'template' keyword
Summary:
Before this PR, `modernize-use-using` would transform the typedef in
```

template <typename a> class TemplateKeyword {
  typedef typename a::template f<> e;
  typedef typename a::template f<>::d e2;
};
```
into
```
template <typename a> class TemplateKeyword {
  using d = typename a::b<>;
  using d2 = typename a::template a::b<>::c;
};
```
The first one is missing the `template` keyword,
the second one has an extra `a::` scope. Both result
in compilation errors.

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78139
2020-04-17 10:37:24 +02:00
Sam McCall 63725df1d6 [clangd] Remove unused and underused helpers. NFC 2020-04-17 01:08:32 +02:00
Sam McCall b0c4dfb3b1 [clangd] Print PID on windows too 2020-04-17 01:00:42 +02:00
Chris Lattner 39c9c12b76 [clang-tools-extra] reimplement PreprocessorTracker in terms of StringSet.
Summary:
PreprocessorTracker is the last user of the old StringPool class, which
isn't super loved and isn't a great improvement over a plan StringSet.
Once this goes in we can remove StringPool entirely.

This is as discussed on cfe-dev.

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78273
2020-04-16 12:57:43 -07:00
Kirill Bobyrev cee80c0489 [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)
Summary:
This patch allows using installed gRPC to build two simple tools which
currently provide the functionality of looking up the symbol by name.
remote-index-client is a simplified version of dexp which connects to
remote-index-server passes lookup requests.

I also significantly reduced the scope of this patch to prevent large changelist
and more bugs. The next steps would be:

* Extending Protocol for deep copies of Symbol and inherit RemoteIndex from
  Index to unify the interfaces
* Make remote-index-server more generic and merge the remote index client with
  dexp
* Modify Clangd to allow using remote index instead of the local one for all
  global index requests

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77794
2020-04-16 13:55:08 +02:00
Haojian Wu 6a78c55e3a [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78181
2020-04-15 21:42:27 +02:00
Kim Viggedal b2d8c89ea4 Remove false positive in AvoidNonConstGlobalVariables.
Addresses post-commit review feedback from https://reviews.llvm.org/D70265
2020-04-15 14:48:06 -04:00
Nico Weber 99e4061bd8 Try to fix clang-tidy/infrastructure/config-files.cpp on Win after cb1ee34e9d.
See also r267736.
2020-04-15 13:38:03 -04:00
Dmitry Polukhin cb1ee34e9d [clang-tidy] Optional inheritance of file configs from parent directories
Summary:
Without this patch clang-tidy stops finding file configs on the nearest
.clang-tidy file. In some cases it is not very convenient because it
results in common parts duplication into every child .clang-tidy file.
This diff adds optional config inheritance from the parent directories
config files.

Test Plan:

Added test cases in existing config test.

Reviewers: alexfh, gribozavr2, klimek, hokein

Subscribers: njames93, arphaman, xazax.hun, aheejin, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75184
2020-04-15 06:41:31 -07:00
Kirill Bobyrev f058673397 [dexp] NFC: Change positional argument format
Summary:
Before:

  USAGE: dexp [options] --index-path Path to the index

After:

  USAGE: dexp [options] <INDEX FILE>

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78089
2020-04-15 13:28:07 +02:00
Kadir Cetinkaya 2cd0be02b9
[clangd] Fix MSVC compile error, attempt 2 2020-04-15 09:33:12 +02:00
Kadir Cetinkaya 6d53897554
[clangd] Fix MSVC builds 2020-04-15 09:24:58 +02:00
Kadir Cetinkaya dffa9dfbda
[clangd] Shard preamble symbols in dynamic index
Summary:
This reduces memory usage by dynamic index from more than 400MB to 32MB
when all files in clang-tools-extra/clangd/*.cpp are active in clangd.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77732
2020-04-15 09:10:10 +02:00
Nathan Ridge d83541d1b8 [clangd] Color dependent names based on their heuristic target if they have one
Summary: Fixes https://github.com/clangd/clangd/issues/297

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76896
2020-04-15 00:57:08 -04:00
Sam McCall 808c2855e1 [clangd] Add tests that no-op changes are cheap
Summary:
We want to be sure they don't cause AST rebuilds or evict items from the cache.
D77847 is going to start sending spurious no-op changes (in case the preamble
was invalidated), this is cheap enough but we shouldn't regress that in future.

Reviewers: kadircet

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78048
2020-04-14 16:15:23 +02:00
Reid Kleckner eac56724fd Fix target_info.test on Windows with a hack
Add a quote character to the sed command to cause it to be quoted.
Hopefully, which will help both gnuwin and MSys versions of sed tokenize
the command line the same way.
2020-04-13 13:14:06 -07:00
Sam McCall 596b63ad40 [clangd] Rebuild dependent files when a header is saved.
Summary:
Caveats:
 - only works when the header is changed in the editor and the editor provides
   the notification
 - we revalidate preambles for all open files (stat all their headers) rather
   than taking advantage of the fact that we know which file changed.
   This is much simpler!

Fixes https://github.com/clangd/clangd/issues/107

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77847
2020-04-13 22:08:15 +02:00
Sam McCall 31db1e0bd1 [clangd] Send the correct error code when cancelling requests.
Summary:
I couldn't quite bring myself to make Cancellation depend on LSP ErrorCode.
Magic numbers instead...

Reviewers: kadircet

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77947
2020-04-13 19:42:38 +02:00
Kadir Cetinkaya 48d851a92e
[clangd] Update TUStatus test to handle async PreambleThread
Summary:
Currently it doesn't matter because we run PreambleThread in sync mode.
Once we start running it in async, test order will become non-deterministic.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77669
2020-04-13 12:27:50 +02:00
Nathan James 672207c319 [clang-tidy] Convert config options that are bools to use the bool overload of get(GlobalOrLocal)?
Summary: This was done with a script that looks for calls to Options.get(GlobalOrLocal) that take an integer for the second argument and the result is either compared not equal to 0 or implicitly converted to bool. There may be other occurances

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77831
2020-04-12 23:06:09 +01:00
Kadir Cetinkaya 101a69d71b
[clangd] Reland target_info_test 2020-04-12 16:10:04 +02:00
Kadir Cetinkaya 5d5671242e
[clangd] Disable failing target_info test 2020-04-11 22:17:01 +02:00
Kadir Cetinkaya d34a91a10f
[clangd][test] Provide registered targets to lit tests
Summary:
We had tests in clangd (target_info.test) that got enabled only on
systems that know about x86. But they were always disabled as clangd lit config
never registered those targets.

This patch adds those targets as `$TARGET$-registered-target`

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77944
2020-04-11 22:03:08 +02:00
Sam McCall a50df668f6
[clangd] Remove redundant code in test. NFC 2020-04-11 17:14:31 +02:00
Michael Wyman 89f1321fe4 [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.
Summary: This check is similar to an ARC Migration check that warned about this incorrect usage under ARC, but most projects are no longer undergoing migration from pre-ARC code. The documentation for NSInvocation is not explicit about these requirements and incorrect usage has been found in many of our projects.

Reviewers: stephanemoore, benhamilton, dmaclach, alexfh, aaron.ballman, hokein, njames93

Reviewed By: stephanemoore, benhamilton, aaron.ballman

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

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D77571
2020-04-10 08:51:21 -07:00
Sam McCall 1229245df7 [clangd] Set up machinery for gtests of ClangdLSPServer.
Summary:
This is going to be needed to test e.g. diagnostics regeneration on
didSave where files changed on disk. Coordinating such changes is too
hard in lit tests.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77766
2020-04-10 02:50:57 +02:00
Matthias Gehre eaa5559094 [clang-tidy] misc-unused-parameters: Don't remove parameter from lambda
Summary:
Previously, the check would fix
```
using fn = void(int);
void f(fn *);
void test() {
  // CHECK-MESSAGES: :[[@LINE+2]]:12: warning: parameter 'I' is unused
  // CHECK-FIXES: {{^}}  f([](int  /*I*/) {
  f([](int I) { return; });
}
```
into
`f([]() { return; });` which breaks compilation. Now the check is disabled from Lambdas.

The AST is not so easy to use. For
```
    auto l = [](int) {  return;  };
    f(l);
```
one gets
```
 `-CallExpr <line:7:5, col:8> 'void'
      |-ImplicitCastExpr <col:5> 'void (*)(fn *)' <FunctionToPointerDecay>
      | `-DeclRefExpr <col:5> 'void (fn *)' lvalue Function 0x55a91a545e28 'f' 'void (fn *)'
      `-ImplicitCastExpr <col:7> 'void (*)(int)' <UserDefinedConversion>
        `-CXXMemberCallExpr <col:7> 'void (*)(int)'
          `-MemberExpr <col:7> '<bound member function type>' .operator void (*)(int) 0x55a91a546850
            `-ImplicitCastExpr <col:7> 'const (lambda at line:6:14)' lvalue <NoOp>
              `-DeclRefExpr <col:7> '(lambda at line:6:14)':'(lambda at line:6:14)' lvalue Var 0x55a91a5461c0 'l' '(lambda at line:6:14)':'(lambda at line:6:14)'
```
There is no direct use of the `operator()(int I)` of the lambda, so the `!Indexer->getOtherRefs(Function).empty()`
does not fire. In the future, we might be able to use the conversion operator `operator void (*)(int)` to mark
the call operator as having an "other ref".

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77680
2020-04-09 19:26:41 +02:00
Marek Kurdej 340d1119ed [clang-tidy] [doc] Fix hicpp-noexcept-move alias links. 2020-04-09 10:48:08 +02:00
Yitzhak Mandelbaum 5e5d366718 [libTooling] Simplify the representation of Transformer's RewriteRules.
Summary:
This revision simplifies the representation of edits in rewrite rules. The
simplified form is more general, allowing the user more flexibility in building
custom edit specifications.

The changes extend the API, without changing the signature of existing
functions. So this only risks breaking users that directly accessed the
`RewriteRule` struct.

Reviewers: gribozavr2

Subscribers: jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77419
2020-04-08 08:45:41 -04:00
Haojian Wu a533b03028 [clangd] Add missing GoToStmt in FindTarget.
Summary: so that go-to-def on label can work.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77715
2020-04-08 14:19:52 +02:00
Sam McCall 49268a678c [clangd] Support dexp -c "some command"
Summary:
It runs one command and exits.
See D77385 for motivation.

Reviewers: mnauw, kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77645
2020-04-08 14:02:49 +02:00
Adam Czachorowski cca10be3f6 [clangd] Fix a crash bug in AddUsing tweak around template handling.
Summary:
The crash happened on cases like:
template<typename TT> using one = two::three<T^T>;
because we tried to call getName() on getBaseTypeIdentifier(), which can
be nullptr.

Ideally we would support this use case as well, but for now not crashing
will do.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77656
2020-04-08 13:59:47 +02:00
Sam McCall c1a00b89ad [clangd] show layout info when hovering on a class/field definition.
Summary:
This triggers only on the definition itself, not on references (probably too
noisy). Inspecting the definition seems like a decent hint for being interested
in layout.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77355
2020-04-08 13:41:51 +02:00
Kadir Cetinkaya 2a6eedbb51
[clangd] Destroy context before resetting CurrentReq
Summary:
Our tests stash callbacks into request context and rely on it being
invoked before threads going idle.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77671
2020-04-08 09:57:55 +02:00
Kadir Cetinkaya 130dbf63ff
[clangd] Fix broken assertion
Summary:
This assertion was bad. It will show up once we start running preamble
thread async. Think about the following case:

- Update 1
    builds a preamble, and an AST. Caches the AST.
- Update 2
    Invalidates the cache, preamble hasn't changed.
- Update 3
    Invalidates the cache, preamble hasn't changed
- Read
    builds AST using preamble v1, and caches it.
    preamble for v2 gets build, cache isn't invalidated since preamble is same.
    generateDiags tries to reuse cached AST but latest version is 3 not 2, so
    assertion fails.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77664
2020-04-08 09:57:55 +02:00
Johannes Doerfert 530377018f [OpenMP] "UnFix" last layering problem with FrontendOpenMP
It seems one target was missed in D77666 which kept some bots red [0].

[0] http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/12079/steps/build%20stage%201/logs/stdio
2020-04-07 22:47:41 -05:00
Nathan James 0361798dbe [clang-tidy] Fix buildbot failing with explicit specialization in class scope 2020-04-07 21:30:29 +01:00
Johannes Doerfert f9d558c871 [OpenMP] "UnFix" layering problem with FrontendOpenMP
This reverts commit 97aa593a83 as it
causes problems (PR45453) https://reviews.llvm.org/D77574#1966321.

This additionally adds an explicit reference to FrontendOpenMP to
clang-tidy where ASTMatchers is used.

This is hopefully just a temporary solution. The dependence on
`FrontendOpenMP` from `ASTMatchers` should be handled by CMake
implicitly, not us explicitly.

Reviewed By: aheejin

Differential Revision: https://reviews.llvm.org/D77666
2020-04-07 14:41:18 -05:00
Nathan James 9dff9ecdd1 [clang-tidy] Change checks that take enum configurations to use a new access method.
Summary: Change all checks that take enums as configuration to use enum specific methods in `ClangTidyCheck::OptionsView`.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: wuzish, nemanjai, kbarton, arphaman, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D76606
2020-04-07 20:04:31 +01:00
Nathan James fcf7cc268f [clang-tidy] Added support for validating configuration options
Summary:
Adds support for `ClangTidyCheck::OptionsView` to deteremine:
  - If an option is found in the configuration.
  - If an integer option read from configuration is parsable to an integer.
  - Parse and Serialize enum configuration options directly using a mapping from `llvm::StringRef` to `EnumType`.
  - If an integer or enum option isn't parseable but there is a default value it will issue a warning to stderr that the config value hasn't been used.
  - If an enum option isn't parsable it can provide a hint if the value was a typo.

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D77085
2020-04-07 19:54:34 +01:00
Nico Weber 448b777b86 Stop passing site cfg files via --param to llvm-lit.
This has been unnecessary since https://reviews.llvm.org/D37756.

https://reviews.llvm.org/D37838 removed it for llvm.

This removes it from clang, lld, clang-tools-extra (and the GN build).

No intended behavior change.

Differential Revision: https://reviews.llvm.org/D77585
2020-04-07 08:20:40 -04:00
Kadir Cetinkaya 59c28103a4
[clangd] Fix printing for Inclusion 2020-04-07 13:48:00 +02:00
Kadir Cetinkaya 4ac7b805b7
[clangd] Get rid of ASTWorker::getCurrentFileInputs
Summary:
FileInputs are only written by ASTWorker thread, therefore it is safe
to read them without the lock inside that thread. It can still be read by other
threads through ASTWorker::getCurrentCompileCommand though.

This patch also gets rid of the smart pointer wrapping FileInputs as there is
never mutliple owners.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77309
2020-04-07 13:48:00 +02:00
Nathan James 353a988368 [clangd] DefineOutline: removes static token from static CXXMethodDecl
Summary: Removes the `static` token when defining a function out of line if the function is a `CXXMethodDecl`

Reviewers: sammccall, kadircet, hokein

Reviewed By: kadircet

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

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D77534
2020-04-07 11:57:43 +01:00
Karl-Johan Karlsson 39e9149d8e Fix unused variable warning in Protocol.cpp, NFCI
Fixed gcc warning:
clang-tools-extra/clangd/Protocol.cpp:300:16: warning: unused variable 'SemanticHighlighting' [-Wunused-variable]
2020-04-07 08:39:17 +02:00
Kadir Cetinkaya 549e87f3d0
[clangd] Fix bad include 2020-04-06 21:36:54 +02:00
Kadir Cetinkaya c31367e95c
[clangd] Build ASTs only with fresh preambles or after building a new preamble
Summary:
This is another step for out-of-order preamble builds. To keep the
diagnostic behavior same, we only build ASTs either with "usable" preambles,
the ones that are fully applicable to a given ParseInput, or after building a
new preamble. Which is the same behaviour as what we do today. ASTs
built in the latter is called golden ASTs.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76725
2020-04-06 21:20:17 +02:00
Kadir Cetinkaya 6b85032c95
[clangd] Update TUStatus api to accommodate preamble thread
Summary:
TUStatus api had a single thread in mind. This introudces a section
action to represent state of the preamble thread. In the file status extension,
we keep old behavior almost the same. We only prepend current task with a
`parsing includes` if preamble thread is working. We omit the idle thread in the
output unless both threads are idle.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76304
2020-04-06 21:20:17 +02:00
Kadir Cetinkaya 276a95bdf2
[clangd] Decouple preambleworker from astworker, NFCI
Summary:
First step to enable deferred preamble builds. Not intending to land it
alone, will have follow-ups that will implement full deferred build
functionality and will land after all of them are ready.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76125
2020-04-06 21:20:16 +02:00
Johannes Doerfert 97aa593a83 [OpenMP] Fix layering problem with FrontendOpenMP
Summary:
ASTMatchers is used in various places and it now exposes the
LLVMFrontendOpenMP library to its users without them needing to depend
on it explicitly.

Reviewers: lebedev.ri

Subscribers: mgorny, yaxunl, bollu, guansong, martong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77574
2020-04-06 13:04:26 -05:00
Paula Toth 00a5755897 [clang-tidy] Add check llvmlibc-implementation-in-namespace.
Summary:
This check makes sure all llvm-libc implementations falls within the `__llvm_libc` namespace.

Reviewers: alexfh, aaron.ballman, hokein, njames93

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, libc-commits, mgorny, xazax.hun, MaskRay, cfe-commits, sivachandra

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D76818
2020-04-06 10:49:49 -07:00
Reid Kleckner 76221c734e Remove llvm::Error include form Diagnostic.h
Saves ~400 related LLVM ADT. llvm/ADT/Error.h takes 90ms to parse.

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
    | grep '^[-+] ' | sort | uniq -c | sort -nr
    403 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Error.h
    403 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm-c/Error.h
    397 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Format.h
    397 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Debug.h
    377 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/StringExtras.h
    158 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm-c/ExternC.h
    138 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/ErrorOr.h
     13 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/raw_ostream.h
     13 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SmallString.h
      5 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/Twine.h
2020-04-06 10:42:17 -07:00
Johannes Doerfert 9e1af172ee [OpenMP][FIX] Add missing cmake dependence needed after 931c0cd713 2020-04-06 09:01:43 -05:00
Johannes Doerfert 8ea07f62a6 [OpenMP] Add extra qualification to OpenMP clause id
Forgot to adjust this use in 419a559c5a.
2020-04-05 23:10:58 -05:00
Kazuaki Ishizaki dd5571d51a [clang-tools-extra] NFC: Fix trivial typo in documents and comments
Differential Revision: https://reviews.llvm.org/D77458
2020-04-05 15:28:40 +09:00
Kazuaki Ishizaki abdd042bb7 [clang-tools-extra] NFC: Fix trivial typo in documents and comments
Differential Revision: https://reviews.llvm.org/D77458
2020-04-05 11:26:19 +09:00
Tamás Zolnai 0f9e1e3ae7 [clang-tidy]: fix false positive of cert-oop54-cpp check.
Summary:
It seems we need a different matcher for binary operator
in a template context.

Fixes this issue:
https://bugs.llvm.org/show_bug.cgi?id=44499

Reviewers: aaron.ballman, alexfh, hokein, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D76990
2020-04-04 17:19:17 +02:00
Sam McCall ebd522aaa8 [clangd] Tweak parseDocumentation loop to use raw lines. NFC
This clears the way for the raw lines themselves to be parsed easily.

(Okay, one functional change: fix punctuation linebreaks with trailing WS)
2020-04-04 08:07:51 +02:00
Sam McCall a975fde23a [clang] Annotate trivial getters and setters on hover.
Summary: (Only if their definitions are visible and they have no other docs)

Reviewers: kadircet

Subscribers: jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77408
2020-04-04 07:15:12 +02:00
Reid Kleckner ba1ffd25c1 [OpenMP][NFC] Remove the need to include `OpenMPClause.h`
See rational here: https://reviews.llvm.org/D76173#1922916
Time to compile Attr.h in isolation goes from 2.6s to 1.8s.

Original patch by Johannes, plus some additions from Reid to fix some
clang tooling targets.

Effect on transitive includes is marginal, though:

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
   | grep '^[-+] ' | sort | uniq -c | sort -nr
    104 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/AST/OpenMPClause.h
     87 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPContext.h
     19 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SmallSet.h
     19 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SetVector.h
     14 -    /usr/include/c++/9/set
...

Differential Revision: https://reviews.llvm.org/D76184
2020-04-03 13:27:52 -07:00
Nathan James 2c7ea1c4c5 [clang-tidy] Address false positive in modernize-use-default-member-init
Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=45363 | incorrect warning emitted by "modernize-use-default-member-init" (new to 10.0.0) ]].

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77199
2020-04-03 19:43:46 +01:00
Sam McCall 164ed7b1d0 [clangd] Enable some nice clang-tidy checks by default.
Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77348
2020-04-03 15:40:07 +02:00
Benjamin Kramer 02cb21df3f Make helpers static. NFC. 2020-04-03 12:48:25 +02:00
Sam McCall 9e3063eace [clangd] Support textDocument/semanticTokens/edits
Summary:
This returns incremental highlights as a set of edits against the
previous highlights.

Server-side, we compute the full set of highlights, this just saves
wire-format size.

For now, the diff used is trivial: everything from the first change to
the last change is sent as a single edit.

The wire format is grungy - the replacement offset/length refer to
positions in the encoded array instead of the logical list of tokens.
We use token-oriented structs and translating to LSP forms when serializing.
This departs from LSP (but is consistent with semanticTokens today).

Tested in VSCode insiders (with a patched client to enable experimental
features).

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77225
2020-04-02 17:38:29 +02:00
Sam McCall fc830106e1 [clangd] Don't send semanticHighlights to clients that support semanticTokens.
Summary: This allows the standard mechanism to gracefully displace the old one.

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77206
2020-04-02 17:38:02 +02:00
Adam Czachorowski 24bb2d1e77 [clangd] Add a tweak for adding "using" statement.
Summary:
This triggers on types and function calls with namespace qualifiers. The
action is to remove the qualifier and instead add a "using" statement at
appropriate place.

It is not always clear where to add the "using" line. Right now we find
the nearest "using" line and add it there, thus keeping with local
convention. If there are no usings, we put it at the deepest relevant
namespace level.

This is an initial version only. There are several improvements that
can be made:
* Support for qualifiers that are not purely namespace (e.g.  record
types, etc).
* Removing qualifier from other instances of the same type/call.
* Smarter placement of the "using" line.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: nridge, mgorny, ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76432
2020-04-02 17:37:38 +02:00
Kadir Cetinkaya da8eda1ab1
[clangd] Get rid of redundant make_uniques 2020-04-02 16:52:13 +02:00
Haojian Wu b420065969 [clangd] Fix an assertion crash in ReferenceFinder.
Summary: The assertion is almost correct, but it fails on refs from non-preamble

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77222
2020-04-02 09:29:20 +02:00
Sylvestre Ledru c6a65bb93f clagn-tidy/doc: Add a link to readability-static-accessed-through-instance from readability-convert-member-functions-to-static 2020-04-01 17:01:48 +02:00
Simon Pilgrim 43eca880c6 Fix "control reaches end of non-void function" warning. NFCI. 2020-04-01 14:08:48 +01:00
Kirill Bobyrev db3d64eebb [clangd-vscode] NFC; Improve wording in documentation and update VSCode tasks
Summary:
VSCode tasks are updated to the latest supported versions: deprecated
values are removed and replaced by their new counterparts.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76595
2020-04-01 14:16:55 +02:00
Kadir Cetinkaya 43aa04eb7a
[clangd] Run semaCodeComplete only with a preamble
Summary:
It is used by code completion and signature help. Code completion
already uses a special no-compile mode for missing preambles, so this change is
a no-op for that.

As for signature help, it already blocks for a preamble and missing it implies
clang has failed to parse the preamble and retrying it in signature help likely
will fail again. And even if it doesn't, request latency will be too high to be
useful as parsing preambles is expensive.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77204
2020-04-01 13:02:47 +02:00
Sam McCall 038f03cb5e [clangd] Force delayed-template-parsing off in code completion.
Summary:
It prevents code completion entirely in affected method bodies.
The main reason it's turned on is for compatibility with headers, so we turn it
off for the main file only. This is allowed because it's a compatible langopt.

Fixes https://github.com/clangd/clangd/issues/302

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77176
2020-04-01 11:09:15 +02:00
Haojian Wu 72439b6b95 [clangd] Add a flag to turn on recovery-expr.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77142
2020-04-01 09:03:56 +02:00
Sam McCall 2dee4d4429 [clangd] Don't build clangdserver for (most) completion tests. NFC 2020-03-31 23:09:36 +02:00
Sam McCall 71177ac168 [clangd] Support new semanticTokens request from LSP 3.16.
Summary:
This is a simpler request/response protocol.

Reference: https://github.com/microsoft/vscode-languageserver-node/blob/master/protocol/src/protocol.semanticTokens.proposed.ts

No attempt to support incremental formatting (yet).

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76663
2020-03-31 15:14:35 +02:00
Nathan James 3807079d70 [clang-tidy] Fix crash in readability-redundant-string-cstr
Summary: Addresses [[ https://bugs.llvm.org/show_bug.cgi?id=45286 | clang-tidy-11: Crash in DynTypedMatcher::matches during readability-redundant-string-cstr check ]]

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D76761
2020-03-31 13:27:32 +01:00
Nathan Ridge b9d9968f63 [clangd] Handle clang-tidy suppression comments for diagnostics inside macro expansions
Summary:
Not handling this was a side-effect of being overly cautious when trying
to avoid reading files for which clangd doesn't have the source mapped.

Fixes https://github.com/clangd/clangd/issues/266

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75286
2020-03-29 15:19:13 -04:00
Nathan Ridge 15f1fe1506 clang-format fixes in ClangTidyDiagnosticConsumer.cpp and DiagnosticsTets.cpp
Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77023
2020-03-29 15:19:09 -04:00
Benjamin Kramer 4065e92195 Upgrade some instances of std::sort to llvm::sort. NFC. 2020-03-28 19:23:29 +01:00
Haojian Wu 62dea6e9be Revert "[AST] Build recovery expressions by default for C++."
This reverts commit 0788acbccb.
This reverts commit c2d7a1f79cedfc9fcb518596aa839da4de0adb69:  Revert "[clangd] Add test for FindTarget+RecoveryExpr (which already works). NFC"

It causes a crash on invalid code:

class X {
  decltype(unresolved()) foo;
};
constexpr int s = sizeof(X);
2020-03-26 16:25:32 +01:00
Karl-Johan Karlsson 7055cd42b5 Remove extra ';', NFC
Fixed gcc -Wpedantic warning about extra ';'
2020-03-26 11:23:59 +01:00
Haojian Wu 297a9dac43 [CodeComplete] Don't replace the rest of line in #include completion.
Summary:
The previous behavior was aggressive,
  #include "abc/f^/abc.h"
                foo/  -> candidate
"f/abc.h" is replaced with "foo/", this patch will preserve the "abc.h".

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76770
2020-03-26 11:03:04 +01:00
Sam McCall 159a9f7e76 [AST] Print a<b<c>> without extra spaces in C++11 or later.
Summary: It's not 1998 anymore.

Reviewers: kadircet

Subscribers: jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76801
2020-03-26 09:53:54 +01:00
Sam McCall 6324912592 [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.
Summary:
Now Preferred is always the canonical (first) decl, Definition is always the def
if available.

In practice the index was already forcing this behaviour anyway, so there's no
change. (Unless you weren't using this index, in which case this patch makes
textDocument/declaration and toggling work as expected).

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73369
2020-03-26 09:52:48 +01:00
Haojian Wu a9ab11d408 [AST] Build recovery expressions for nonexistent member exprs.
Summary: Previously, we dropped the AST node for nonexistent member exprs.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76764
2020-03-26 08:50:33 +01:00
Sam McCall c2d7a1f79c [clangd] Add test for FindTarget+RecoveryExpr (which already works). NFC 2020-03-26 00:40:29 +01:00
Sam McCall 43c63349f5 [clangd] Work around gcc bug after 8f237f9b0 2020-03-26 00:06:54 +01:00
Sam McCall 8f237f9b09 [clangd] Support multiple cursors in selectionRange.
Summary:
One change: because there's no way to signal failure individually for
each cursor, we now "succeed" with an empty range with no parent if a
cursor doesn't point at anything.

Reviewers: usaxena95

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76741
2020-03-25 17:59:09 +01:00
Nathan James 6538b4393d [clang-apply-replacements] No longer deduplucates replacements from the same TU
Summary:
clang-apply-replacements currently deduplicates all diagnostic replacements. However if you get a duplicated replacement from one TU then its expected that it should not be deduplicated. This goes some way to solving [[ https://bugs.llvm.org/show_bug.cgi?id=45150 | export-fixes to yaml adds extra newlines and breaks offsets. ]]

Take this example yaml.
```
---
MainSourceFile:  '/home/nathan/test/test.cpp'
Diagnostics:
  - DiagnosticName:  readability-braces-around-statements
    DiagnosticMessage:
      Message:         statement should be inside braces
      FilePath:        '/home/nathan/test/test.cpp'
      FileOffset:      14
      Replacements:
        - FilePath:        '/home/nathan/test/test.cpp'
          Offset:          14
          Length:          0
          ReplacementText: ' {'
        - FilePath:        '/home/nathan/test/test.cpp'
          Offset:          28
          Length:          0
          ReplacementText: '

}'
  - DiagnosticName:  readability-braces-around-statements
    DiagnosticMessage:
      Message:         statement should be inside braces
      FilePath:        '/home/nathan/test/test.cpp'
      FileOffset:      20
      Replacements:
        - FilePath:        '/home/nathan/test/test.cpp'
          Offset:          20
          Length:          0
          ReplacementText: ' {'
        - FilePath:        '/home/nathan/test/test.cpp'
          Offset:          28
          Length:          0
          ReplacementText: '

}'
...```

The current behaviour is to deduplicate the text insertions at Offset 28 and only apply one of the replacements.
However as both of these replacements came from the same translation unit we can be confident they were both meant to be applied together
The new behaviour won't deduplicate the text insertion and instead insert both of the replacements.
If the duplicate replacement is found inside different translation units (from a header file change perhaps) then they will still be deduplicated as before.

Reviewers: aaron.ballman, gribozavr2, klimek, ymandel

Reviewed By: ymandel

Subscribers: ymandel, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76054
2020-03-25 09:36:36 +00:00
Haojian Wu 0788acbccb [AST] Build recovery expressions by default for C++.
Update the existing tests.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76696
2020-03-25 09:00:48 +01:00
Lorenz Junglas b194e7d631 [clangd] Change line break behaviour for hoverinfo
`parseDocumentation` retains hard line breaks and removes soft line
breaks inside documentation comments.
Wether a line break is hard or soft is determined by the following rules
(some of which have been discussed in
https://github.com/clangd/clangd/issues/95):

Line breaks that are preceded by a punctuation are retained
Line breaks that are followed by "interesting characters" (e.g. Markdown
syntax, doxygen commands) are retained
All other line breaks are removed

Related issue: https://github.com/clangd/clangd/issues/95

Differential Revision: https://reviews.llvm.org/D76094
2020-03-24 12:41:08 +01:00
Sam McCall edf6a19adf [clangd] Rename theia-derived semantic highlighting protocol. NFC
This feature is being added to LSP with a different (request-response)
protocol in 3.16, so this should avoid some confusion.
2020-03-24 00:39:47 +01:00
Nathan James 7693a9b931 [clang-tidy] Fix RenamerClangTidy handling qualified TypeLocs
Summary:
Previously if a type was accessed with a qualifier, RenamerClangTidy wouldn't rename the TypeLoc, this patch addresses this shortfall by trying to find the Unqualified TypeLoc first. Also fixed a broken test case that was dependent on this broken behaviour.

Example:
```
struct a{};

void foo(const a&);
void foo(a&);
void foo(a);
void foo(a&&);
void foo(const a);
```
exec `-checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.StructCase, value: CamelCase}]}" -fix`
Current Behaviour:
```
struct A{};

void foo(const a&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const a);
```
Proposed new behaviour:
```
struct A{};

void foo(const A&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const A);
```

Reviewers: aaron.ballman, gribozavr2, alexfh

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76549
2020-03-23 13:45:34 +00:00
Whisperity df5fa48739 [clang-tidy][NFC] Add missing check group docs and order entries
Differential Revision: https://reviews.llvm.org/D76541
2020-03-23 11:05:34 +01:00
Sylvestre Ledru 986051749c doc: use the right url to bugzilla 2020-03-22 22:49:40 +01:00
abelkocsis 770df90451 [clang-tidy] my work: fix sphinx docs 2020-03-21 12:29:39 +01:00
abelkocsis 0f4c70dd3e [clang-tidy] Add spuriously-wake-up-functions check
Summary:
According to
https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON54-CPP.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
and
https://wiki.sei.cmu.edu/confluence/display/c/CON36-C.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
misc-spuriously-wake-up-functions check is created. The check finds
`cnd_wait` or `wait` function calls in an `IfStmt` and  warns the user to
replace it with a `WhileStmt` or use it with a lambda parameter.

Reviewers: aaron.ballman, alexfh, hokein, jfb, Charusso

Reviewed By: aaron.ballman

Subscribers: sylvestre.ledru, whisperity, Eugene.Zelenko, mgorny, dexonsmith, cfe-commits, gerazo, xazax.hun, steakhal, Charusso

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D70876
2020-03-21 12:04:03 +01:00
Bjorn Pettersson c6d799156a [clangd] Skip ClangdVFSTest.TestStackOverflow when address sanitizer is used
Summary:
The ClangdVFSTest.TestStackOverflow unittest does not seem to work
when building the test with address sanitizer activated. Afaict the
goal is to get a constexpr depth error, rather than stack overflow.
But with asan instrumentation we do get stack overflow complaints
from asan. As a workaround this patch simply disables the test case,
when being built with address sanitizer activated.

Reviewers: sammccall, Dmitry.Kozhevnikov

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76533
2020-03-21 11:07:45 +01:00
Paula Toth 556b917fff [clang-tidy] Merge common code between llvmlibc-restrict-system-libc-headers and portability-restrict-system-includes
Summary:
Made llvmlibc::RestrictSystemLibcHeadersCheck a subclass of protability::RestrictSystemIncludesCheck to re-use common code between the two.
This also adds the ability to white list linux development headers.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: mgorny, xazax.hun, MaskRay, cfe-commits, sivachandra

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D76395
2020-03-20 15:53:05 -07:00
Nathan Ridge b89202e842 [clangd] Do not trigger go-to-def textual fallback inside string literals
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76098
2020-03-19 17:24:45 -04:00
Adam Czachorowski 55b92dcb35 [clangd] Fix elog message when preamble build fails.
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76429
2020-03-19 15:09:46 +01:00
Nathan James 1365ab4b63 [clang-tidy] RenamerClangTidy now correctly renames `using namespace` decls
Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=45039 | readability-identifier-naming doesn't rename using namespace correctly. ]]

Reviewers: aaron.ballman, gribozavr2, JonasToth, hokein, alexfh

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75220
2020-03-18 22:14:40 +00:00
Alex Cameron 9bb5685b21 [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=27702
I wasn't sure how this type of thing is usually tested. So any advice would be appreciated.
`check-llvm`, `check-clang` and `check-clang-tools` are clean for me.
**C++98**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
  "directory": "/home/tetsuo/dev/llvm-project/test",
  "command": "/usr/bin/c++      -std=gnu++98 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
  "file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
3053 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&' or 'Foo' [misc-unconventional-assign-operator]
  Foo &operator=(Foo &Other) {
  ^
Suppressed 3052 warnings (3052 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
**C++17**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
  "directory": "/home/tetsuo/dev/llvm-project/test",
  "command": "/usr/bin/c++      -std=gnu++17 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
  "file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
5377 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&', 'Foo&&' or 'Foo' [misc-unconventional-assign-operator]
  Foo &operator=(Foo &Other) {
  ^
Suppressed 5376 warnings (5376 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

Reviewers: njames93, MaskRay, alexfh, hokein, aaron.ballman

Reviewed By: njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D75901
2020-03-18 21:39:23 +00:00
Nathan Ridge 31b7f0ed6a [clangd] Extend findTarget()'s dependent name heuristic to handle enumerators
Fixes https://github.com/clangd/clangd/issues/296

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76103
2020-03-17 18:13:07 -04:00
Sam McCall 704cd4d5d0 [clangd] Only minimally escape text when rendering to markdown.
Summary:
Conservatively escaping everything is bad in coc.nvim which shows the markdown
to the user, and we have reports of it causing problems for other parsers.

Fixes https://github.com/clangd/clangd/issues/301

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75687
2020-03-17 17:10:20 +01:00
Haojian Wu 8a593e29ab [AST] Correct the CXXOperatorCallExpr source range.
Summary:
Previously, the range for "->" CXXOperatorCallExpr is the range of the
class object (not including the operator!), e.g. "[[vector_ptr]]->size()".

This patch includes the range of the operator, which fixes the issue
where clangd doesn't go to the overloaded operator "->" definition.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76128
2020-03-16 16:51:10 +01:00
Paweł Barań 2f20417ef0 Add AllowMissingMoveFunctionsWhenCopyIsDeleted flag to cppcoreguidelines-special-member-functions
The flag allows classes to don't define move operations when copy operations
are explicitly deleted. This flag is related to Google C++ Style Guide
https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types
2020-03-16 08:14:48 -04:00
Tamás Zolnai 04410c565a [clang-tidy] extend bugprone-signed-char-misuse check.
Summary:
Cover a new use case when using a 'signed char' as an integer
might lead to issue with non-ASCII characters. Comparing
a 'signed char' with an 'unsigned char' using equality / unequality
operator produces an unexpected result for non-ASCII characters.

Reviewers: aaron.ballman, alexfh, hokein, njames93

Reviewed By: njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75749
2020-03-14 20:00:00 +01:00
Jan Korous 42b7827411 [clangd] Add json::Object->Value conversion workaround for older compilers
The build was broken for clang-3.8 which we still support.
2020-03-13 14:01:33 -07:00
Hyrum Wright 3860b2a0bd [clang-tidy] Update Abseil Duration Conversion check to find more cases.
This change improves the check to handle cases with internal scalar
multiplication.

Differential Revision: https://reviews.llvm.org/D75558
2020-03-13 12:52:37 -04:00
Kim Viggedal 512767eb3f Add CppCoreGuidelines I.2 "Avoid non-const global variables" check
Cpp Core Guideline I.2, a.k.a "Avoid non-const global variables"
For detailed documentation, see:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#i2-avoid-non-const-global-variables
2020-03-13 10:05:13 -04:00
Kadir Cetinkaya ecd3e678bb
[clangd] Populate PreambleData::CompileCommand and make use of it inside buildPreamble
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75996
2020-03-13 09:40:47 +01:00
Sam McCall dc4cd43904 [clangd] Add a textual fallback for go-to-definition
Summary:
This facilitates performing go-to-definition in contexts where AST-based
resolution does not work, such as comments, string literals, preprocessor
disabled regions, and macro definitions, based on textual lookup in the index.

Partially fixes https://github.com/clangd/clangd/issues/241

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72874
2020-03-12 16:33:08 -04:00
Paula Toth eb41cc6198 [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.
Summary: This adds a new module to enforce standards specific to the llvm-libc project. This change also adds the first check which restricts user from including system libc headers accidentally which can lead to subtle bugs that would be a challenge to detect.

Reviewers: alexfh, hokein, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: juliehockett, arphaman, jfb, abrachet, sivachandra, Eugene.Zelenko, njames93, mgorny, xazax.hun, MaskRay, cfe-commits

Tags: #clang-tools-extra, #libc-project, #clang

Differential Revision: https://reviews.llvm.org/D75332
2020-03-12 11:46:05 -07:00
Jonathan Roelofs 2c9cf9f4dd [clang-tidy] New check: bugprone-suspicious-include
Detects and fixes suspicious code like: `#include "foo.cpp"`.

Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20

https://reviews.llvm.org/D74669
2020-03-12 09:59:28 -06:00
Sam McCall 966cad0c65 [clangd] Add README pointing to docs, bugtracker etc. NFC 2020-03-12 14:00:08 +01:00
Sam McCall 57e81a2f64 [clangd] Redirect documentation to clangd.llvm.org.
Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76053
2020-03-12 11:45:40 +01:00
Reid Kleckner d7c5037e6b Prune TargetInfo.h include from ParsedAttr.h, NFC
Saves ~400 includes of related headers:

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
    | grep '^[-+] ' | sort | uniq -c | sort -nr
    468 -    llvm-project/clang/include/clang/Basic/TargetInfo.h
    468 -    llvm-project/clang/include/clang/Basic/TargetCXXABI.h
    368 -    llvm-project/llvm/include/llvm/Support/CodeGen.h
    368 -    llvm-project/clang/include/clang/Basic/XRayInstr.h
    368 -    llvm-project/clang/include/clang/Basic/CodeGenOptions.h
    368 -    llvm-project/clang/include/clang/Basic/CodeGenOptions.def
    367 -    llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h
    367 -    llvm-project/clang/include/clang/Basic/DebugInfoOptions.h
2020-03-11 20:47:11 -07:00
Reid Kleckner d6497a521b Add missing StringMap.h inclusion, apparently clangd is not covered by check-clang-tools zzz 2020-03-11 16:47:49 -07:00
Reid Kleckner e08464fb45 Avoid including FileManager.h from SourceManager.h
Most clients of SourceManager.h need to do things like turning source
locations into file & line number pairs, but this doesn't require
bringing in FileManager.h and LLVM's FS headers.

The main code change here is to sink SM::createFileID into the cpp file.
I reason that this is not performance critical because it doesn't happen
on the diagnostic path, it happens along the paths of macro expansion
(could be hot) and new includes (less hot).

Saves some includes:
    309 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h
    272 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h
    271 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h
    267 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h
    266 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h

Differential Revision: https://reviews.llvm.org/D75406
2020-03-11 13:53:12 -07:00
Paula Toth f1736f7a2a [clang-tidy] Mock system headers for portability-restrict-system-includes tests.
Summary: Didn't realize that headers such as stddef.h may not exist on all systems. This patch mocks the headers so that the check's tests work on all systems.  (:

Reviewers: RKSimon, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D76015
2020-03-11 12:13:27 -07:00
Haojian Wu d83ade4506 [clangd] Improve the "max limit" error message in rename, NFC.
previously, we emited "exceeds the max limit 49" which was weird, now we
emit "exceeds the max limit 50".
2020-03-11 16:13:46 +01:00
Hubert Tong 48121a5743 [cmake] Link libclangDaemonTweaks with clangFormat
Speculative fix for buildbot failure in
http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1881/steps/build%20stage%201/logs/stdio

Cause appears to be D75716.
2020-03-10 21:31:10 -04:00
Paula Toth 54928ba0ec [clang-tidy] Use more widely available headers for protability-restrict-system-includes-check's test 2020-03-10 16:54:11 -07:00
Paula Toth ddfcda0256 [clang-tidy] Fix warning from my previous patch in ReleaseNotes.txt 2020-03-10 14:01:23 -07:00
Nathan Ridge 445195ba6c [clangd] Have visibleNamespaces() and getEligiblePoints() take a LangOptions rather than a FormatStyle
Summary:
These functions only use the FormatStyle to obtain a LangOptions via
format::getFormattingLangOpts(), and some callers can more easily obtain
a LangOptions more directly.

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75716
2020-03-10 16:45:41 -04:00
Nathan Ridge 484402abac [clangd] Run clang-format on CodeComplete.cpp and SourceCodeTests.cpp
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75959
2020-03-10 16:45:14 -04:00
Paula Toth ebdb98f254 [clang-tidy] Move fuchsia-restrict-system-includes to portability module for general use.
Summary:
Created a general check for restrict-system-includes under portability as recommend in the comments under D75332. I also fleshed out the user facing documentation to show examples for common use-cases such as allow-list, block-list, and wild carding.

Removed fuchsia's check as per phosek sugguestion.

Reviewers: aaron.ballman, phosek, alexfh, hokein, njames93

Reviewed By: phosek

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, phosek, cfe-commits, MaskRay

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D75786
2020-03-10 13:33:06 -07:00
Nathan James 66945b62f4 Add Optional overload to DiagnosticBuilder operator <<
Reviewers: aaron.ballman, gribozavr2, lebedev.ri

Reviewed By: gribozavr2

Subscribers: wuzish, nemanjai, kbarton, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75714
2020-03-10 17:44:10 +00:00
Kadir Cetinkaya 39eebe68b5
[clangd] Use a separate RunningTask flag instead of leaving a broken request on top of the queue
Summary:
This helps us prevent races when scheduler (or any other thread) tries
to read a request while it's still running.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75927
2020-03-10 18:25:35 +01:00
Nico Weber 714466bf36 Revert "[clang-tidy] New check: bugprone-suspicious-include"
This reverts commit 1e0669bfe0
(and follow-ups 698a127129 and
52bbdad7d6).
The tests fail fail on Windows, see https://reviews.llvm.org/D74669
2020-03-10 10:28:20 -04:00
Nathan James 1fc5be0669 [NFC] Tweak OptionsUtils 2020-03-10 12:50:58 +00:00
Nathan James 97572fa6e9 [NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in clang-tidy matchers 2020-03-10 00:42:21 +00:00
Jonathan Roelofs 52bbdad7d6 [clang-tidy][docs] Post-commit feedback on D74669 2020-03-09 16:51:41 -06:00
Jonathan Roelofs 2e9d33bccd Add missing list.rst entry 2020-03-09 16:27:35 -06:00
Jonathan Roelofs 698a127129 release notes: fix new check name 2020-03-09 16:11:35 -06:00
Jonathan Roelofs 1e0669bfe0 [clang-tidy] New check: bugprone-suspicious-include
Detects and fixes suspicious code like: `#include "foo.cpp"`.

Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20

https://reviews.llvm.org/D74669
2020-03-09 15:54:32 -06:00
Jonathan Roelofs c71ef7a85d Drop HEADER_ per review feedback on D74669 2020-03-09 12:14:22 -06:00
Jonathan Roelofs 47caa69120 [clang-tidy] Use ; as separator for HeaderFileExtensions
... and deprecate use of ',' for the same.

https://reviews.llvm.org/D75621
2020-03-09 11:32:44 -06:00
Jonathan Roelofs 3486cc014b [clang-tidy] Generalize HeaderFileExtensions.{h,cpp}. NFC
https://reviews.llvm.org/D75489
2020-03-09 11:32:44 -06:00
Haojian Wu e669d81715 [clangd] Bump vscode-clangd v0.0.21.
CHANGELOG:
- better ranking for completions
- enable dot-to-arrow fix in code completion
2020-03-09 15:36:49 +01:00
Haojian Wu 6ba0a4ec3b [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.
Summary:
The previous issue is that the item was filtered out by vscode, because
the prefix (which contains ".") are not matched against the filterText.

This patch works around it by adjusting the item filterText, inspired by
https://reviews.llvm.org/D75623.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75739
2020-03-09 14:02:08 +01:00
Nathan James 2ce821cbc9 Fix build failure from rG223a43ee8d89 2020-03-09 08:12:52 +00:00
Nathan James 223a43ee8d [clang-tidy] [NFC] Remove unnecessary matchers
Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75803
2020-03-09 07:38:15 +00:00
Nathan James fc3c80c386 [ASTMatchers] adds isComparisonOperator to BinaryOperator and CXXOperatorCallExpr
Reviewers: aaron.ballman, gribozavr2

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75800
2020-03-09 00:05:10 +00:00
Petr Hosek 7003f64c1e [clang-doc] Improving Markdown Output
This change has two components. The moves the generated file
for a namespace to the directory named after the namespace in
a file named 'index.<format>'. This greatly improves the browsing
experience since the index page is shown by default for a directory.

The second improves the markdown output by adding the links to the
referenced pages for children objects and the link back to the source
code.

Patch By: Clayton

Differential Revision: https://reviews.llvm.org/D72954
2020-03-06 17:37:08 -08:00
Sam McCall c86f794bd5 [clangd][VSCode] Force VSCode to use the ranking provided by clangd.
Summary:
Clangd's approach is to provide lots of completions, and let ranking sort them
out. This relies on various important signals (Quality.h), without which the
large completion lists are extremely spammy.

Even with a completion result exactly at the cursor, vscode looks backwards and
tries to match the presumed partial-identifier against filterText, and uses
the result to rank, with sortText only used as a tiebreak.
By prepending the partial-identifier to the filterText, we can force the match
to be perfect and so give sortText full control of the ranking.

Full sad story: https://github.com/microsoft/language-server-protocol/issues/898

It's possible to do this on the server side too of course, and switch it on
with an initialization option. But it's a little easier in the extension, it
will get the fix to users of old clangd versions, and other editors

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75623
2020-03-06 13:34:25 +01:00
Jonas Devlieghere 45e2c6d956 [clang-tools-extra/clang-tidy] Mark modernize-make-shared as offering fixes
The list incorrectly states that modernize-make-shared does not offer
fixes, which is incorrect. Just like modernize-make-unique it does.
2020-03-05 21:45:20 -08:00
Nathan James dcba401a39 Fix 45129: Incorrect generated configuration modernize-make-shared.IncludeStyle 2020-03-06 00:07:08 +00:00
Nathan Ridge a7c655f148 [clangd] Remove vsc-extension-quickstart.md from the vscode-clangd plugin
Summary:

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75292
2020-03-05 15:28:40 -05:00
Utkarsh Saxena e397a0a5c3 [clangd] Add instrumentation mode in clangd for metrics collection.
Summary:
This patch adds an instrumentation mode for clangd (enabled by
corresponding option in cc_opts).
If this mode is enabled then user can specify callbacks to run on the
final code completion result.

Moreover the CodeCompletion::Score will contain the detailed Quality and
Relevance signals used to compute the score when this mode is enabled.
These are required because we do not any place in which the final
candidates (scored and sorted) are available along with the above
signals. The signals are temporary structures in `addCandidate`.

The callback is needed as it gives access to many data structures that
are internal to CodeCompleteFlow and are available once Sema has run. Eg:
ScopeDistnace and FileDistance.

If this mode is disabled (as in default) then Score would just contain 2
shared pointers (null). Thus cost(memory/time) increase for the default
mode would be fairly cheap and insignificant.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75603
2020-03-05 12:39:15 +01:00
Sam McCall 5abfe646f5 [clangd] Fix test (it worked by coincidence before) 2020-03-05 10:11:55 +01:00
Sam McCall 2cd33e6fe6 [clangd] Track document versions, include them with diags, enhance logs
Summary:
This ties to an LSP feature (diagnostic versioning) but really a lot
of the value is in being able to log what's happening with file versions
and queues more descriptively and clearly.

As such it's fairly invasive, for a logging patch :-\

Key decisions:
 - at the LSP layer, we don't reqire the client to provide versions (LSP
   makes it mandatory but we never enforced it). If not provided,
   versions start at 0 and increment. DraftStore handles this.
 - don't propagate magically using contexts, but rather manually:
   addDocument -> ParseInputs -> (ParsedAST, Preamble, various callbacks)
   Context-propagation would hide the versions from ClangdServer, which
   would make producing good log messages hard
 - within ClangdServer, treat versions as opaque and unordered.
   std::string is a convenient type for this, and allows richer versions
   for embedders. They're "mandatory" but "null" is a reasonable default.

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75582
2020-03-05 01:22:32 +01:00
Sam McCall e6d9b2cb92 [clangd] Remove unused+broken InvalidationError class. 2020-03-05 01:08:40 +01:00
Petr Hosek ea086d10ce Revert "[clang-doc] Improving Markdown Output"
This reverts commit 45499f3801, it's
still failing on Windows bots.
2020-03-04 16:00:22 -08:00
Sam McCall c627b120eb [clangd] Cancel certain operations if the file changes before we start.
Summary:
Otherwise they can force us to build lots of snapshots that we don't need.
Particularly, try to do this for operations that are frequently
generated by editors without explicit user interaction, and where
editing the file makes the result less useful. (Code action
enumeration is a good example).

https://github.com/clangd/clangd/issues/298

This doesn't return the "right" LSP error code (ContentModified) to the client,
we need to teach the cancellation API to distinguish between different causes.

Reviewers: kadircet

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75602
2020-03-05 00:10:07 +01:00
Sam McCall 2be4569719 [clangd] Fix isInsideMainFile to be aware of preamble.
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75460
2020-03-04 23:57:21 +01:00
Petr Hosek 45499f3801 [clang-doc] Improving Markdown Output
This change has two components. The moves the generated file
for a namespace to the directory named after the namespace in
a file named 'index.<format>'. This greatly improves the browsing
experience since the index page is shown by default for a directory.

The second improves the markdown output by adding the links to the
referenced pages for children objects and the link back to the source
code.

Patch By: Clayton

Differential Revision: https://reviews.llvm.org/D72954
2020-03-04 14:42:07 -08:00
Kadir Cetinkaya 2128a79c46
[clangd] Fix buildbots 2020-03-04 12:41:26 +01:00
Kadir Cetinkaya a8706b22a6
[clangd] Fix windows buildbots 2020-03-04 12:07:23 +01:00
Kadir Cetinkaya ec7c8bae84
[clangd] Make use of syntax tokens in ReplayPreamble
Summary: Replace usage of RawLexer with syntax tokens inside ReplayPreamble.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74842
2020-03-04 11:01:35 +01:00
Kadir Cetinkaya e6b8181895
[clangd] Fix early selection for non-vardecl declarators
Summary:
Selection tree was performing an early claim only for VarDecls, but
there are other cases where we can have declarators, e.g. FieldDecls. This patch
extends the early claim logic to all types of declarators.

Fixes https://github.com/clangd/clangd/issues/292

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75106
2020-03-04 11:01:35 +01:00
Nathan Ridge e70a9f3850 [clangd] Handle go-to-definition in macro invocations where the target appears in the expansion multiple times
Fixes https://github.com/clangd/clangd/issues/234

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72041
2020-03-03 15:52:05 -05:00
Nathan James e40a742a50 [clang-tidy] Change checks to use new isLanguageVersionSupported restriction
Summary: Modifies all checks that are language version dependent to use `isLanguageVersionSupported`

Reviewers: jdoerfert, lebedev.ri, aaron.ballman, gribozavr2, Eugene.Zelenko

Reviewed By: gribozavr2

Subscribers: wuzish, nemanjai, xazax.hun, hiraditya, kbarton, steven_wu, dexonsmith, arphaman, lebedev.ri, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75340
2020-03-03 16:43:45 +00:00
Sam McCall caf5a4d57f [clangd] Propagate versions into DraftStore, assigning where missing. NFC
This prepares for propagating versions through the server so diagnostics
etc can be versioned.
2020-03-03 16:20:13 +01:00
Sam McCall c0b27c4891 [clangd] Remove unused getDocument() API 2020-03-03 14:53:59 +01:00
Kadir Cetinkaya 3755039c99
[clangd] Get rid of getTokenRange helper
Summary:

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75474
2020-03-03 14:30:42 +01:00
Kadir Cetinkaya 3302af83ef
[clangd] Make use of token buffers in semantic highlighting
Reviewers: hokein, sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75447
2020-03-03 14:30:41 +01:00
Sam McCall 6525a6b7b2 [clangd] Use structured PublishDiagnosticsParams. NFC 2020-03-03 12:44:40 +01:00
Sam McCall 6f7dca97fb [clangd] Send InitializeResult.serverInfo 2020-03-03 12:25:58 +01:00
serge-sans-paille 1454c27b60 Syndicate, test and fix base64 implementation
llvm/Support/Base64, fix its implementation and provide a decent test suite.

Previous implementation code was using + operator instead of | to combine

results, which is a problem when shifting signed values. (0xFF << 16) is
implicitly converted to a (signed) int, and thus results in 0xffff0000,
h is
negative. Combining negative numbers with a + in that context is not what we
want to do.

This is a recommit of 5a1958f267 with UB removved.

This fixes https://github.com/llvm/llvm-project/issues/149.

Differential Revision: https://reviews.llvm.org/D75057
2020-03-03 12:17:53 +01:00
Sam McCall 8a2d294ed0 [clangd] Handle `initialized` notification (no-op to suppress log message) 2020-03-03 12:12:30 +01:00
Nathan James b2666ccca0 [clangd] DefineOutline won't copy virtual specifiers on methods
Summary:
The define out of line refactor tool previously would copy the `virtual`, `override` and `final` specifier into the out of line method definition.
This results in malformed code as those specifiers aren't allowed outside the class definition.

Reviewers: hokein, kadircet

Reviewed By: kadircet

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

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75429
2020-03-03 09:59:14 +00:00
Sam McCall e7de00cf97 [clangd] Split locateSymbolAt into several component functions, to allow later reuse. NFC 2020-03-02 18:45:25 +01:00
Mitch Phillips 49684f9db5 Revert "Syndicate, test and fix base64 implementation"
This reverts commit 5a1958f267.

This change broke the UBSan build bots. See
https://reviews.llvm.org/D75057 for more information.
2020-03-02 09:33:22 -08:00
Haojian Wu 9ad1099224 [clangd] No need to query ctor refs in cross-file rename.
Summary:
This patch reverts 2c5ee78de1,
now kythe (https://github.com/kythe/kythe/issues/4381) supports returning ctors refs as part of class references, so
there is no need to query the ctor refs in the index (this would also
make the results worse, lots of duplications)

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75439
2020-03-02 15:21:32 +01:00
Kadir Cetinkaya 3ae2fc7a8b
[clangd] Get rid of lexer usage in locateMacroAt
Reviewers: sammccall, hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75331
2020-03-02 13:31:12 +01:00
Kadir Cetinkaya c24c89d6f0
[clangd] Get rid of unnecessary source transformations in locateMacroAt
Summary:
All callers are already passing spelling locations to locateMacroAt.
Also there's no point at looking at macro expansion for figuring out undefs as
it is forbidden to have PP directives inside macro bodies.
Also fixes a bug when the previous sourcelocation is unavailable.

Reviewers: sammccall, hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75259
2020-03-02 13:31:12 +01:00
Joe Turner 071002ffdb [clang-tidy] Copy the Ranges field from the Diagnostic when creating the ClangTidyError
Differential Revision: https://reviews.llvm.org/D68887
2020-03-02 12:39:16 +01:00
serge-sans-paille 5a1958f267 Syndicate, test and fix base64 implementation
Move Base64 implementation from clangd/SemanticHighlighting to
llvm/Support/Base64, fix its implementation and provide a decent test suite.

Previous implementation code was using + operator instead of | to combine some
results, which is a problem when shifting signed values. (0xFF << 16) is
implicitly converted to a (signed) int, and thus results in 0xffff0000, which is
negative. Combining negative numbers with a + in that context is not what we
want to do.

This fixes https://github.com/llvm/llvm-project/issues/149.

Differential Revision: https://reviews.llvm.org/D75057
2020-03-02 10:02:25 +01:00
Haojian Wu c443b610bf [clangd] Remove the deprecated clangdServer::rename API, NFC.
There is no actual user of it now.
2020-03-02 09:48:25 +01:00
Stefanos Baziotis 21390eab4c [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle() 2020-03-01 19:17:21 +02:00
Karasev Nikita 365c99fd7d Skip TemplateSpecializedType in modernize-pass-by-value.
Existing 'modernize-pass-by-value' check works only with non template values in
initializers. Fixes PR37210.
2020-02-28 09:17:16 -05:00
Nathan James 39c4246e1e [clang-tidy] Added virtual isLanguageVersionSupported to ClangTidyCheck
Summary:
Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=45045 | Tune inspections to a specific C++ standard. ]]
Moves the isLanguageVersionSupported virtual function from `MakeSmartPtrCheck` to the base `ClangTidyCheck` class.
This will disable registering matchers or pp callbacks on unsupported language versions for a check.
Having it as a standalone function is cleaner than manually disabling the check in the register function and should hopefully
encourage check developers to actually restrict the check based on language version.
As an added bonus this could enable automatic detection of what language version a check runs on for the purpose of documentation generation

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

Reviewed By: gribozavr2

Subscribers: xazax.hun, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75289
2020-02-28 13:05:05 +00:00
Kadir Cetinkaya 48fad110e0
[clangd] Get rid of lexer usage in ObjCLocalizeStringLiteral tweak
Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75230
2020-02-28 09:38:26 +01:00
Kadir Cetinkaya 98bb094c1e
[clangd] Use tokenize instead of raw lexer in SourceCode/lex
Reviewers: hokein, sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75249
2020-02-28 09:38:26 +01:00
Reid Kleckner 86565c1309 Avoid SourceManager.h include in RawCommentList.h, add missing incs
SourceManager.h includes FileManager.h, which is expensive due to
dependencies on LLVM FS headers.

Remove dead BeforeThanCompare specialization.

Sink ASTContext::addComment to cpp file.

This reduces the time to compile a file that does nothing but include
ASTContext.h from ~3.4s to ~2.8s for me.

Saves these includes:
    219 -    ../clang/include/clang/Basic/SourceManager.h
    204 -    ../clang/include/clang/Basic/FileSystemOptions.h
    204 -    ../clang/include/clang/Basic/FileManager.h
    165 -    ../llvm/include/llvm/Support/VirtualFileSystem.h
    164 -    ../llvm/include/llvm/Support/SourceMgr.h
    164 -    ../llvm/include/llvm/Support/SMLoc.h
    161 -    ../llvm/include/llvm/Support/Path.h
    141 -    ../llvm/include/llvm/ADT/BitVector.h
    128 -    ../llvm/include/llvm/Support/MemoryBuffer.h
    124 -    ../llvm/include/llvm/Support/FileSystem.h
    124 -    ../llvm/include/llvm/Support/Chrono.h
    124 -    .../MSVCSTL/include/stack
    122 -    ../llvm/include/llvm-c/Types.h
    122 -    ../llvm/include/llvm/Support/NativeFormatting.h
    122 -    ../llvm/include/llvm/Support/FormatProviders.h
    122 -    ../llvm/include/llvm/Support/CBindingWrapping.h
    122 -    .../MSVCSTL/include/xtimec.h
    122 -    .../MSVCSTL/include/ratio
    122 -    .../MSVCSTL/include/chrono
    121 -    ../llvm/include/llvm/Support/FormatVariadicDetails.h
    118 -    ../llvm/include/llvm/Support/MD5.h
    109 -    .../MSVCSTL/include/deque
    105 -    ../llvm/include/llvm/Support/Host.h
    105 -    ../llvm/include/llvm/Support/Endian.h

Reviewed By: aaron.ballman, hans

Differential Revision: https://reviews.llvm.org/D75279
2020-02-27 13:49:40 -08:00
Joe Turner b26c88e3c6 [clang-tidy] Store all ranges in clang::tooling::Diagnostic
Summary: Instead of dropping all the ranges associated with a Diagnostic when
converting them to a ClangTidy error, instead attach them to the ClangTidyError,
so they can be consumed by other APIs.

Patch by Joe Turner <joturner@google.com>.
Differential Revision: https://reviews.llvm.org/D69782
2020-02-27 19:39:42 +01:00
Haojian Wu aa324c5441 [clangd][NFC] Don't query the index if the rename symbol is function
local.

This would save an unnecessary index query when renaming a function
local symbol in cross-file rename mode.
2020-02-27 15:04:51 +01:00
Kadir Cetinkaya f31fc1043d
[clangd] Get rid of lexer usage in AST.cpp
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75193
2020-02-27 09:54:21 +01:00
Kadir Cetinkaya 2bb7774ddf
[clangd] Get rid of getBeginningOfIdentifier helper
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75176
2020-02-27 09:34:45 +01:00
Kadir Cetinkaya 2011d14296
[clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations
Summary:
Get rid of calls to lexer and unnecessary source location
transformations.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75166
2020-02-26 17:51:27 +01:00
Haojian Wu 02323a3d5f [clangd] use printQualifiedName to skip the inlinenamespace qualifiers.
Summary:
symbols in libcpp are inside the inline namespace, printQualifierAsString will
print the inline namespace, which is unexpected.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75174
2020-02-26 16:22:45 +01:00
Haojian Wu 5560a78820 [clangd] Bump index version number.
Summary:
Though we don't have new changes to the index format, we have changes to
symbol collector, e.g. collect marcos, spelled references. Bump the
version to force background-index to rebuild.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74127
2020-02-26 13:43:16 +01:00
Haojian Wu 4feca71df0 Fix the clangd-fuzzer build error. 2020-02-26 10:13:13 +01:00
Haojian Wu 34d0e1bd6d [clangd] Expose the rename LimitFiles option to the C++ API, NFC.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74834
2020-02-26 09:33:58 +01:00
Haojian Wu e6d0bad843 [clang-rename] Add the USR of incomplete decl to the USRSet.
Summary:
This fixes a clangd rename issue, which is missing the reference of
an incomplete specialization.

Unfortunately, I didn't reproduce this issue in clang-rename, I guess
the input `FoundDecl` of AdditionalUSRFinder is different in clangd vs
clang-rename, clang-rename uses the underlying CXXRecordDecl of the
ClassTemplateDecl, which is fixed in 5d862c042b;
while clangd-rename uses the ClassTemplateDecl.

Reviewers: kbobyrev

Reviewed By: kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74829
2020-02-25 16:56:35 +01:00
Kadir Cetinkaya e09754ccef
[clangd] Migrate Lexer usages in TypeHierarchy to TokenBuffers
Summary:
Also fixes a bug, resulting from directly using ND.getEndLoc() for end
location of the range. As ND.getEndLoc() points to the begining of the last
token, whereas it should point one past the end, since LSP ranges are half open
(exclusive on the end).

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74850
2020-02-25 15:36:45 +01:00
Kadir Cetinkaya 555d5ad85a
[clangd] Disable ExtractVariable for C
Summary:
Currently extract variable doesn't spell the type explicitly and just
uses an `auto` instead, which is not available in C.

Reviewers: usaxena95

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75053
2020-02-25 12:15:15 +01:00
Shoaib Meenai e34ddc09f4 [arcconfig] Delete subproject arcconfigs
From https://secure.phabricator.com/book/phabricator/article/arcanist_new_project/:

> An .arcconfig file is a JSON file which you check into your project's root.

I've done some experimentation, and it looks like the subproject
.arcconfigs just get ignored, as the documentation says. Given that
we're fully on the monorepo now, it's safe to remove them.

Differential Revision: https://reviews.llvm.org/D74996
2020-02-24 16:20:36 -08:00
Sam McCall e9997cfb4d [clangd] Try to fix buildbots - copy elision not happening here? 2020-02-23 21:12:26 +01:00
Sam McCall be6d07c920 [clangd] Reapply b60896fad9 Fall back to selecting token-before-cursor if token-after-cursor fails.
This reverts commit b4b9706d5d.
Now avoiding expected<vector<selection>> in favor of expected<vector<unique_ptr<selection>>>
2020-02-23 20:17:30 +01:00
Sam McCall b4b9706d5d Revert "[clangd] Reapply b60896fad9 Fall back to selecting token-before-cursor if token-after-cursor fails."
This reverts commit a2ce807eb7.

Buildbot failures on GCC due to SelectionTree not being copyable, and
instantiating vector<Selection> in the tweak-handling in ClangdServer.
2020-02-23 16:34:49 +01:00
Sam McCall a2ce807eb7 [clangd] Reapply b60896fad9 Fall back to selecting token-before-cursor if token-after-cursor fails.
This reverts commit 6af1ad20d6.
2020-02-23 16:17:46 +01:00
Sam McCall 7d3f8b1e2d [clangd] Debounce rebuilds responsively to rebuild times.
Summary:
Old: 500ms always. New: rebuild time, up to 500ms.

Fixes https://github.com/clangd/clangd/issues/275

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73949
2020-02-23 15:34:28 +01:00
Haojian Wu bc498198b5 [clangd] Allow renaming class templates in cross-file rename.
Summary:
It was disabled because we don't handle explicit template
specialization well (due to the index limitation).

renaming templates is normal in practic, rather than disabling it, this patch
allows to rename them though it is not perfect (just a known limitation).

Context: https://github.com/clangd/clangd/issues/280

Reviewers: kbobyrev

Reviewed By: kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74709
2020-02-21 09:57:10 +01:00
Haojian Wu e326f52430 [clangd] Fix the incomplete template specialization in findTarget.
Summary:
FindTarget doesn't report the TemplatePattern for incomplete
specialization.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74900
2020-02-21 09:42:02 +01:00
Eugene Zelenko db8911aad7 [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section
Summary:
Also use //check// in add_new_check.py for terminology consistency.

PS

My GitHub ID is [[ https://github.com/EugeneZelenko | EugeneZelenko ]], if it's necessary for attribution.

Reviewers: alexfh, hokein, aaron.ballman, njames93, MyDeveloperDay

Reviewed By: njames93

Subscribers: Andi, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D73580
2020-02-20 17:31:08 +00:00
Haojian Wu bb9e92bad5 [clang][Index] Fix the incomplete instantiations in libindex.
Summary:
libindex will canonicalize references to template instantiations:
- 1) reference to an explicit template specialization, report the specializatiion
- 2) otherwise, report the primary template

but 2) is not true for incomplete instantiations, this patch fixes this.

Fixes https://github.com/clangd/clangd/issues/287

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74830
2020-02-20 14:42:30 +01:00
Roman Lebedev c8f9e526bc
[clang-tidy] misc-no-recursion: point to the function defs, not decls
Results in slightly better UX.
This actually was the initial intent, but it kinda got lost along the way.
2020-02-20 14:17:30 +03:00
Douglas Yung 6730f390a1 Fixup test after changes made in 709fd989.
The change added a test that required exceptions, so enable that explicitly
so that it works on platforms that default to having exceptions disabled
(like the PS4).
2020-02-19 18:39:54 -08:00
Nathan James d1d5180e69 [NFC] Fix issues with clang-tidy checks list.rst
Added FixItHint comments to ReservedIdentifierCheck and IdentifierNamingCheck to trick the python scripts into detecting a fix it is provided as it can't see the FixItHints in RenamerClangTidyCheck.cpp
2020-02-19 23:19:09 +00:00
Alexander Lanin 709fd989b6 [clang-tidy] fix readability-redundant-member-init auto-fix of Function-try-block
Summary: This fixes https://bugs.llvm.org/show_bug.cgi?id=39310

Reviewers: malcolm.parsons, ioeric

Reviewed By: malcolm.parsons

Subscribers: xazax.hun

Tags: #clang-format, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D74800
2020-02-19 23:04:05 +00:00
Balázs Kéri fa6aef4427 [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.
Summary:
The check accepts now a `return (*this = something);` as return
statement too (beneath of `*this`).

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: aaron.ballman

Subscribers: xazax.hun, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D74529
2020-02-19 10:07:34 +01:00