Commit Graph

3534 Commits

Author SHA1 Message Date
Haojian Wu c6ddb46162 [clangd] Share getSymbolID implementation.
Summary: And remove all duplicated implementation.

Reviewers: ioeric

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

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

llvm-svn: 339116
2018-08-07 08:57:52 +00:00
Haojian Wu 65ac321092 [clangd] Index Interfaces for Xrefs
Summary:
This is the first step of implementing Xrefs in clangd:
  - add index interfaces, and related data structures.

Reviewers: sammccall

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

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

llvm-svn: 339011
2018-08-06 13:14:32 +00:00
Matt Morehouse ff538a56d3 [clangd] Fix fuzzer build.
llvm-svn: 338947
2018-08-04 01:51:10 +00:00
Martin Bohme b7d621b7b6 [clang-tidy] Sequence init statements, declarations, and conditions correctly in if, switch, and while
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36516.

Reviewers: ilya-biryukov, alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 338932
2018-08-03 22:20:04 +00:00
Alex Lorenz b411cf3275 [clangd] capitalize diagnostic messages
The diagnostic messages that are sent to the client from Clangd are now always
capitalized.

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

llvm-svn: 338919
2018-08-03 20:43:28 +00:00
Simon Marchi 70e209b816 [clangd] Add test for changing build configuration
Summary:
This patch adds tests for the two ways of changing build configuration
(pointing to a particular compile_commands.json):

- Through the workspace/didChangeConfiguration notification.
- Through the initialize request.

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

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

llvm-svn: 338914
2018-08-03 19:40:19 +00:00
Shuai Wang c2d93d6619 Use ExprMutationAnalyzer in performance-unnecessary-value-param
Summary:
This yields better recall as ExprMutationAnalyzer is more accurate.

One common pattern this check is now able to catch is:
```
void foo(std::vector<X> v) {
  for (const auto& elm : v) {
    // ...
  }
}
```

Reviewers: george.karpenkov

Subscribers: a.sidorin, cfe-commits

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

llvm-svn: 338903
2018-08-03 17:23:37 +00:00
Julie Hockett 87072165cf [clang-doc] Fix unique_ptr error on bots
Explicitly return the base unique_ptr type, as some of the older
compilers on the bots don't support full C++11.

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

llvm-svn: 338796
2018-08-03 00:40:11 +00:00
Julie Hockett 8899c29b1e Reland "[clang-doc] Refactoring mapper to map by scope"
Relanding with a minor change to prevent an assertion on release bots.

The result of this adjusted mapper pass is that all Function and Enum
infos are absorbed into the info of their enclosing scope (i.e. the class
or namespace in which they are defined). Namespace and Record infos are
passed along to the final output, but the second pass creates a reference
to each in its parent scope. As a result, the top-level final outputs are
Namespaces and Records.

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

llvm-svn: 338763
2018-08-02 20:10:17 +00:00
Julie Hockett a9cb2dd8b0 Revert "[clang-doc] Refactoring mapper to map by scope"
This reverts commit r338738 as it's breaking the bots.

llvm-svn: 338748
2018-08-02 18:01:37 +00:00
Julie Hockett 1f430693b1 [clang-doc] Refactoring mapper to map by scope
The result of this adjusted mapper pass is that all Function and Enum
infos are absorbed into the info of their enclosing scope (i.e. the
class or namespace in which they are defined). Namespace and Record
infos are passed along to the final output, but the second pass creates
a reference to each in its parent scope. As a result, the top-level final
outputs are Namespaces and Records.

llvm-svn: 338738
2018-08-02 17:17:19 +00:00
Eric Liu fa63e9831e Replace hardcoded format styles in a few tools with the default style in libFormat.
llvm-svn: 338696
2018-08-02 10:30:56 +00:00
Alex Lorenz f808786a65 [clangd] allow clients to control the compilation database by passing in
compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request

This commit allows clangd to use an in-memory compilation database that's
controlled from the LSP client (-compile_args_from=lsp). It extends the
'workspace/didChangeConfiguration' request to allow the client to pass in a
compilation database subset that needs to be updated in the workspace.

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

llvm-svn: 338597
2018-08-01 17:39:29 +00:00
Hans Wennborg 91aa2fdf56 Update docs version and clear release notes after 8.0.0 version bump
llvm-svn: 338559
2018-08-01 14:09:00 +00:00
Haojian Wu 59dad0f7cd [clangd] Correct the namespace of ParsedAST forward declaration, NFC.
llvm-svn: 338526
2018-08-01 12:50:44 +00:00
Simon Marchi 8801678979 [clangd] Receive compilationDatabasePath in 'initialize' request
Summary:
That way, as soon as the "initialize" is received by the server, it can start
parsing/indexing with a valid compilation database and not have to wait for a
an initial 'didChangeConfiguration' that might or might not happen.
Then, when the user changes configuration, a didChangeConfiguration can be sent.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>

Reviewers: malaperle

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

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

llvm-svn: 338518
2018-08-01 11:28:49 +00:00
Haojian Wu 1ffd6b222a [clangd] Make SymbolLocation => bool conversion explicitly.
Summary:
The implicit bool conversion could happen superisingly, e.g. when
checking `if (Loc1 == Loc2)`, the compiler will convert SymbolLocation to
bool before comparing (because we don't define operator `==` for SymbolLocation).

Reviewers: sammccall

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

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

llvm-svn: 338517
2018-08-01 11:24:50 +00:00
Jonas Toth 0b8fdd2847 [clang-tidy] add all clang-tidy modules to plugin
Summary:
This patch addresses PR38359 and adds all existing clang-tidy
modules to the plugin that can be used together with libclang.

Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov

Reviewed By: alexfh

Subscribers: srhines, mgorny, xazax.hun, cfe-commits

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

llvm-svn: 338393
2018-07-31 15:23:49 +00:00
Ilya Biryukov ec9bd36f2d [clangd] Do not build AST if no diagnostics were requested
Summary:
It can be removed from the cache before the first access anyway, so
building it can be a waste of time.

Reviewers: ioeric

Reviewed By: ioeric

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

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

llvm-svn: 338378
2018-07-31 13:45:37 +00:00
Ilya Biryukov 442c283218 [clangd] Report diagnostics even if WantDiags::No AST was reused
Summary:
After r338256, clangd stopped reporting diagnostics if WantDiags::No request
is followed by a WantDiags::Yes request but the AST can be reused.

Reviewers: ioeric

Reviewed By: ioeric

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

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

llvm-svn: 338361
2018-07-31 11:47:52 +00:00
Ilya Biryukov ce979dd24a [clangd] Remove outdated comment. NFC
llvm-svn: 338260
2018-07-30 15:55:13 +00:00
Ilya Biryukov 24ec072e18 [clangd] Do not remove AST from cache if nothing changed
We were previously clearing the AST cache if the inputs and the
preamble were the same, which is not desired.

llvm-svn: 338256
2018-07-30 15:30:45 +00:00
Ilya Biryukov 4055d8c9fa [clangd] Fix a comment. NFC
llvm-svn: 338241
2018-07-30 11:46:25 +00:00
Raoul Wols 8f5e06fcd1 [clangd] Add command-line option
to suppress the space and the circular dot prepended in a completion label.

llvm-svn: 338223
2018-07-29 19:12:42 +00:00
Ilya Biryukov 778a33a0bb [clang-tidy] Fix a crash in fuchsia-multiple-inheritance
Summary: See the test case for a repro.

Reviewers: juliehockett, ioeric, hokein, aaron.ballman

Reviewed By: hokein

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

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

llvm-svn: 338124
2018-07-27 14:05:39 +00:00
Kirill Bobyrev a522c1cf86 [clangd] Return Dex Iterators
The original Dex Iterators patch (https://reviews.llvm.org/rL338017)
caused problems for Clang 3.6 and Clang 3.7 due to the compiler bug
which prevented inferring template parameter (`Size`) in create(And|Or)?
functions. It was reverted in https://reviews.llvm.org/rL338054.

In this revision the mentioned helper functions were replaced with
variadic templated versions.

Proposed changes were tested on multiple compiler versions, including
Clang 3.6 which originally caused the failure.

llvm-svn: 338116
2018-07-27 09:54:27 +00:00
Kirill Bobyrev d75b556c56 Revert Clangd Dex Iterators patch
This reverts two revisions:

* https://reviews.llvm.org/rL338017
* https://reviews.llvm.org/rL338028

They caused crash for Clang 3.6 & Clang 3.7 buildbots, it was
reported by Jeremy Morse.

llvm-svn: 338054
2018-07-26 18:25:48 +00:00
Ilya Biryukov 1d5e640428 [clangd] Use 'const Twine&' instead of 'Twine'. NFC
To fix clang-tidy warning

llvm-svn: 338037
2018-07-26 16:13:52 +00:00
Kirill Bobyrev 3f9758ee55 [clangd] Fix unit tests for Dex
Iterators took temporary objects in constructors, objects were
invalidated when built with recent Clang which resulted in crashes.

llvm-svn: 338028
2018-07-26 14:00:00 +00:00
Alexander Kornienko 7b6993d445 [clang-tidy] Fix llvm.org/PR38315 (support type aliases in modernize-shrink-to-fit)
llvm-svn: 338025
2018-07-26 13:13:54 +00:00
Ilya Biryukov 74f2655dc7 [clangd] Fix (most) naming warnings from clang-tidy. NFC
llvm-svn: 338021
2018-07-26 12:05:31 +00:00
Kirill Bobyrev bea258d3d7 [clangd] Proof-of-concept query iterators for Dex symbol index
This patch introduces three essential types of query iterators:
`DocumentIterator`, `AndIterator`, `OrIterator`. It provides a
convenient API for query tree generation and serves as a building block
for the next generation symbol index - Dex. Currently, many
optimizations are missed to improve code readability and to serve as the
reference implementation. Potential improvements are briefly mentioned
in `FIXME`s and will be addressed in the following patches.

Dex RFC in the mailing list:
http://lists.llvm.org/pipermail/clangd-dev/2018-July/000022.html

Iterators, their applications and potential extensions are explained in
detail in the design proposal:
https://docs.google.com/document/d/1C-A6PGT6TynyaX4PXyExNMiGmJ2jL1UwV91Kyx11gOI/edit#heading=h.903u1zon9nkj

Reviewers: ioeric, sammccall, ilya-biryukov

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

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

llvm-svn: 338017
2018-07-26 10:42:31 +00:00
Kirill Bobyrev f8823f3ccc [clangd] Give an example for symbol-builder usage
`global-symbol-builder` help message mentions `-executor=<string>`
option, but doesn't give any example of what the value could be

Assuming the most popular use case to be building the whole project
index, help message should probably give an example of such usage.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 338015
2018-07-26 09:41:24 +00:00
Ilya Biryukov 1720113ace [clangd] Do not rebuild AST if inputs have not changed
Summary:
If the contents are the same, the update most likely comes from the
fact that compile commands were invalidated. In that case we want to
avoid rebuilds in case the compile commands are actually the same.

Reviewers: ioeric

Reviewed By: ioeric

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

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

llvm-svn: 338012
2018-07-26 09:21:07 +00:00
Eric Liu 84bd5db209 [clangd] Use a sigmoid style function for #usages boost in symbol quality.
Summary:
This has a shape to similar logarithm function but grows much slower for
large #usages.

Metrics: https://reviews.llvm.org/P8096

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 337907
2018-07-25 11:26:35 +00:00
Kirill Bobyrev 5e82f05e7a [clangd] Introduce Dex symbol index search tokens
This patch introduces the core building block of the next-generation
Clangd symbol index - Dex. Search tokens are the keys in the inverted
index and represent a characteristic of a specific symbol: examples of
search token types (Token Namespaces) are

* Trigrams -  these are essential for unqualified symbol name fuzzy
search * Scopes for filtering the symbols by the namespace * Paths, e.g.
these can be used to uprank symbols defined close to the edited file

This patch outlines the generic for such token namespaces, but only
implements trigram generation.

The intuition behind trigram generation algorithm is that each extracted
trigram is a valid sequence for Fuzzy Matcher jumps, proposed
implementation utilize existing FuzzyMatcher API for segmentation and
trigram extraction.

However, trigrams generation algorithm for the query string is different
from the previous one: it simply yields sequences of 3 consecutive
lowercased valid characters (letters, digits).

Dex RFC in the mailing list:
http://lists.llvm.org/pipermail/clangd-dev/2018-July/000022.html

The trigram generation techniques are described in detail in the
proposal:
https://docs.google.com/document/d/1C-A6PGT6TynyaX4PXyExNMiGmJ2jL1UwV91Kyx11gOI/edit#heading=h.903u1zon9nkj

Reviewers: sammccall, ioeric, ilya-biryukovA

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

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

llvm-svn: 337901
2018-07-25 10:34:57 +00:00
Benjamin Kramer 11eef3b3e9 [clangd] Guard fuzzer against empty inputs.
llvm-svn: 337860
2018-07-24 21:50:06 +00:00
Eric Liu d7de81172e [clangd] Tune down quality score for class constructors so that it's ranked after class types.
Summary:
Currently, class constructors have the same score as the class types, and they
are often ranked before class types. This is often not desireable and can
be annoying when snippet is enabled and constructor signatures are added.

Metrics:

```
==================================================================================================
                                        OVERALL
==================================================================================================
  Total measurements: 111117 (+0)
  All measurements:
	MRR: 64.06 (+0.20)	Top-5: 75.73% (+0.14%)	Top-100: 93.71% (+0.01%)
  Full identifiers:
	MRR: 98.25 (+0.55)	Top-5: 99.04% (+0.03%)	Top-100: 99.16% (+0.00%)
  Filter length 0-5:
	MRR:      15.23 (+0.02)		50.50 (-0.02)		65.04 (+0.11)		70.75 (+0.19)		74.37 (+0.25)		79.43 (+0.32)
	Top-5:    40.90% (+0.03%)		74.52% (+0.03%)		87.23% (+0.15%)		91.68% (+0.08%)		93.68% (+0.14%)		95.87% (+0.12%)
	Top-100:  68.21% (+0.02%)		96.28% (+0.07%)		98.43% (+0.00%)		98.72% (+0.00%)		98.74% (+0.01%)		98.81% (+0.00%)
==================================================================================================
                                        DEFAULT
==================================================================================================
  Total measurements: 57535 (+0)
  All measurements:
	MRR: 58.07 (+0.37)	Top-5: 69.94% (+0.26%)	Top-100: 90.14% (+0.03%)
  Full identifiers:
	MRR: 97.13 (+1.05)	Top-5: 98.14% (+0.06%)	Top-100: 98.34% (+0.00%)
  Filter length 0-5:
	MRR:      13.91 (+0.00)		38.53 (+0.01)		55.58 (+0.21)		63.63 (+0.30)		69.23 (+0.47)		72.87 (+0.60)
	Top-5:    24.99% (+0.00%)		62.70% (+0.06%)		82.80% (+0.30%)		88.66% (+0.16%)		92.02% (+0.27%)		93.53% (+0.21%)
	Top-100:  51.56% (+0.05%)		93.19% (+0.13%)		97.30% (+0.00%)		97.81% (+0.00%)		97.85% (+0.01%)		97.79% (+0.00%)
```

Remark:
- The full-id completions have +1.05 MRR improvement.
- There is no noticeable impact on EXPLICIT_MEMBER_ACCESS and WANT_LOCAL.

Reviewers: sammccall

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

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

llvm-svn: 337816
2018-07-24 08:51:52 +00:00
Jonas Toth ad2524f9fc [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Summary:
The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where
pointer arithmetic is used, but does not check values where the pointer types
is deduced via `auto`. This patch adjusts this behaviour and solved
PR36489.
I accidentally commited a wrong patch, this Differential is meant to have a
correct revision description and code attached to it.
Because the patch was accepted by aaron.ballman already, i will just commit
it.
See https://reviews.llvm.org/D48717 for the old differntial (contains wrong
code from the mixup)

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

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

llvm-svn: 337716
2018-07-23 17:46:17 +00:00
Jonas Toth 966b5203bd Revert "[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well"
I applied the wrong patch.

llvm-svn: 337712
2018-07-23 17:34:25 +00:00
Jonas Toth 369e4fd353 [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Summary:
The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where
pointer arithmetic is used, but does not check values where the pointer types
is deduced via ``auto``. This patch adjusts this behaviour and solved
PR36489.

Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov

Reviewed By: alexfh, aaron.ballman

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

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

llvm-svn: 337710
2018-07-23 17:13:06 +00:00
Jonas Toth e8217f6a1f [clang-tidy] remove private decltypeType in TrailingReturnType
Summary:
This patch removes a private matcher in fuchsia/TrailingReturnType check because
the matcher is now in ASTMatchers

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 337707
2018-07-23 16:30:13 +00:00
Simon Marchi 802a685b72 [clangd] Fix category in clangd-vscode's package.json
Summary:
When opening package.json, vscode shows:

  Use 'Programming  Languages' instead

Replacing "Languages" with this fixes it.

Reviewers: ilya-biryukov

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

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

llvm-svn: 337697
2018-07-23 14:32:12 +00:00
Eric Liu 5d2a807f25 [clangd] Penalize non-instance members when accessed via class instances.
Summary:
The following are metrics for explicit member access completions. There is no
noticeable impact on other completion types.

Before:
EXPLICIT_MEMBER_ACCESS
  Total measurements: 24382
  All measurements: MRR: 62.27	Top10: 80.21%	Top-100: 94.48%
  Full identifiers: MRR: 98.81	Top10: 99.89%	Top-100: 99.95%
  0-5 filter len:
	MRR:  13.25	46.31	62.47	67.77	70.40	81.91
	Top-10:  29%	74%	84%	91%	91%	97%
	Top-100:  67%	99%	99%	99%	99%	100%

After:
EXPLICIT_MEMBER_ACCESS
  Total measurements: 24382
  All measurements: MRR: 63.18	Top10: 80.58%	Top-100: 95.07%
  Full identifiers: MRR: 98.79	Top10: 99.89%	Top-100: 99.95%
  0-5 filter len:
	MRR:  13.84	48.39	63.55	68.83	71.28	82.64
	Top-10:  30%	75%	84%	91%	91%	97%
	Top-100:  70%	99%	99%	99%	99%	100%

* Top-N: wanted result is found in the first N completion results.
* MRR: Mean reciprocal rank.

Remark: the change seems to have minor positive impact. Although the improvement
is relatively small, down-ranking non-instance members in instance member access
should reduce noise in the completion results.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 337681
2018-07-23 10:56:37 +00:00
Benjamin Kramer 7f288269f0 [clangd] Unbreak fuzzer build.
llvm-svn: 337655
2018-07-22 15:55:57 +00:00
Julie Hockett b218069826 [clang-doc] Create a script to generate tests
Upstreaming the script I use to generate clang-doc tests (and updating
the existing tests to use it)

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

llvm-svn: 337632
2018-07-20 23:00:34 +00:00
Julie Hockett eb50a2e8d4 [clang-doc] Adding PublicOnly flag
Submitted on behalf of Annie Cherkaev (@anniecherk)

Added a flag which, when enabled, documents only those methods and
fields which have a Public attribute.

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

llvm-svn: 337602
2018-07-20 18:49:55 +00:00
Benjamin Kramer 1434b81601 [clangd] Fix racy use-after-scope in unittest
This only shows up with asan when the stars align in a bad way.

llvm-svn: 337601
2018-07-20 18:45:25 +00:00
Sam McCall f7d1805171 [clangd] FuzzyMatch exposes an API for its word segmentation. NFC
Summary: This is intended to be used for indexing, e.g. in D49417

Reviewers: ioeric, omtcyfz

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

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

llvm-svn: 337527
2018-07-20 08:01:37 +00:00
Eric Liu f433c2dab7 [clangd] Also get scope for RK_pattern completion results.
For exmaple, clas field candidates in constructor initializers can be
RK_Pattern, but they can still have scopes.

llvm-svn: 337396
2018-07-18 15:31:14 +00:00