Commit Graph

3722 Commits

Author SHA1 Message Date
Jonas Toth 5c0f66b1fe [clang-tidy] fix check_clang_tidy to forbid mixing of CHECK-NOTES and CHECK-MESSAGES
Summary:
The check_clang_tidy.py script would allow mixing of `CHECK-NOTES` and `CHECK-MESSAGES` but running `FileCheck` for that would implicitly fail, because `CHECK-NOTES` bails out if there is a warning.

That means a clang-tidy test can not mix these constructs to check warnings with `CHECK-MESSAGES` and notes with `CHECK-NOTES`. The script gives now a clear error if that happens.

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

Reviewed By: lebedev.ri

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 341039
2018-08-30 08:44:27 +00:00
Jonas Toth 51aadb463e [clang-tidy] Add abseil-no-internal-dependencies check
Finds instances where the user depends on internal details and warns them against doing so.
Should not be run on internal Abseil files or Abseil source code.

Patch by hugoeg!

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

llvm-svn: 340928
2018-08-29 14:23:15 +00:00
Aaron Ballman ca5f775dbe Introduce the abseil-redundant-strcat-calls check.
This flags redundant calls to absl::StrCat where the result is being passed to another call to absl::StrCat or absl::StrAppend. Patch by Hugo Gonzalez and Samuel Benzaquen.

llvm-svn: 340918
2018-08-29 11:29:07 +00:00
Aaron Ballman a22d24a36c Introduce the abseil-str-cat-append check.
This flags uses of absl::StrCat when absl::StrAppend should be used instead. Patch by Hugo Gonzalez and Benjamin Kramer.

llvm-svn: 340915
2018-08-29 11:17:31 +00:00
Kirill Bobyrev 8212eae996 [clangd] Switch to Dex by default for the static index
Dex is now mature enough to be used as the default static index. This
patch performs the switch but introduces a hidden flag to allow users
fallback to Mem in case something happens.

Reviewed by: ioeric

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

llvm-svn: 340828
2018-08-28 14:55:05 +00:00
Eric Liu 4e4e5a4e8a [clangd] Use buffered llvm::errs() in the clangd binary.
Summary: Unbuffered stream can cause significant (non-deterministic) latency for the logger.

Reviewers: sammccall

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

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

llvm-svn: 340822
2018-08-28 13:15:50 +00:00
Ilya Biryukov 8f3b3df5f8 [clangd] Remove unused parameter. NFC
llvm-svn: 340816
2018-08-28 11:04:07 +00:00
Ilya Biryukov c572dae405 [clangd] Add some trace::Spans. NFC
llvm-svn: 340815
2018-08-28 10:57:45 +00:00
Haojian Wu d2f7b04d1b [clang-tidy] Abseil: no namepsace check
This check ensures that users of Abseil do not open namespace absl in their code, as that violates our compatibility guidelines.

AbseilMatcher.h written by Hugo Gonzalez.

Patch by Deanna Garcia!

llvm-svn: 340800
2018-08-28 07:48:28 +00:00
Kirill Bobyrev e6d5fd818f Cleanup after rL340729
llvm-svn: 340759
2018-08-27 17:26:43 +00:00
Kirill Bobyrev 5bda3fad00 [docs] Mention clangd-dev in clangd documentation
Since the clangd-dev is intended to be the place for clangd-related
discussions, we should point new users to this mailing list while
probably mentioning cfe-dev, too.

Reviewed by: ioeric

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

llvm-svn: 340749
2018-08-27 15:38:49 +00:00
Kirill Bobyrev b217ddb1bb [clangd] Use TRUE iterator instead of complete posting list
Stop using `$$$` (empty) trigram and generating a posting list with all
items. Since TRUE iterator is already implemented and correctly inserted
when there are no real trigram posting lists, this is a valid
transformation.

Benchmarks show that this simple change allows ~30% speedup on dataset
of real completion queries.

Before

```
-------------------------------------------------------
Benchmark                Time           CPU Iterations
-------------------------------------------------------
DexAdHocQueries    5640321 ns    5640265 ns        120
DexRealQ         939835603 ns  939830296 ns          1
```

After

```
-------------------------------------------------------
Benchmark                Time           CPU Iterations
-------------------------------------------------------
DexAdHocQueries    3452014 ns    3451987 ns        203
DexRealQ         667455912 ns  667455750 ns          1
```

Reviewed by: ilya-biryukov

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

llvm-svn: 340729
2018-08-27 09:47:50 +00:00
Julie Hockett b8ff56c726 [clang-doc] Fix memory leaks
Adds a virtual destructor to the base Info class.

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

llvm-svn: 340620
2018-08-24 16:43:46 +00:00
Kadir Cetinkaya 689bf93b2f [clangd] Initial cancellation mechanism for LSP requests.
Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

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

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

llvm-svn: 340607
2018-08-24 13:09:41 +00:00
Kirill Bobyrev a98961bc84 [clangd] Implement LIMIT iterator
This patch introduces LIMIT iterator, which is very important for
improving the quality of search query. LIMIT iterators can be applied on
top of BOOST iterators to prevent populating query request with a huge
number of low-quality symbols.

Reviewed by: sammccall

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

llvm-svn: 340605
2018-08-24 11:25:43 +00:00
Eric Liu 25d74e9594 [clangd] Speculative code completion index request before Sema is run.
Summary:
For index-based code completion, send an asynchronous speculative index
request, based on the index request for the last code completion on the same
file and the filter text typed before the cursor, before sema code completion
is invoked. This can reduce the code completion latency (by roughly latency of
sema code completion) if the speculative request is the same as the one
generated for the ongoing code completion from sema. As a sequence of code
completions often have the same scopes and proximity paths etc, this should be
effective for a number of code completions.

Trace with speculative index request:{F6997544}

Reviewers: hokein, ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 340604
2018-08-24 11:23:56 +00:00
Kirill Bobyrev fc89001cec [clangd] Log memory usage of DexIndex and MemIndex
This patch prints information about built index size estimation to
verbose logs. This is useful for optimizing memory usage of DexIndex and
comparisons with MemIndex.

Reviewed by: sammccall

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

llvm-svn: 340601
2018-08-24 09:12:54 +00:00
Ilya Biryukov e9fe4db876 [clangd] Allow to merge symbols on-the-fly in global-symbol-builder
Summary:
The new mode avoids serializing and deserializing YAML.
This results in better performance and less memory usage. Reduce phase
is now almost instant.

The default is to use the old mode going through YAML serialization to
allow migrating MapReduce clients that require the old mode to operate
properly. After we migrate the clients, we can switch the default to
the new mode.

Reviewers: hokein, ioeric, kbobyrev, sammccall

Reviewed By: ioeric

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

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

llvm-svn: 340600
2018-08-24 09:03:54 +00:00
Kadir Cetinkaya 0d2e6251ce [clangd] Check for include overlapping looks for only the line now.
Summary:
Currently we match an include only if we are inside filename, with this patch we
will match whenever we are on the starting line of the include.

Reviewers: ilya-biryukov, hokein, ioeric

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 340539
2018-08-23 15:55:27 +00:00
Kadir Cetinkaya f8b85a3d6b [clangd] Suggest code-completions for overriding base class virtual methods.
Summary:
Whenever a code-completion is triggered within a class/struct/union looks at
base classes and figures out non-overriden virtual functions. Than suggests
completions for those.

Reviewers: ilya-biryukov, hokein, ioeric

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 340530
2018-08-23 13:14:50 +00:00
Kadir Cetinkaya 516fcdac6d [clangd] Move function argument snippet disable mechanism from LSP rendering to internal clangd reprensentation.
Summary:
We were handling the EnableFunctionArgSnippets only when we are producing LSP
response. Move that code into CompletionItem generation so that internal clients
can benefit from that as well.

Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 340527
2018-08-23 12:19:39 +00:00
Ilya Biryukov 1326145fdd [clangd] Increase the timeouts in TUScheduler tests to 10 seconds.
Some of them timeout on our buildbots in certain configurations.
The timeouts are there to avoid hanging indefinitely on deadlocks, so
the exact number we put there does not matter.

llvm-svn: 340523
2018-08-23 10:25:07 +00:00
Alex Lorenz 0ce8a7a039 [clangd] send diagnostic categories only when 'categorySupport'
capability was given by the client

After r339738 Clangd started sending categories with each diagnostic, but that
broke the eglot client. This commit puts the categories behind a capability to
fix that breakage.

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

llvm-svn: 340449
2018-08-22 20:30:06 +00:00
Haojian Wu 3425cdc69b [clang-tidy] Add Abseil prefix to documentation
Summary: Adds the Abseil prefix to the list of prefixes in the documentation

Patch by Deanna Garcia!

Reviewers: aaron.ballman, hokein

Reviewed By: hokein

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 340412
2018-08-22 14:03:30 +00:00
Haojian Wu 279d72d37d [clang-tidy] Abseil: faster strsplit delimiter check
This check is an abseil specific check that checks for code using single character string literals as delimiters and transforms the code into characters.

The check was developed internally and has been running at google, this is just
a move to open source the check. It was originally written by @sbenza.

Patch by Deanna Garcia!

llvm-svn: 340411
2018-08-22 13:58:25 +00:00
Ilya Biryukov 22abe49fff [clangd] Get rid of regexes in CanonicalIncludes
Summary: Replace them with suffix mappings.

Reviewers: ioeric, kbobyrev

Reviewed By: ioeric

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

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

llvm-svn: 340410
2018-08-22 13:51:19 +00:00
Kirill Bobyrev 7413e985ea [clangd] Implement BOOST iterator
This patch introduces BOOST iterator - a substantial block for efficient
and high-quality symbol retrieval. The concept of boosting allows
performing computationally inexpensive scoring on the query side so that
the final (expensive) scoring can only be applied on the items with the
highest preliminary score while eliminating the need to score too many
items.

Reviewed by: ilya-biryukov

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

llvm-svn: 340409
2018-08-22 13:44:15 +00:00
Ilya Biryukov 8343baf686 [clangd] Make FileIndex aware of the main file
Summary:
It was previously only indexing the preamble decls. The new
implementation will index both the preamble and the main AST and
report both sets of symbols, preferring the ones from the main AST
whenever the symbol is present in both.
The symbols in the main AST slab always store all information
available in the preamble symbols, possibly adding more,
e.g. definition locations.

Reviewers: hokein, ioeric

Reviewed By: ioeric

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

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

llvm-svn: 340404
2018-08-22 12:43:17 +00:00
Ilya Biryukov c5e44c1805 [clangd] Add callbacks on parsed AST in addition to parsed preambles
Summary:
Will be used for updating the dynamic index on updates to the open files.
Currently we collect only information coming from the preamble
AST. This has a bunch of limitations:
  - Dynamic index misses important information from the body of the
    file, e.g. locations of definitions.
  - XRefs cannot be collected at all, since we can only obtain full
    information for the current file (preamble is parsed with skipped
    function bodies, therefore not reliable).

This patch only adds the new callback, actually updates to the index
will be done in a follow-up patch.

Reviewers: hokein

Reviewed By: hokein

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

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

llvm-svn: 340401
2018-08-22 11:39:16 +00:00
Kirill Bobyrev 14e4700468 [clangd] Cleanup after D50897
The wrong diff that was uploaded to Phabricator was building the wrong
index.

llvm-svn: 340388
2018-08-22 07:17:59 +00:00
Kirill Bobyrev dc41befc4f [clangd] NFC: Fix broken build
llvm-svn: 340263
2018-08-21 10:40:19 +00:00
Kirill Bobyrev 7a94c918a0 [clangd] Allow using experimental Dex index
This patch adds hidden Clangd flag ("use-dex-index") which replaces
(currently) default `MemIndex` with `DexIndex` for the static index.

Reviewed by: ioeric

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

llvm-svn: 340262
2018-08-21 10:32:27 +00:00
Kirill Bobyrev 870aaf2963 [clangd] DexIndex implementation prototype
This patch is a proof-of-concept Dex index implementation. It has
several flaws, which don't allow replacing static MemIndex yet, such as:

* Not being able to handle queries of small size (less than 3 symbols);
  a way to solve this is generating trigrams of smaller size and having
  such incomplete trigrams in the index structure.
* Speed measurements: while manually editing files in Vim and requesting
  autocompletion gives an impression that the performance is at least
  comparable with the current static index, having actual numbers is
  important because we don't want to hurt the users and roll out slow
  code. Eric (@ioeric) suggested that we should only replace MemIndex as
  soon as we have the evidence that this is not a regression in terms of
  performance. An approach which is likely to be successful here is to
  wait until we have benchmark library in the LLVM core repository, which
  is something I have suggested in the LLVM mailing lists, received
  positive feedback on and started working on. I will add a dependency as
  soon as the suggested patch is out for a review (currently there's at
  least one complication which is being addressed by
  https://github.com/google/benchmark/pull/649). Key performance
  improvements for iterators are sorting by cost and the limit iterator.
* Quality measurements: currently, boosting iterator and two-phase
  lookup stage are not implemented, without these the quality is likely to
  be worse than the current implementation can yield. Measuring quality is
  tricky, but another suggestion in the offline discussion was that the
  drop-in replacement should only happen after Boosting iterators
  implementation (and subsequent query enhancement).

The proposed changes do not affect Clangd functionality or performance,
`DexIndex` is only used in unit tests and not in production code.

Reviewed by: ioeric

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

llvm-svn: 340175
2018-08-20 14:39:32 +00:00
Haojian Wu 931b2262d4 [clangd] Simplify the code using UniqueStringSaver, NFC.
llvm-svn: 340161
2018-08-20 09:47:12 +00:00
Kirill Bobyrev 6d8bd7f56a [clangd] NFC: Cleanup Dex Iterator comments and simplify tests
Proposed changes:

* Cleanup comments in `clangd/index/dex/Iterator.h`: Vim's `gq`
  formatting added redundant spaces instead of newlines in few
  places
* Few comments in `OrIterator` are wrong
* Use `EXPECT_TRUE(Condition)` instead of
  `EXPECT_THAT(Condition, true)` (same with `EXPECT_FALSE`)
* Don't expose `dump()` method to the public by misplacing
  `private:`

This patch does not affect functionality.

Reviewed by: ioeric

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

llvm-svn: 340157
2018-08-20 09:16:14 +00:00
Haojian Wu 02465baea2 [clangd] Add missing lock in the lookup.
Reviewers: ioeric

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

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

llvm-svn: 340156
2018-08-20 09:07:59 +00:00
Kirill Bobyrev 30ffdf42f7 [clangd] Implement TRUE Iterator
This patch introduces TRUE Iterator which efficiently handles posting
lists containing all items within `[0, Size)` range.

Reviewed by: ioeric

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

llvm-svn: 340155
2018-08-20 08:47:30 +00:00
Haojian Wu 9ddc1a09d4 [clang-tidy] Add missing check documentation.
llvm-svn: 340075
2018-08-17 19:50:22 +00:00
Kadir Cetinkaya 6c9f15c533 [clangd] Add parantheses while auto-completing functions.
Summary:
Currently we only add parantheses to the functions if snippets are
enabled, which also inserts snippets for parameters into parantheses. Adding a
new option to put only parantheses. Also it moves the cursor within parantheses
or at the end of them by looking at whether completion item has any parameters
or not. Still requires snippets support on the client side.

Reviewers: ioeric, ilya-biryukov, hokein

Reviewed By: ioeric

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 340040
2018-08-17 15:42:54 +00:00
Haojian Wu 5cd630d341 [clang-tidy] Abseil: integral division of Duration check
This check is an abseil specific test that tests to ensure users utilize abseil specific floating point division when trying to divide with abseil duration types.

Patch by Deanna Garcia!

llvm-svn: 340038
2018-08-17 15:19:19 +00:00
Haojian Wu 189aeeef48 [clangd] Add a testcase for empty preamble.
Summary: This is a patch of add a testcase for https://reviews.llvm.org/D50628.

Reviewers: ilya-biryukov

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

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

llvm-svn: 340035
2018-08-17 14:55:57 +00:00
Simon Pilgrim 24d3492aee Fix clangd tests on older compilers
Old versions of gcc struggle with raw string literals inside macros.

llvm-svn: 340009
2018-08-17 10:40:05 +00:00
Kirill Bobyrev 28c804a752 [clangd] NFC: Mark Workspace Symbol feature complete in the documentation
Workspace Symbol implementation was introduced in D44882 and should be
complete now.

Reviewed by: ioeric

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

llvm-svn: 340007
2018-08-17 10:14:31 +00:00
Ilya Biryukov 8a0f76b855 [clangd] Fetch documentation from the Index during signature help
Summary:
Sema can only be used for documentation in the current file, other doc
comments should be fetched from the index.

Reviewers: hokein, ioeric, kadircet

Reviewed By: hokein, kadircet

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

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

llvm-svn: 340005
2018-08-17 09:32:30 +00:00
Ilya Biryukov 5f4a351306 [clangd] Show function documentation in signature help
Summary:
Previously, clangd was trying to show documentation for the active
parameter instead, which is wrong per LSP specification.

Moreover, the code path that attempts to get parameter comments never
succeds, because no attempt is made to parse function doc comment and
extract parameter-specific parts out of it. So we also remove the code
that claims to fetch parameter comments: it is not used anymore and is
incorrect.

Reviewers: hokein, ioeric, kadircet

Reviewed By: ioeric

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 340004
2018-08-17 09:29:38 +00:00
Haojian Wu 4c0c37df4c [clangd] Always use the latest preamble
Summary:
Fix an inconsistent behavior of using `LastBuiltPreamble`/`NewPreamble`
in TUScheduler (see the test for details), AST should always use
NewPreamble. This patch makes LastBuiltPreamble always point to
NewPreamble.

Preamble rarely fails to build, even there are errors in headers, so we
assume it would not cause performace issue for code completion.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 340001
2018-08-17 08:15:22 +00:00
Julie Hockett 921e195633 Revert "Implement a (simple) Markdown generator"
This reverts commit r339948, as it's breaking a few bots in ways that I
can't reproduce right now.

llvm-svn: 339966
2018-08-16 23:50:51 +00:00
Julie Hockett 1bcd1b0324 Implement a (simple) Markdown generator
Implementing a simple Markdown generator from the emitted bitcode
summary of declarations. Very primitive at this point, but will be
expanded. Currently emits an .md file for each class and namespace,
listing its contents.

For a more detailed overview of the tool, see the design document
on the mailing list:
http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html

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

llvm-svn: 339948
2018-08-16 21:54:34 +00:00
Simon Pilgrim 923e4990ff Fixed unused variable warning. NFCI.
llvm-svn: 339879
2018-08-16 13:55:10 +00:00
Kirill Bobyrev 51534ab864 [clangd] NFC: Improve Dex Iterators debugging traits
This patch improves `dex::Iterator` string representation by
incorporating the information about the element which is currently being
pointed to by the `DocumentIterator`.

Reviewed by: ioeric

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

llvm-svn: 339877
2018-08-16 13:19:43 +00:00
Simon Pilgrim 83552ee008 Attempt to fix clangd tests on older compilers
Old gcc versions of gcc struggle with raw string literals inside macros.

Inspired by rL339759

llvm-svn: 339866
2018-08-16 11:41:19 +00:00
Julie Hockett d12ed9bab8 [clang-doc] Explicitly cast to unique_ptr
Older compilers don't like the implicit cast & move when returning a
unique_ptr to an llvm::Expected type.

llvm-svn: 339785
2018-08-15 16:18:46 +00:00
Julie Hockett 46fc95923c Reland "[clang-doc] Updating BitcodeReader to use llvm::Error""
With explicit unique_ptr casts so that bots with older compilers don't
break.

llvm-svn: 339783
2018-08-15 16:02:28 +00:00
Jan Korous 59890002db [clangd][tests] Rename tests of clangd instance termination
Just making testnames better reflect their testing scenarios.

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

llvm-svn: 339782
2018-08-15 15:58:05 +00:00
Jan Korous 61b0758aa9 [clangd][tests] Fix typo in tests - invalid LSP exit message
Syntactically invalid JSON payload was causing clangd to terminate because of unexpected EOF rather than exit as a response to LSP exit message.

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

llvm-svn: 339781
2018-08-15 15:50:45 +00:00
Alex Lorenz 44fdf2dad6 [clangd] update the new test to check for diagnostic's category as well
llvm-svn: 339739
2018-08-14 22:27:03 +00:00
Alex Lorenz 37146431d2 [clangd] add an extension field to LSP to transfer the diagnostic's category
This patch adds a 'category' extension field to the LSP diagnostic that's sent
by Clangd. This extension is always on by default.

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

llvm-svn: 339738
2018-08-14 22:21:40 +00:00
Alex Lorenz 3738dba69b [clangd] add missing test from r339454
I forgot to checkin the test for the fixits into SVN.

llvm-svn: 339737
2018-08-14 22:20:35 +00:00
Kirill Bobyrev 8e35f1e7cb NFC: Enforce good formatting across multiple clang-tools-extra files
This patch improves readability of multiple files in clang-tools-extra
and enforces LLVM Coding Guidelines.

Reviewed by: ioeric

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

llvm-svn: 339687
2018-08-14 16:03:32 +00:00
Julie Hockett c84155ff6c [clang-doc] Fix unused variable
Differential Revision: https://reviews.llvm.org/D50709

llvm-svn: 339685
2018-08-14 15:38:59 +00:00
Kirill Bobyrev 0ef813fa83 [clangd] NFC: Cleanup clangd help message
Add missed space, fix a typo.

Reviewed by: ioeric

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

llvm-svn: 339673
2018-08-14 12:00:39 +00:00
Ilya Biryukov 8fd44bb915 [clangd] Show non-instantiated decls in signatureHelp
Summary:
To avoid producing very verbose output in substitutions involving
typedefs, e.g.
  T -> std::vector<std::string>::iterator
gets turned into an unreadable mess when printed out for libstdc++,
result contains internal types (std::__Vector_iterator<...>) and
expanded well-defined typedefs (std::basic_string<char>).

Until we improve the presentation code in clang, going with
non-instantiated decls looks like a better UX trade-off.

Reviewers: hokein, ioeric, kadircet

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 339665
2018-08-14 09:36:32 +00:00
Julie Hockett 39f47b9286 Revert "[clang-doc] Updating BitcodeReader to use llvm::Error"
This reverts commit r339617 for breaking bots.

llvm-svn: 339620
2018-08-13 21:51:48 +00:00
Julie Hockett 7136abff1c [clang-doc] Updating BitcodeReader to use llvm::Error
llvm-svn: 339617
2018-08-13 21:39:03 +00:00
Julie Hockett 4955422f9e [clang-doc] Pass over function-internal declarations
llvm-svn: 339592
2018-08-13 18:05:50 +00:00
Eugene Zelenko fd709711e2 [Documentation] Remove unnecessary placeholder, grammar fix in Release Notes.
llvm-svn: 339590
2018-08-13 17:55:48 +00:00
Kadir Cetinkaya d4218dcd79 Fix lint tests for D50449
Reviewers: ilya-biryukov, hokein

Reviewed By: hokein

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

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

llvm-svn: 339572
2018-08-13 14:32:19 +00:00
Martin Bohme e47a631d1c [clang-tidy] Recognize [[clang::reinitializes]] attribute in bugprone-use-after-move
Summary:
This allows member functions to be marked as reinitializing the object. After a
moved-from object has been reinitialized, the check will no longer consider it
to be in an indeterminate state.

The patch that adds the attribute itself is at https://reviews.llvm.org/D49911

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

Reviewed By: aaron.ballman

Subscribers: dblaikie, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 339571
2018-08-13 14:24:52 +00:00
Simon Pilgrim 7b31fae983 Fix MSVC 'std::min: no matching overloaded function found' error.
llvm-svn: 339557
2018-08-13 12:24:48 +00:00
Kirill Bobyrev ff2dd9095f [clangd] Generate incomplete trigrams for the Dex index
This patch handles trigram generation "short" identifiers and queries.
Trigram generator produces incomplete trigrams for short names so that
the same query iterator API can be used to match symbols which don't
have enough symbols to form a trigram and correctly handle queries which
also are not sufficient for generating a full trigram.

Reviewed by: ioeric

Differential revision: https://reviews.llvm.org/D50517

llvm-svn: 339548
2018-08-13 08:57:06 +00:00
Kadir Cetinkaya e486e37a09 [clangd] Introduce scoring mechanism for SignatureInformations.
Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 339547
2018-08-13 08:40:05 +00:00
Kadir Cetinkaya a9c9d00016 [clangd] Support textEdit in addition to insertText.
Summary:
Completion replies contains textEdits as well. Note that this change
relies on https://reviews.llvm.org/D50443.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 339543
2018-08-13 08:23:01 +00:00
Aaron Ballman d824f0cbe3 Adding the readability module to the list of dependencies for the C++ Core Guidelines module. Amends r339516 for a failing bot.
llvm-svn: 339517
2018-08-12 14:47:16 +00:00
Aaron Ballman bc8f5ac754 Add a new check to the readability module that flags uses of "magic numbers" (both floating-point and integral).
Patch by Florin Iucha <florin@signbit.net>

llvm-svn: 339516
2018-08-12 14:35:13 +00:00
Simon Marchi 25f1f7325f [clangd] Avoid duplicates in findDefinitions response
Summary:
When compile_commands.json contains some source files expressed as
relative paths, we can get duplicate responses to findDefinitions.  The
responses only differ by the URI, which are different versions of the
same file:

    "result": [
        {
            ...
            "uri": "file:///home/emaisin/src/ls-interact/cpp-test/build/../src/first.h"
        },
        {
            ...
            "uri": "file:///home/emaisin/src/ls-interact/cpp-test/src/first.h"
        }
    ]

In getAbsoluteFilePath, we try to obtain the realpath of the FileEntry
by calling tryGetRealPathName.  However, this can fail and return an
empty string.  It may be bug a bug in clang, but in any case we should
fall back to computing it ourselves if it happens.

I changed getAbsoluteFilePath so that if tryGetRealPathName succeeds, we
return right away (a real path is always absolute).  Otherwise, we try
to build an absolute path, as we did before, but we also call
VFS->getRealPath to make sure to get the canonical path (e.g. without
any ".." in it).

Reviewers: malaperle

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

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

llvm-svn: 339483
2018-08-10 22:27:53 +00:00
Alex Lorenz 8626d36f8c [clangd] extend the publishDiagnostics response to send back fixits to the
client if the client supports this extension

This commit extends the 'textDocument/publishDiagnostics' notification sent from
Clangd to the client.  When it's enabled, Clangd sends out the fixits associated
with the appropriate diagnostic in the body of the 'publishDiagnostics'
notification. The client can enable this extension by setting 'clangdFixSupport'
to true in the textDocument capabilities during initialization.

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

llvm-svn: 339454
2018-08-10 17:25:07 +00:00
Roman Lebedev 70fcafc096 [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

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

Tags: #clang-tools-extra

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

llvm-svn: 339437
2018-08-10 15:05:46 +00:00
Alexander Kornienko f337f5b7a5 [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro
Fixes https://bugs.llvm.org/show_bug.cgi?id=28406

Patch by IdrissRio.

Differential revision: https://reviews.llvm.org/D49800

llvm-svn: 339433
2018-08-10 13:59:33 +00:00
Andi-Bogdan Postelnicu bebcd6fa4d [clang-tidy] run-clang-tidy.py - add synchronisation to the output
Differential Revision: https://reviews.llvm.org/D49851

llvm-svn: 339427
2018-08-10 11:50:47 +00:00
Kirill Bobyrev 0a75766c3d [clangd] Allow consuming limited number of items
This patch modifies `consume` function to allow retrieval of limited
number of symbols. This is the "cheap" implementation of top-level
limiting iterator. In the future we would like to have a complete limit
iterator implementation to insert it into the query subtrees, but in the
meantime this version would be enough for a fully-functional
proof-of-concept Dex implementation.

Reviewers: ioeric, ilya-biryukov

Reviewed by: ioeric

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

llvm-svn: 339426
2018-08-10 11:50:44 +00:00
Haojian Wu 1793bc9f78 [clangd] Fix a "-Wdangling-else" compiler warning in the test.
llvm-svn: 339416
2018-08-10 08:34:16 +00:00
Haojian Wu 25efa0fad3 [clang-tidy] Omit cases where loop variable is not used in loop body in
performance-for-range-copy check.

Summary:
The upstream change r336737 make the check too smart to fix the case
where loop variable could be used as `const auto&`.

But for the case below, changing to `const auto _` will introduce
an unused complier warning.

```
for (auto _ : state) {
  // no references for _.
}
```

This patch omit this case, and it is safe to do it as the case is very rare.

Reviewers: ilya-biryukov, alexfh

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 339415
2018-08-10 08:25:51 +00:00
Stephen Kelly c09197e086 Port getLocEnd -> getEndLoc
Subscribers: nemanjai, ioeric, kbarton, cfe-commits

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

llvm-svn: 339401
2018-08-09 22:43:02 +00:00
Stephen Kelly 43465bf3fd Port getLocStart -> getBeginLoc
Reviewers: javed.absar

Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits

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

llvm-svn: 339400
2018-08-09 22:42:26 +00:00
Eric Liu e745eb33d9 [clangd] Try to fix buildbot after r339320.
http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/5487

llvm-svn: 339322
2018-08-09 09:25:26 +00:00
Eric Liu f40819ea2d [clangd] Record the file being processed in a TUScheduler thread in context.
Summary:
This allows implementations like different symbol indexes to know what
the current active file is. For example, some customized index implementation
might decide to only return results for some files.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 339320
2018-08-09 09:05:45 +00:00
Petr Hosek eb46c95c3e [CMake] Use normalized Windows target triples
Changes the default Windows target triple returned by
GetHostTriple.cmake from the old environment names (which we wanted to
move away from) to newer, normalized ones. This also requires updating
all tests to use the new systems names in constraints.

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

llvm-svn: 339307
2018-08-09 02:16:18 +00:00
Kadir Cetinkaya 2f84d91131 Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.
Summary: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

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

llvm-svn: 339224
2018-08-08 08:59:29 +00:00
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
Idriss Riouak deb8c7d396 [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
Summary:
Hello, i would like to suggest a fix for one of the checks in clang-tidy. 
The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=38039 where you can find more information.

```
struct UOB{
	UOB(const UOB &Other):j{Other.j}{}
	int j;
};
```
In this case the check modernize-use-equals-default does not detect copy constructors that can be defaulted; that should be:

```
struct UOB{
	UOB(const UOB &Other) = default;
	int j;
};
```

Reviewers: aaron.ballman, hokein, alexfh

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 337286
2018-07-17 14:35:15 +00:00
Benjamin Kramer a60dadde15 [clang-tidy] Force exceptions to be enabled in test
For targets that have them off by default.

llvm-svn: 337091
2018-07-14 10:48:06 +00:00
Eugene Zelenko 415a1506ed [Documentation] Add missing description for bugprone-exception-escape in Release Notes.
llvm-svn: 337069
2018-07-13 22:53:05 +00:00
Adam Balogh e0e5b4cf2e [clang-tidy] Exception Escape Checker
Finds functions which may throw an exception directly or indirectly, but they
should not: Destructors, move constructors, move assignment operators, the
main() function, swap() functions, functions marked with throw() or noexcept
and functions given as option to the checker.

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

llvm-svn: 336997
2018-07-13 13:09:40 +00:00
Sam McCall 57b66c8ba3 [clang-tidy] readability-inconsistent-declaration-parameter-name: accept approximate name matches.
Summary:
The goal is to reduce false positives when the difference is intentional, like:

foo(StringRef name);
foo(StringRef name_ref) {
  string name = cleanup(name_ref);
  ...
}

Or semantically unimportant, like:
foo(StringRef full_name);
foo(StringRef name) { ... }

There are other matching names we won't recognise (e.g. syns vs synonyms) but
this catches many that we see in practice, and gives people a systematic
workaround.

The old behavior is available as a 'Strict' option.

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 336992
2018-07-13 11:41:56 +00:00
Ben Hamilton 13af794726 [clang-tidy/ObjC] Add SQL to list of acronyms
Summary: SQL is a common acronym.

Reviewers: Wizard, hokein

Reviewed By: Wizard, hokein

Subscribers: cfe-commits

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

llvm-svn: 336919
2018-07-12 17:32:55 +00:00
Sam McCall 6316e0d322 [clangd] Extract FileSystemProvider into a separate header. NFC
Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 336909
2018-07-12 14:49:52 +00:00
Sam McCall 8d7760cb7c [clangd] log request/response messages with method/ID/error at INFO level
Summary: Bodies are logged at VERBOSE level (since r336785), tweak the formatting.

Reviewers: hokein

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

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

llvm-svn: 336899
2018-07-12 11:52:18 +00:00
Sam McCall b34565ec7a [clangd] Simplify logging wrapper after r336888
llvm-svn: 336890
2018-07-12 08:00:21 +00:00
Eugene Zelenko 8027bb3330 [Documentation] Fix incorrect documentation references, new checks order in Release Notes
llvm-svn: 336850
2018-07-11 20:56:26 +00:00
Eugene Zelenko 3b71c2c98d [Documentation] Link format and order of Clang-tidy changes in Release Notes
llvm-svn: 336849
2018-07-11 20:41:16 +00:00
Kirill Bobyrev 47d7f52dea [clangd] Uprank delcarations when "using q::name" is present in the main file
Having `using qualified::name;` for some symbol is an important signal
for clangd code completion as the user is more likely to use such
symbol.  This patch helps to uprank the relevant symbols by saving
UsingShadowDecl in the new field of CodeCompletionResult and checking
whether the corresponding UsingShadowDecl is located in the main file
later in ClangD code completion routine. While the relative importance
of such signal is a subject to change in the future, this patch simply
bumps DeclProximity score to the value of 1.0 which should be enough for
now.

The patch was tested using

`$ ninja check-clang check-clang-tools`

No unexpected failures were noticed after running the relevant testsets.

Reviewers: sammccall, ioeric

Subscribers: MaskRay, jkorous, cfe-commits

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

llvm-svn: 336810
2018-07-11 14:49:49 +00:00