Commit Graph

5094 Commits

Author SHA1 Message Date
Haojian Wu ac958c2ed6 [clangd] Suppress unwritten scopes when expanding auto.
Summary: otherwise the replacement will break the code.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 366446
2019-07-18 15:13:45 +00:00
Sam McCall f1c05e8d20 [clangd] Disable DumpRecordLayout by default per https://bugs.llvm.org/show_bug.cgi?id=42670
llvm-svn: 366443
2019-07-18 15:00:38 +00:00
Hans Wennborg 8f5b44aead Bump the trunk version to 10.0.0svn
and clear the release notes.

llvm-svn: 366427
2019-07-18 11:51:05 +00:00
Johan Vikstrom 51cdd51807 [clangd] Added highlightings for template parameters and specializations.
Summary: Template parameters and specializations were not being highlighted before. This adds highlightings to those types of tokens by adding two Visit* methods.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 366420
2019-07-18 09:56:38 +00:00
Hans Wennborg 5dd86ab2dd clang-tidy release notes: Split and order changes by type
Patch by Eugene Zelenko!

llvm-svn: 366408
2019-07-18 07:12:47 +00:00
Fangrui Song ceeda9f07a [clangd] Fix Fix -Wunused-lambda-capture after r366339
llvm-svn: 366400
2019-07-18 04:23:54 +00:00
Julie Hockett 337aea438c [clang-tidy] Exclude forward decls from fuchsia-multiple-inheritance
Addresses b39770.

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

llvm-svn: 366354
2019-07-17 17:40:53 +00:00
Nathan Huckleberry b53e13cd43 [clang-tidy] Fix crash on end location inside macro
Summary:
Lexer::getLocForEndOfToken is defined to return an
invalid location if the given location is inside a macro.
Other checks conditionally warn based off location
validity. Updating this check to do the same.

Reviewers: JonasToth, aaron.ballman, nickdesaulniers

Reviewed By: nickdesaulniers

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

Tags: #clang

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

llvm-svn: 366353
2019-07-17 17:22:43 +00:00
Simon Pilgrim 0730710b3f Fix MSVC 'implicitly capture' compile error. NFCI.
llvm-svn: 366339
2019-07-17 15:31:53 +00:00
Nathan Ridge e61d0257ed [clangd] Type hierarchy: don't resolve parents if the client only asked for children
Summary: Also reorganize the code for computing supertypes to make it more symmetric to subtypes.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 366338
2019-07-17 15:26:49 +00:00
Ilya Biryukov f81ee439a4 [clang-tidy] Adjust location of namespace comment diagnostic
Summary:
If there is no comment, place it at the closing brace of a namespace
definition. Previously it was placed at the next character after the
closing brace.

The new position produces a better location for highlighting in clangd
and does not seem to make matters worse for clang-tidy.

Reviewers: alexfh, hokein

Reviewed By: alexfh, hokein

Subscribers: xazax.hun, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 366337
2019-07-17 15:22:14 +00:00
Sam McCall 2889fe6769 [clangd] Force the required interpretation of #import on windows tests.
Summary: NFC but should fix a bunch of tests.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 366321
2019-07-17 13:21:25 +00:00
Kadir Cetinkaya 6011a285ed [clangd] Handle windows line endings in QueryDriver
Summary: fixes second case of https://github.com/clangd/clangd/issues/93

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 366320
2019-07-17 13:14:02 +00:00
Sam McCall 11b06242a7 [clangd] Fix error message in tweaktests to be useful. NFC
llvm-svn: 366311
2019-07-17 10:17:47 +00:00
Rui Ueyama 42cfbafc1f Replace CRLF with LF.
llvm-svn: 366304
2019-07-17 08:31:51 +00:00
Matthias Gehre ffca322266 [clang-tidy] initial version of readability-convert-member-functions-to-static
Summary:
Finds non-static member functions that can be made ``static``.

I have run this check (repeatedly) over llvm-project. It made 1708 member functions
``static``. Out of those, I had to exclude 22 via ``NOLINT`` because their address
was taken and stored in a variable of pointer-to-member type (e.g. passed to
llvm::StringSwitch).
It also made 243 member functions ``const``. (This is currently very conservative
to have no false-positives and can hopefully be extended in the future.)

You can find the results here: https://github.com/mgehre/llvm-project/commits/static_const_eval

Reviewers: alexfh, aaron.ballman

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 366265
2019-07-16 21:19:00 +00:00
Johan Vikstrom aae7553b34 [clangd] Added highlighting for the targets in typedefs and using.
Summary:
In `typedef int A` the `A` was not highlighted previously.

This patch gives `A` the same kind of highlighting that the underlying type has (class/enum) (which in this example is no special highlighting because builtins are not handled yet)
Will add highlightings for built ins in another patch.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 366207
2019-07-16 13:23:12 +00:00
Sam McCall 06377ae2e5 [clangd] Don't rebuild background index until we indexed one TU per thread.
Summary:
This increases the odds that the boosted file (cpp file matching header)
will be ready. (It always enqueues first, so it'll be present unless
another thread indexes *two* files before the first thread indexes one.)

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 366199
2019-07-16 10:17:06 +00:00
Kadir Cetinkaya 1d91f94f09 [clangd] Fix doc
llvm-svn: 366073
2019-07-15 15:16:57 +00:00
Johan Vikstrom 4e34a85aa2 [clangd] Fix duplicate highlighting tokens appearing in initializer lists.
Summary: The RecursiveASTVisitor sometimes visits exprs in initializer lists twice. Added deduplication to prevent duplicate highlighting tokens from appearing. Done by sorting and a linear search.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 366070
2019-07-15 15:08:27 +00:00
Johan Vikstrom 17b4a932fa [clangd] Added highlighting for members and methods.
Summary: Added highlighting for members and methods.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 366047
2019-07-15 08:12:21 +00:00
Johan Vikstrom d02f17daed [clangd] Added highlighting to enum constants.
Summary: VSCode does not have a scope for enum constants. So they were placed under "constant.other.enum" as that seems to be the most correct scope for enum constants. However, this makes theia color them blue (the same color it uses for keywords).

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 366045
2019-07-15 07:41:12 +00:00
Fangrui Song 36fbd0da5f Simplify with llvm::is_contained. NFC
llvm-svn: 365993
2019-07-13 07:23:12 +00:00
Nathan Ridge d1fdadb226 [clangd] Mark type hierarchy as a supported feature in the docs
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365987
2019-07-13 03:24:54 +00:00
Nathan Ridge 087b044c49 [clangd] Implement typeHierarchy/resolve for subtypes
Summary:
This allows the client to resolve subtypes one level at a time.

For supertypes, this is not necessary, because we eagerly compute
supertypes and return all levels.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365986
2019-07-13 03:24:48 +00:00
Julie Hockett b131ad0be2 [clang-doc] Fix failing tests on Windows
Tests on Windows were failing due to path separator differences.
'/' was being used as separator in the expected output, paths in expected
output are now changed to their native form before comparing them to the
actual output.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 365967
2019-07-12 22:19:02 +00:00
Sam McCall 697de1c24e [clangd] Fix off-by-one in CodeComplete and assertion in Dex
llvm-svn: 365955
2019-07-12 20:35:41 +00:00
Julie Hockett 2c1c9a2407 [clang-doc] Add html links to references
<a> tags are added for the parents and members of records and return type and
params of functions. The link redirects to the reference's info file.

The directory path where each info file will be saved is now generated in the
serialization phase and stored as an attribute in each Info.

Bitcode writer and reader were modified to handle the new attributes.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 365937
2019-07-12 18:32:00 +00:00
Russell Gallop de54e2c4df Revert "[clangd] Implement typeHierarchy/resolve for subtypes"
Causing test failure on Windows bot

This reverts commit 5b9484e559.

llvm-svn: 365899
2019-07-12 13:35:58 +00:00
Shaurya Gupta 0d26d6f887 [clangd] Fixed toHalfOpenFileRange
Summary:
- Fixed toHalfOpenFileRange to work for macros as well as template
instantiations
- Added unit tests

Breaking test case for older version of toHalfOpenFileRange:
\# define FOO(X) X++
int a = 1;
int b = FOO(a);
toHalfOpenFileRange for the sourceRange of VarDecl for b returned the
wrong Range.

Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 365894
2019-07-12 11:42:31 +00:00
Sam McCall 0f7146db9b [clangd] Prioritize indexing of files that share a basename with the open file.
Summary:
In practice, opening Foo.h will still often result in Foo.cpp making the
second index build instead of the first, as the rebuild policy doesn't
know to wait.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365888
2019-07-12 10:18:42 +00:00
Haojian Wu 210a9b6aee [clangd] Move the expandAuto tweak from global namespace into annoymous namespace.
llvm-svn: 365885
2019-07-12 09:38:53 +00:00
Haojian Wu 7eeb82b585 [clangd] Don't run the prepare for tweaks that are disabled.
Summary: Previously, we ran the prepare, even for the tweaks that are disabled.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365882
2019-07-12 08:50:20 +00:00
Fangrui Song 67ab269e1d [test] Delete trailing spaces from YAML tests after D65566/r365869
llvm-svn: 365874
2019-07-12 06:01:37 +00:00
Nathan Ridge 5b9484e559 [clangd] Implement typeHierarchy/resolve for subtypes
Summary:
This allows the client to resolve subtypes one level at a time.

For supertypes, this is not necessary, because we eagerly compute
supertypes and return all levels.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365867
2019-07-12 03:26:32 +00:00
Nathan Ridge 3aba8296e5 [clangd] Add a missing early return in getTypeHierarchy()
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365849
2019-07-12 00:24:45 +00:00
Paul Robinson 2cb5c46e67 [clangd] Fix MSVC build failure.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26898

llvm-svn: 365844
2019-07-11 23:48:06 +00:00
Jan Korous a286aae4d8 [clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded test
...to minimize the chance of stack overflow before reaching the limit.

llvm-svn: 365804
2019-07-11 18:21:21 +00:00
Sam McCall ad37ae18e2 [clangd] Avoid template in Task constructor, hopefully fix MSVC build
llvm-svn: 365794
2019-07-11 16:26:53 +00:00
Sam McCall 709d611cf2 [clangd] Consume llvm::Error in test after r365792
llvm-svn: 365793
2019-07-11 16:22:50 +00:00
Sam McCall 9470142ca5 [clangd] Implementation of auto type expansion.
Add a tweak for clangd to replace an auto keyword to the deduced type.

This way a user can declare something with auto and then have the
IDE/clangd replace auto with whatever type clangd thinks it is. In case
of long/complext types this makes is reduces writing effort for the
user.

The functionality is similar to the hover over the auto keyword.

Example (from the header):

```
/// Before:
///    auto x = Something();
///    ^^^^
/// After:
///    MyClass x = Something();
///    ^^^^^^^
```

Patch by kuhnel! (Christian Kühnel)
Differential Revision: https://reviews.llvm.org/D62855

llvm-svn: 365792
2019-07-11 16:04:18 +00:00
Haojian Wu f3661a78bf [clangd] Remove an extra ";", NFC
llvm-svn: 365778
2019-07-11 13:58:56 +00:00
Kadir Cetinkaya 605e772abc [clangd][QueryDriver] Use language from underlying database if possible
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365776
2019-07-11 13:47:46 +00:00
Sam McCall 7e27d86afb [clangd] Add priorities to background index queue, extract to separate class
Reviewers: kadircet

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits

Tags: #llvm

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

llvm-svn: 365773
2019-07-11 13:34:38 +00:00
Haojian Wu e397172438 [clangd] Remove the extra ";", NFC
llvm-svn: 365764
2019-07-11 12:31:18 +00:00
Haojian Wu 1503a3b2e7 [clangd] Fix an assertion crash in "ExtractVariable" tweak
Summary:
GetTypePtr requires that the type should not be null, otherwise we hit
an assertion, we should use getTypePtrOrNull instead.

Reviewers: sammccall, SureYeaah

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

Tags: #clang

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

llvm-svn: 365763
2019-07-11 12:29:01 +00:00
Kadir Cetinkaya c05f67712d [clangd] Fix windows buildbots
llvm-svn: 365756
2019-07-11 10:41:58 +00:00
Haojian Wu 63f5235978 [clangd] Add a missing "return nullptr;" to the SelectionTree::commonAncestor.
This would fix some mysterious crashes on codeAction in clangd.

llvm-svn: 365751
2019-07-11 10:06:24 +00:00
Kadir Cetinkaya ad54935c77 [clangd] Reland rL365634
This was reverted in rL365678, the failure was due to YAML parsing of
compile_commands.json.

Converting backslashes to forward slashes to fix the issue in unittest.

llvm-svn: 365748
2019-07-11 09:54:31 +00:00
Johan Vikstrom b6a74e33c3 [clangd] Added highlightings for namespace specifiers.
Summary: Added highlightings for namespace specifiers.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 365745
2019-07-11 09:29:16 +00:00
Haojian Wu e6695821e5 Revert Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."
This reverts r365675 (git commit 43d75f9778)

The patch causes a crash in SupportTests (CommandLineTest.AliasesWithArguments).

llvm-svn: 365742
2019-07-11 08:54:28 +00:00
Mikael Holmen c593f5e671 [clang-doc] Silence compiler warning with gcc 7.4 [NFC]
Without the fix gcc 7.4.0 complains with

/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'llvm::SmallString<16> clang::doc::{anonymous}::HTMLTag::ToString() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:165:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'bool clang::doc::{anonymous}::HTMLTag::HasInlineChildren() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:142:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'bool clang::doc::{anonymous}::HTMLTag::IsSelfClosing() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:126:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1plus: all warnings being treated as errors

llvm-svn: 365736
2019-07-11 06:50:10 +00:00
Sterling Augustine 05630a3745 rL365634 adds a unique_ptr<CompilationDatabase> in GobalCompilationDatabase.h:108 but CompilationDatabase is only forward declared. This makes the header not compile standalone, because unique_ptrs expect to have the full-definition of the...
Summary:
...template argument.

Remove the forward declaration and include the appropriate header instead.
Remove CompileCommand too, which is also in the header.

llvm-svn: 365713
2019-07-10 23:38:00 +00:00
Julie Hockett 671bac7436 [clang-doc] Add a structured HTML generator
Implements an HTML generator.
Nodes are used to represent each part of the HTML file. There are TagNodes that
represent every HTML tag (p, h1, div, ...) and they have children nodes, which
can be TagNodes or TextNodes (these nodes only have text).
Proper indentation is rendered within the files generated by tool.
No styling (CSS) is included.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com)

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

llvm-svn: 365687
2019-07-10 19:03:25 +00:00
Matthew Voss 6d1a64e489 Revert "[clangd] Filter out non-governed files from broadcast"
This reverts commit d5214dfa7b.

It's causing failures, both in our local CI and the PS4 Windows bot.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26872/steps/test/logs/stdio

llvm-svn: 365678
2019-07-10 18:16:35 +00:00
Don Hinton 43d75f9778 Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."
Previously reverted in 364141 due to buildbot breakage, and fixed here
by making GeneralCategory global a ManagedStatic.

Summary:
This change processes `OptionCategory`s and `SubCommand`s as they
are seen instead of caching them in the Option class and processing
them later.  Doing so simplifies the work needed to be done by the Global
parser and significantly reduces the size of the Option class to a mere 64
bytes.

Removing  the `OptionCategory` cache saved 24 bytes, and removing
the `SubCommand` cache saved an additional 48 bytes, for a total of a
72 byte reduction.

Reviewed By: serge-sans-paille

Tags: #llvm, #clang

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

llvm-svn: 365675
2019-07-10 17:57:05 +00:00
Kadir Cetinkaya d5214dfa7b [clangd] Filter out non-governed files from broadcast
Summary:
This also turns off implicit discovery of additional compilation
databases.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365634
2019-07-10 14:11:46 +00:00
Kadir Cetinkaya fbafaf48fe [clangd] Trim spaces around parsed include in include extractor
llvm-svn: 365632
2019-07-10 13:59:13 +00:00
Haojian Wu 6b043f0518 [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.
Summary:
This would allow clangd embedders to use the ClangdServer::rename for other
purposes (highlighting all the occurrences of the symbol in prepare
stage).

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 365631
2019-07-10 13:44:22 +00:00
Ilya Biryukov 57852878c0 [clangd] Stop recording tokens before running clang-tidy
modernize-trailing-return-type runs the preprocessor, breaking the token
collection logic.

This lead to a crash before, see the new test for a repro.

llvm-svn: 365607
2019-07-10 09:28:35 +00:00
Ilya Biryukov 18cb8e401c [clangd] Consume error to avoid assertion failures
When we fail to calculate #include insertion for a completion item.
Note that this change does not add a test, although that would be good.

llvm-svn: 365606
2019-07-10 09:18:09 +00:00
Johan Vikstrom eff868fdef [clangd] Added highlighting for class and enum types.
Summary: Added highlighting for non-builtin types using VisitTypeLoc. Ignoring namespace qualifiers as for now.

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 365602
2019-07-10 08:41:25 +00:00
Sam McCall 9145f265b0 [clangd] fix assert in test after r365531.
Unverified because CMake/ninja seems to be broken...

llvm-svn: 365576
2019-07-09 23:05:20 +00:00
Sam McCall 2f760c44e6 [clangd] Rewrite of logic to rebuild the background index serving structures.
Summary:
Previously it was rebuilding every 5s by default, which was much too frequent
in the long run - the goal was to provide an early build. There were also some
bugs. There were also some bugs, and a dedicated thread was used in production
but not tested.

 - rebuilds are triggered by #TUs built, rather than time. This should scale
   more sensibly to fast vs slow machines.
 - there are two separate indexed-TU thresholds to trigger index build: 5 TUs
   for the first build, 100 for subsequent rebuilds.
 - rebuild is always done on the regular indexing threads, and is affected by
   blockUntilIdle. This means unit/lit tests run the production configuration.
 - fixed a bug where we'd rebuild after attempting to load shards, even if there
   were no shards.
 - the BackgroundIndexTests don't really test the subtleties of the rebuild
   policy (for determinism, we call blockUntilIdle, so rebuild-on-idle is enough
   to pass the tests). Instead, we expose the rebuilder as a separate class and
   have fine-grained tests for it.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits

Tags: #llvm

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

llvm-svn: 365531
2019-07-09 18:30:49 +00:00
Sam McCall 5a458d6ada [clangd] Show documentation in hover, and fetch docs from index if needed.
Summary:
I assume showing docs is going to be part of structured hover rendering, but
it's unclear whether that's going to make clangd 9 so this is low-hanging fruit.

(Also fixes a bug uncovered in FormattedString's plain text output: need blank
lines when text follows codeblocks)

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365522
2019-07-09 17:59:50 +00:00
Dmitri Gribenko f717148b3a Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.
Summary:
Currently it fails on cases like '\001'.

Note: Since `StringLiteral::outputString` dumps most nonprintable
characters in octal value, the exact string literal format isn't preserved,
e.g. `"\x01"` becomes `'\001'`.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits

Tags: #clang

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

Patch by Xiaoyi Zhang.

llvm-svn: 365463
2019-07-09 11:04:04 +00:00
Shaurya Gupta cc0203e06d Fixed assertion
llvm-svn: 365460
2019-07-09 10:30:18 +00:00
Shaurya Gupta 1fb97c9036 dummy variable extraction on a function scope
Summary:
- Added extraction to a dummy variable
- using auto for the dummy variable type for now
- Works on a function scope
- Adding braces to create a compound statement not supported yet
- added unit tests

Reviewers: sammccall, kadircet

Subscribers: mgorny, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 365453
2019-07-09 10:12:26 +00:00
Jian Cai 967aa5745d A test commit following 'Obtaining Commit Access' (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)
llvm-svn: 365380
2019-07-08 19:53:22 +00:00
Sam McCall b324c64b6d [clangd] Don't insert absolute paths, give up instead.
Summary: Also implement resolution of paths relative to mainfile without HeaderSearchInfo.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365364
2019-07-08 18:07:46 +00:00
Sam McCall 5f092e31ab [clangd] Use -completion-style=bundled by default if signature help is available
Summary:
I didn't manage to find something nicer than optional<bool>, but at least I
found a sneakier comment.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365356
2019-07-08 17:27:15 +00:00
Ilya Biryukov 4aa2873fdc [clangd] A code tweak to expand a macro
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 365331
2019-07-08 15:25:16 +00:00
Sam McCall 674d8a947c [clangd] Use xxhash instead of SHA1 for background index file digests.
Summary:
Currently SHA1 is about 10% of our CPU, this patch reduces it to ~1%.

xxhash is a well-defined (stable) non-cryptographic hash optimized for
fast checksums (like crc32).
Collisions shouldn't be a problem, despite the reduced length:
 - for actual file content (used to invalidate bg index shards), there
   are only two versions that can collide (new shard and old shard).
 - for file paths in bg index shard filenames, we would need 2^32 files
   with the same filename to expect a collision. Imperfect hashing may
   reduce this a bit but it's well beyond what's plausible.

This will invalidate shards on disk (as usual; I bumped the version),
but this time the filenames are changing so the old files will stick
around :-( So this is more expensive than the usual bump, but would be
good to land before the v9 branch when everyone will start using bg index.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365311
2019-07-08 11:33:17 +00:00
Sam McCall d3bbc06ac7 [clangd] Avoid slow ostreams in URI conversion.
This speeds up some hot paths significantly (e.g.  dex::generateProximityURIs
by a third or so)

llvm-svn: 365289
2019-07-08 02:46:21 +00:00
Sam McCall 8f9e4d92e0 [clangd] Encapsulate fields in dex token. NFC
llvm-svn: 365288
2019-07-08 02:37:06 +00:00
Bjorn Pettersson 009225374a Bitstream reader: Fix undefined behavior seen after rL364464
Summary:
After rL364464 the following tests started to fail when
running the clang-doc tests with an ubsan instrumented
build of clang-doc:
    Clang Tools :: clang-doc/single-file-public.cpp
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode

We need to check that the read value is in range for being
casted to the llvm::bitc::FixedAbbrevIDs enum, before the
cast in ClangDocBitcodeReader::skipUntilRecordOrBlock.

SerializedDiagnosticReader::skipUntilRecordOrBlock was updated
in the same way.

Reviewers: jfb

Reviewed By: jfb

Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 365239
2019-07-05 20:22:40 +00:00
Johan Vikstrom 8ca1c65ced [clangd] Added highlighting for variable references (declrefs)
Summary: Added highlighting for variable references using VisitDeclRefExpr.

Reviewers: hokein, sammccall

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

Tags: #clang

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

llvm-svn: 365205
2019-07-05 13:06:03 +00:00
Haojian Wu ee08036df8 [clangd] Deduplicate clang-tidy diagnostic messages.
Summary:
Clang-tidy checks may emit duplicated messages (clang-tidy tool
deduplicate them in its custom diagnostic consumer), and we may show
multiple duplicated diagnostics in the UI, which is really bad.

This patch makes clangd do the deduplication, and revert the change
rL363889.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365204
2019-07-05 12:57:56 +00:00
Sam McCall 5bf7229c1f [clangd] Mark a couple of unimportant flags as hidden. NFC
llvm-svn: 365151
2019-07-04 18:49:08 +00:00
Kadir Cetinkaya 51702765b4 [clangd] Fix breakage on gcc 5.4
llvm-svn: 365140
2019-07-04 13:47:51 +00:00
Haojian Wu 1ca2ee4dc1 [clangd] Some tweaks on semantic highlighting lookuptable.
Summary:
- move toTextMateScope to SemanticHighlighting.h;
- move the buildLookupTable to LSP layer (as LSP requires such form);

Reviewers: sammccall, jvikstrom

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

Tags: #clang

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

llvm-svn: 365135
2019-07-04 12:27:21 +00:00
Kadir Cetinkaya 5bec85a34c [clangd] Fix a lifetime bug in QueryDriver
llvm-svn: 365134
2019-07-04 12:24:17 +00:00
Kadir Cetinkaya 04531ba3a2 [clangd] Query driver reads stderr and passes driver as first argument
Summary:
gcc invokes cc1 through a path deduced from argv[0] therefore it must
be correctly set.
Also it prints the search path to stderr not stdout, this also applies to clang.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365132
2019-07-04 11:34:23 +00:00
Haojian Wu b7ec41556b [clangd] Add a hidden tweak to annotate all highlighting tokens of the file.
Reviewers: sammccall, jvikstrom

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

Tags: #clang

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

llvm-svn: 365130
2019-07-04 10:49:32 +00:00
Kadir Cetinkaya c6fdefa0ee [clangd] Turn background-index on by default
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365124
2019-07-04 09:56:24 +00:00
Kadir Cetinkaya 12b14869dc [clangd] Make HadErrors part of background index's internal state
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365123
2019-07-04 09:52:12 +00:00
Kadir Cetinkaya adbb347ffe [clangd] Add HadErrors field into shards
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365122
2019-07-04 09:52:04 +00:00
Kadir Cetinkaya 11e1c50b08 [clangd] Store hash of command line in index shards.
Summary: This is to enable cache invalidation when command line flags changes.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365121
2019-07-04 09:51:53 +00:00
Kadir Cetinkaya a6fedc8bd6 [clangd] Also cache failures while indexing
Summary:
Clangd currently doesn't cache any indexing failures, which results in
retrying those failed files even if their contents haven't changed.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 365120
2019-07-04 09:51:43 +00:00
Johan Vikstrom c1ead0e1b5 [clangd] Add missing changes for 365111
llvm-svn: 365112
2019-07-04 08:06:48 +00:00
Johan Vikstrom a848dab7a3 [clangd] Emit publishSemanticHighlighting in LSP if enabled
Summary: Emit publishSemanticHighlighting in LSP if enabled

Reviewers: hokein, kadircet

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

Tags: #clang

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

llvm-svn: 365111
2019-07-04 07:53:12 +00:00
Francis Visoiu Mistrih e0308279cb [Bitcode] Move Bitstream to a separate library
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

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

llvm-svn: 365091
2019-07-03 22:40:07 +00:00
Dmitri Gribenko ede514049a Fixed a link in ReleaseNotes.rst (follow-up to r365007)
llvm-svn: 365078
2019-07-03 20:18:34 +00:00
Dmitri Gribenko e6020f5c62 [clang-tidy] new check: bugprone-posix-return
Summary:
Checks if any calls to posix functions (except posix_openpt) expect negative return values.
These functions return either 0 on success or an errno on failure, which is positive only.

Reviewers: JonasToth, gribozavr, alexfh, hokein

Reviewed By: gribozavr

Subscribers: Eugene.Zelenko, lebedev.ri, llozano, george.burgess.iv, xazax.hun, srhines, mgorny, cfe-commits

Tags: #clang

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

Patch by Jian Cai.

llvm-svn: 365007
2019-07-03 09:20:18 +00:00
Kadir Cetinkaya 1f6d9845d8 [clang][HeaderSearch] Shorten paths for includes in mainfile's directory
Summary:
Currently HeaderSearch only looks at SearchDir's passed into it, but in
addition to those paths headers can be relative to including file's directory.

This patch makes sure that is taken into account.

Reviewers: gribozavr

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 365005
2019-07-03 07:47:19 +00:00
Julie Hockett 097aedc9d9 [clang-doc] Serialize child namespaces and records
Serialization of child namespaces and records is now handled.
Namespaces can have child records and child namespaces.
Records can only have child records.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 364963
2019-07-02 19:59:56 +00:00
Julie Hockett d42f22997e [clang-doc] Fix segfault in comment sorting
Differential Revision: https://reviews.llvm.org/D63962

llvm-svn: 364949
2019-07-02 17:57:11 +00:00
Yitzhak Mandelbaum e423275665 [clang-tidy] Extend TransformerClangTidyCheck to support adding includes.
Summary:
This revision implements support for the `AddedIncludes` field in
RewriteRule cases; that is, it supports specifying the addition of include
directives in files modified by the clang tidy check.

Reviewers: ilya-biryukov, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364922
2019-07-02 13:25:07 +00:00
Haojian Wu 7c251fa069 [clangd] Collect the refs when the main file is header.
Summary:
Previously, we only collect refs of the symbols which are declared in
the preamble and referenced in the main file, it works well when the
main file is .cpp file.

However, when the main file is .h file (when opening a .h file in the
editor), we don't collect refs of the symbol declared in this file, so we miss
these refs in our dynamic index.

A typical scenario:

1. Open Foo.h (which contains class Foo)
2. Open Foo.cpp, call find references for Foo

And we only get refs from Foo.cpp.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 364893
2019-07-02 09:16:21 +00:00
Alexander Kornienko b101c39f58 Fixed two issues in clang-tidy -help.
HeaderFilter -> HeaderFilterRegex

llvm-svn: 364837
2019-07-01 18:55:10 +00:00
Shaurya Gupta 8cae7d79b5 Summary: [Clangd] Added hidden command line option -tweaks to specify which tweaks to enable
- Only for development purposes
- Disabled tweaks in fixits-duplications test
Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 364809
2019-07-01 16:55:29 +00:00
Johan Vikstrom 881aab4dc3 [clangd] No longer getting template instantiations from header files in Main AST.
Previous implementation to filter decls not in the main file did not
work in the case where a template was instantiated from a header in the
main file. It would than include that function/class in topLevelDecls.

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

llvm-svn: 364747
2019-07-01 11:49:01 +00:00
Sam McCall 60300c9c7d [clangd] Fix unused var from r364735
llvm-svn: 364741
2019-07-01 10:13:03 +00:00
Sam McCall 9cca81344c [clangd] Make PreambleStatusCache handle filenames more carefully
Summary:
 - when we hit the cache, the reported filename should be that of the
   cache query, not that of the cache store. This matches behaviors of
   common FSes, and avoids triggering difficult edge cases in
   FileManager when files are being moved around concurrently.
 - filename comparisons (both cache queries and == mainfile checks)
   should fold away . and .. in paths. These can appear when relative
   paths occur in compile_commands.json. (gn does this).

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364740
2019-07-01 10:11:18 +00:00
Haojian Wu 9d34f4569b [clangd] Show better message when we rename macros.
Summary:
Previously, when we rename a macro, we get an error message of "there is
no symbol found".

This patch improves the message of this case (as we don't support macros).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364735
2019-07-01 09:26:48 +00:00
Haojian Wu b739b91cd3 [clangd] Make FixIt message be consistent with the clang-tidy diagnostic message.
Summary:
We strip the "[clang-tidy-check]" suffix from the clang-tidy diagnostics, we
should be consistent with the message in FixIt (strip the suffix as well).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364731
2019-07-01 08:05:53 +00:00
Fangrui Song 78ee2fbf98 Cleanup: llvm::bsearch -> llvm::partition_point after r364719
llvm-svn: 364720
2019-06-30 11:19:56 +00:00
Fangrui Song 2d2cb77e45 [ADT] Implement llvm::bsearch() with std::partition_point()
Summary:
Delete the begin-end form because the standard std::partition_point
can be easily used as a replacement.

The ranges-style llvm::bsearch will be renamed to llvm::partition_point
in the next clean-up patch.

The name "bsearch" doesn't meet people's expectation because in C:

> If two or more members compare equal, which member is returned is unspecified.

Reviewed By: sammccall

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

llvm-svn: 364719
2019-06-30 09:17:59 +00:00
Julie Hockett d900ef0a5b [clang-doc] Handle anonymous namespaces
Improves output for anonymous decls, and updates the '--public' flag to exclude everything under an anonymous namespace.

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

llvm-svn: 364674
2019-06-28 19:07:56 +00:00
Julie Hockett 93a290fdc9 [clang-doc] De-duplicate comments and locations
De-duplicate comments and declaration locations in reduce function.
When two files include the same header file, this file's content is mapped
twice causing comments and locations to be duplicated after the reduce stage.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 364670
2019-06-28 18:17:58 +00:00
Julie Hockett 021d2f2093 Update CODE_OWNERS.txt for clang-doc
Differential Revision: https://reviews.llvm.org/D63734

llvm-svn: 364663
2019-06-28 17:32:26 +00:00
Johan Vikstrom 6b8a2515ba [clangd] Emit semantic highlighting tokens when the main AST is built.
Differential Revision: https://reviews.llvm.org/D63821

llvm-svn: 364551
2019-06-27 15:13:03 +00:00
Haojian Wu 93a825c8fb [clangd] Fix a case where we fail to detect a header-declared symbol in rename.
Summary:
Failing case:

```
 #include "foo.h"
 void fo^o() {}
```

getRenameDecl() returns the decl of the symbol under the cursor (which is
in the current main file), instead, we use the canonical decl to determine
whether a symbol is declared in #included header.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364537
2019-06-27 13:24:10 +00:00
Mikael Holmen 79dc930c13 [clang-tidy] Fix NDEBUG build [NFC]
llvm-svn: 364535
2019-06-27 12:47:57 +00:00
Haojian Wu cbab10099d [clangd] No need to setTraversalScope in SemanticHighlighting.
Summary:
We have already set it when the AST is being built, and setting TraversalScope
is not free (it will clear the cache, which is expensive to build).

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 364528
2019-06-27 12:22:18 +00:00
Sam McCall 5cd77f98a1 [clangd] Address limitations in SelectionTree:
Summary:
 - nodes can have special-cased hit ranges including "holes" (FunctionTypeLoc in void foo())
 - token conflicts between siblings (int a,b;) are resolved in favor of left sibling
 - parent/child overlap is handled statefully rather than explicitly by comparing parent/child
   ranges (this lets us share a mechanism with sibling conflicts)

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364519
2019-06-27 11:17:13 +00:00
JF Bastien 0e82895826 BitStream reader: propagate errors
The bitstream reader handles errors poorly. This has two effects:

 * Bugs in file handling (especially modules) manifest as an "unexpected end of
   file" crash
 * Users of clang as a library end up aborting because the code unconditionally
   calls `report_fatal_error`

The bitstream reader should be more resilient and return Expected / Error as
soon as an error is encountered, not way late like it does now. This patch
starts doing so and adopting the error handling where I think it makes sense.
There's plenty more to do: this patch propagates errors to be minimally useful,
and follow-ups will propagate them further and improve diagnostics.

https://bugs.llvm.org/show_bug.cgi?id=42311
<rdar://problem/33159405>

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

llvm-svn: 364464
2019-06-26 19:50:12 +00:00
Yitzhak Mandelbaum 039af0ea03 [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.
Summary: Tidy check behavior often depends on language and/or clang-tidy options. This revision allows a user of TranformerClangTidyCheck to pass rule _generator_ in place of a rule, where the generator takes both the language and clang-tidy options. Additionally, the generator returns an `Optional` to allow for the case where the check is deemed irrelevant/disable based on those options.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364442
2019-06-26 16:04:38 +00:00
Yitzhak Mandelbaum 83b1580e1b [clang-tidy] Fix ClangTidyTest to initialize context before checks.
Summary:
Currently, `clang::tidy::test::runCheckOnCode()` constructs the check
instances *before* initializing the ClangTidyContext. This ordering causes
problems when the check's constructor accesses the context, for example, through
`getLangOpts()`.

This revision moves the construction to after the context initialization, which
follows the pattern used in the clang tidy tool itself.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364435
2019-06-26 15:04:33 +00:00
Johan Vikstrom 09bc665766 [clangd] Added functionality for getting semantic highlights for variable and function declarations
llvm-svn: 364421
2019-06-26 13:08:36 +00:00
Kadir Cetinkaya eb6e16ce63 [clangd] Disable failing unittest on non-x86 platforms
llvm-svn: 364413
2019-06-26 11:52:20 +00:00
Haojian Wu 442a120567 [clangd] Don't rename the namespace.
Summary:
Also fix a small bug -- the extra argument "-xc++" doesn't overwrite the
language if the argument is present after the file name in the compiler
command.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364392
2019-06-26 08:10:26 +00:00
Kadir Cetinkaya 8bfe0fc1d9 [clangd] Add Value field to HoverInfo
Summary:
Put a symbols value information which is deduced from initializer
expression into HoverInfo struct.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364390
2019-06-26 08:00:24 +00:00
Kadir Cetinkaya 256247cfb7 [clangd] Enable extraction of system includes from custom toolchains
Summary:
Some custom toolchains come with their own header files and compiler
drivers. Those compiler drivers implicitly know about include search path for
those headers. This patch aims to extract that information from drivers and add
it to the command line when invoking clang frontend.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364389
2019-06-26 07:45:27 +00:00
Kadir Cetinkaya 84f7377dd9 [clangd] Link and initialize target infos
llvm-svn: 364387
2019-06-26 07:39:14 +00:00
Nikolai Kosjar 181f252d53 [clang-tidy] Update documentation for Qt Creator integration.
Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364315
2019-06-25 13:50:09 +00:00
Sam McCall 79f7831aa7 [clangd] Fix NestedNameSpecifierLoc in SelectionTree
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364284
2019-06-25 09:36:09 +00:00
Haojian Wu 7276a446ce [clangd] Narrow rename to local symbols.
Summary:
Previously, we performed rename for all kinds of symbols (local, global).

This patch narrows the scope by only renaming symbols not being used
outside of the main file (with index asisitance). Renaming global
symbols is not supported at the moment (return an error).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364283
2019-06-25 08:43:17 +00:00
Haojian Wu 92c3257477 [clangd] Cleanup the duplicated getTokenRange.
Summary:
Also lift it to SourceCode.h, so that it can be used in other places
(semantic code highlighting).

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364280
2019-06-25 08:01:46 +00:00
Julie Hockett b1f01e27ec [clang-doc] Add basic support for templates and typedef
In serialize::parseBases(...), when a base record is a template
specialization, the specialization was used as the parent. It should be
the base template so there is only one file generated for this record.
When the specialized template is implicitly declared the reference USR
corresponded to the GlobalNamespace's USR, this will now be the base
template's USR.

More information about templates will be added later.

In serialize::emiInfo(RecorDecl*, ...), typedef records were not handled
and the name was empty. This is now handled and a IsTypeDef attribute is
added to RecordInfo struct.

In serialize::emitInfo(CXXMethodDecl*, ...), template specialization is
handled like in serialize::parseBases(...).

Bitcode writer and reader are modified to handle the new attribute of
RecordInfo.

Submitted on behalf of Diego Astiazarán (diegoaat97@gmail.com)
Differential Revision: https://reviews.llvm.org/D63367

llvm-svn: 364222
2019-06-24 19:31:02 +00:00
Sam McCall ca89eb5f9c [clangd] Improve SelectionTree string representation
llvm-svn: 364180
2019-06-24 13:01:28 +00:00
Douglas Yung c900c46d77 [NFC] Marking test added in r363975 as unsupported on Windows.
This test references a path that does not exist on Windows causing
it to emit different output from what was expected leading to a
failure when run on Windows.

llvm-svn: 364120
2019-06-22 01:09:00 +00:00
Matthias Gehre eeb3f99d23 [clang-tidy] misc-unused-parameters: don't comment out parameter name for C code
Summary: The fixit `int square(int /*num*/)` yields `error: parameter name omitted` for C code. Enable it only for C++ code.

Reviewers: klimek, ilya-biryukov, lebedev.ri, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364106
2019-06-21 21:30:25 +00:00
Reid Kleckner b250a62a51 Quote path to Python executable in case it has spaces
These days Python 3 is typically installed into C:/Program Files, so
cope with that.

Similar to r364077 in compiler-rt.

llvm-svn: 364087
2019-06-21 18:17:04 +00:00
Haojian Wu 34f5188d0f [clangd] Add include-mapping for C symbols.
Summary:
This resolves the issue of introducing c++-style includes for C files.

- refactor the gen_std.py, make it reusable for parsing C symbols.
- add a language mode to the mapping method to use different mapping for
  C and C++ files.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364044
2019-06-21 13:32:18 +00:00
Haojian Wu 38a2f50070 [clang-tidy] Fix a typo in the doc.
llvm-svn: 364010
2019-06-21 07:58:19 +00:00
Kadir Cetinkaya b9b1aaf07d [clang-tidy] Move test files of rL363975 into Inputs directory
llvm-svn: 364008
2019-06-21 07:54:27 +00:00
Serge Guelton 60ca31a7dd [clang-tidy] Fail gracefully upon empty database fields
Fix bz#42281

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

llvm-svn: 363975
2019-06-20 20:25:59 +00:00
Nathan Ridge 8df5f444a2 [clangd] Include the diagnostics's code when comparing diagnostics
Summary: This fixes https://github.com/clangd/clangd/issues/60

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 363889
2019-06-19 23:11:02 +00:00
Ilya Biryukov 482269b9fa [clangd] Consume error returned by cleanupAndFormat
When called by ClangdServer::applyTweak.
No idea how to actually trigger this in practice, so no tests.

llvm-svn: 363844
2019-06-19 17:30:02 +00:00
Ilya Biryukov a7acc7e855 [clangd] Format changes produced by rename
Reviewers: hokein, kadircet, sammccall

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363843
2019-06-19 17:25:24 +00:00
Ilya Biryukov d0aa6c58be [clangd] Collect tokens of main files when building the AST
Summary:
The first use of this is a code tweak to expand macro calls.
Will later be used to build syntax trees.

The memory overhead is small as we only store tokens of the main file.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 363803
2019-06-19 14:03:19 +00:00
Haojian Wu 982a1cf028 [clangd] Correct the MessageType enum values.
llvm-svn: 363798
2019-06-19 13:14:59 +00:00
Sam McCall 08372eb73b Revert "[clangd] Return vector<TextEdit> from applyTweak. NFC"
This reverts commit r363691.

llvm-svn: 363766
2019-06-19 07:29:10 +00:00
Sam McCall 38047dbca4 [clangd] Add ClangdServer accessor for buffer contents
llvm-svn: 363765
2019-06-19 07:29:05 +00:00
Douglas Yung c4d5c37285 [TEST] Fix test on Windows by looking for substrings rather than a regex
since the escaping of special characters appears to break on Windows.

llvm-svn: 363761
2019-06-19 03:02:33 +00:00
Aaron Puchert 44940048dd Fix more tests after r363749
Apparently -Wmissing-prototypes is used for quite a few integration
tests.

llvm-svn: 363760
2019-06-19 01:54:05 +00:00
Julie Hockett d9b3d08a9a [clang-tidy] Split fuchsia-default-arguments
Splits fuchsia-default-arguments check into two checks. fuchsia-default-arguments-calls warns if a function or method is called with default arguments. fuchsia-default-arguments-declarations warns if a function or method is declared with default parameters.

Committed on behalf of @diegoast (Diego Astiazarán).

Resolves b38051.

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

llvm-svn: 363712
2019-06-18 18:07:33 +00:00
Ilya Biryukov df9ee08b64 [clangd] Return vector<TextEdit> from applyTweak. NFC
For the same reasons as r363150, which got overwritten by changes in
r363680.

Sending without review to unbreak our integrate.

llvm-svn: 363691
2019-06-18 15:15:41 +00:00
Haojian Wu 9483bcf781 [clangd] Remove the extra ";", NFC
llvm-svn: 363681
2019-06-18 13:52:00 +00:00
Sam McCall 395fde753c [clangd] Add hidden tweaks to dump AST/selection.
Summary:
This introduces a few new concepts:
 - tweaks have an Intent (they don't all advertise as refactorings)
 - tweaks may produce messages (for ShowMessage notification). Generalized
   Replacements -> Effect.
 - tweaks (and other features) may be hidden (clangd -hidden-features flag).
   We may choose to promote these one day. I'm not sure they're worth their own
   feature flags though.

Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 363680
2019-06-18 13:37:54 +00:00
Sam McCall 8d41294c18 [clangd] Add a capability to enable completions with fixes.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 363664
2019-06-18 11:57:26 +00:00
Haojian Wu 8ddf31bc33 [clangd] Parse files without extensions if we don't have a compile command.
Summary: This would enable clangd for C++ standard library files.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 363663
2019-06-18 11:54:17 +00:00
Haojian Wu 40fdd7a643 [clangd] Detect C++ language based on well-known file path in vscode extension
Summary:
Matching the "C++" pattern on the first line of the file doesn't cover
all cases, MSVC C++ headers doesn't have such pattern. This patch
introduce a new heuristic to detect language based on the file path.

MSVC C++ standard headers are in the directory like
"c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include"

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 363662
2019-06-18 11:53:14 +00:00
Haojian Wu b5ce4e5ea3 [clangd] Perform merge for main file symbols.
Summary:
Previously, we randomly pick one main file symbol in dynamic index, we
may loose the ideal symbol (with definition location) in the index.

It fixes the issue where sometimes we fail to go to the symbol definition, see:

1. call go-to-decl on Foo in Foo.cpp
2. jump to Foo.h, call go-to-def on Foo in Foo.h

we can't go back to Foo.cpp -- because we open Foo.cpp, Foo.h in clangd, both
files have Foo symbol (one with def&decl, one with decl only), we randomely
choose one.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363568
2019-06-17 14:49:18 +00:00
Haojian Wu 7dc917603b [clangd] Bump vscode-clangd v0.0.15.
CHANGELOG:
- support detecting C++ language from first line (`-*- C++ -*-`) of the file.

llvm-svn: 363555
2019-06-17 13:18:24 +00:00
Haojian Wu d53027697c [clangd] Detect C++ for extension-less source files in vscode extension
Summary:
Extend our extension to support detecting these files as C++ files based on the first
line (`-*- C++ -*-`), it will make clangd work on C++ standard headers
(e.g. iostream).

We use the contributes.languages[1] to enrich the builtin VScode C++
support.

[1]: https://code.visualstudio.com/api/references/contribution-points#contributes.languages

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363554
2019-06-17 12:59:14 +00:00
Don Hinton 9d8c94dfd7 [docs] Fix another bot warning by adding a blank line to separate the `option::` command from the text below.
llvm-svn: 363520
2019-06-16 18:41:31 +00:00
Don Hinton 3a92aa2999 [docs] Fix a few problems with clang-tool docs to get the bots green again.
llvm-svn: 363518
2019-06-16 17:57:37 +00:00
Nathan Ridge a552508841 [clangd] Type hierarchy subtypes
Summary:
This builds on the relations support added in D59407, D62459, D62471,
and D62839 to implement type hierarchy subtypes.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363506
2019-06-16 02:31:37 +00:00
Don Hinton b3fc9fde2c Fix gcc-05.4 bot failures caused by in r363481 "[clangd] Index API and implementations for relations"
Use std::make_tuple instead of initializer list to make gcc-5.4 happy.

See https://reviews.llvm.org/D62839 for details.

llvm-svn: 363504
2019-06-16 01:09:41 +00:00
Nathan Ridge f1e6f5713c [clangd] Index API and implementations for relations
Summary:
This builds on the relations support added in D59407, D62459,
and D62471 to expose relations in SymbolIndex and its
implementations.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363481
2019-06-15 02:26:47 +00:00
Haojian Wu f907849e2e [clangd] Bump vscode-clangd v0.0.14
CHANGELOG:
- use the vscode-buildin feature to detect language (rather than using
  file extensions), this fixes the extension not working on
  non-standard C++ files (e.g. via files.associations)

llvm-svn: 363375
2019-06-14 12:11:04 +00:00
Haojian Wu 30557ace0f [clangd] Don't maintain a list of c-family extensions in vscode extension.
Summary:
There is no need to maintain this list by ourself, vscode already
provides this feature.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363372
2019-06-14 11:56:13 +00:00
Shaurya Gupta 822794ef85 Test commit
llvm-svn: 363365
2019-06-14 09:40:42 +00:00
Yitzhak Mandelbaum 67d4a6d48c [clang-tidy] Make ClangTidyCheck::OptionsView public.
Summary: The `OptionsView` class is currently protected. This constraint prevents tidies from passing the OptionsView to, for example, a helper function. Similarly, TransformerClangTidyCheck cannot pass the `OptionsView` object to functions that generate `tooling::RewriteRule`s.  The latter is needed to allow the definition of such rules to depend on the clang-tidy options, as demonstrated in the child revision.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 363296
2019-06-13 19:05:02 +00:00
Dmitri Gribenko 558369b549 [clang-tidy] Made abseil-faster-strsplit-delimiter tests pass on C++17
Reviewers: hokein, gribozavr

Reviewed By: hokein, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Patch by Johan Vikström.

llvm-svn: 363273
2019-06-13 15:16:44 +00:00
Dmitri Gribenko 0030306555 [clang-tidy] Fixed abseil-time-subtraction to work on C++17
Summary: Fixed abseil-time-subtraction to work on C++17

Reviewers: hokein, gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Patch by Johan Vikström.

llvm-svn: 363272
2019-06-13 15:11:02 +00:00
Dmitri Gribenko 93f96b2be9 [clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17
Summary: Made abseil-upgrade-duration-conversions tests pass on c++17

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Patch by Johan Vikström.

llvm-svn: 363270
2019-06-13 14:27:54 +00:00
Dmitri Gribenko ab240c5eee [clang-tidy] Fixed abseil-duration-unnecessary-conversion tests for c++17
Summary: Fixed abseil-duration-unnecessary-conversion tests for c++17

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Patch by Johan Vikström.

llvm-svn: 363263
2019-06-13 13:52:45 +00:00
Kadir Cetinkaya 88e636dfc1 [Clangd] Fixed clangd diagnostics priority
Summary:
- Fixed diagnostics where zero width inserted ranges were being used instead of the whole token
- Added unit tests

Patch by @SureYeaah !

Reviewers: sammccall, kadircet

Reviewed By: kadircet

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

Tags: #clang-tools-extra, #clang

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

llvm-svn: 363253
2019-06-13 12:31:36 +00:00
Kadir Cetinkaya 4977927536 [clangd] Treat lambdas as functions when preparing hover response
Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363237
2019-06-13 08:51:44 +00:00
Ilya Biryukov 04112ecd41 [clangd] Return TextEdits from ClangdServer::applyTweak
Summary:
Instead of `tooling::Replacements`. So that embedders do not need to store
the contents of the file.

This also aligns better with `ClangdServer::rename`.

Reviewers: kadircet, hokein

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363150
2019-06-12 12:03:24 +00:00
Nikolai Kosjar f6efac67e1 [clangd] Fix typo in GUARDED_BY()
Reviewers: ilya-biryukov, kadircet, sammccall

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

Tags: #clang

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

llvm-svn: 363139
2019-06-12 11:01:19 +00:00
Dmitri Gribenko cf7d768351 Fixed a crash in misc-redundant-expression ClangTidy checker
Summary: It was trying to pass a dependent expression into constant evaluator.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 363133
2019-06-12 08:40:53 +00:00
Nikolai Kosjar be8d03a512 [clang-tidy] Fix invalid read on destruction
...in case the clang tidy plugin is linked into the clang binary.

Valgrind's memcheck reports:

8949== Invalid read ==8866== Invalid read of size 4
8866== at 0x164D248B: fetch_sub (atomic_base.h:524)
8866== by 0x164D248B: llvm::ThreadSafeRefCountedBase<clang::ast_matchers::internal::DynMatcherInterface>::Release() const (IntrusiveRefCntPtr.h:98)
8866== by 0x164CE16C: llvm::IntrusiveRefCntPtrInfo<clang::ast_matchers::internal::DynMatcherInterface>::release(clang::ast_matchers::internal::DynMatcherInterface*) (IntrusiveRefCntPtr.h:127)
8866== by 0x164C8D5C: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::release() (IntrusiveRefCntPtr.h:190)
8866== by 0x164C3B87: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::~IntrusiveRefCntPtr() (IntrusiveRefCntPtr.h:157)
8866== by 0x164BB4F1: clang::ast_matchers::internal::DynTypedMatcher::~DynTypedMatcher() (ASTMatchersInternal.h:341)
8866== by 0x164BB529: clang::ast_matchers::internal::Matcher<clang::QualType>::~Matcher() (ASTMatchersInternal.h:496)
8866== by 0xD7AE614: __cxa_finalize (cxa_finalize.c:83)
8866== by 0x164B3082: ??? (in /d2/llvm/8/qtc/builds/DebugShared/lib/libclangTidyModernizeModule.so.8)
8866== by 0x4010B72: _dl_fini (dl-fini.c:138)
8866== by 0xD7AE040: __run_exit_handlers (exit.c:108)
8866== by 0xD7AE139: exit (exit.c:139)
8866== by 0xD78CB9D: (below main) (libc-start.c:344)
8866== Address 0x19dd9bc8 is 8 bytes inside a block of size 16 free'd
8866== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB99: clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl::~TrueMatcherImpl() (ASTMatchersInternal.cpp:126)
8866== by 0x1469BBC5: llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call(void*) (ManagedStatic.h:30)
8866== by 0x9ABFF26: llvm::ManagedStaticBase::destroy() const (ManagedStatic.cpp:72)
8866== by 0x9ABFF94: llvm::llvm_shutdown() (ManagedStatic.cpp:84)
8866== by 0x9A65232: llvm::InitLLVM::~InitLLVM() (InitLLVM.cpp:52)
8866== by 0x14B0C8: main (driver.cpp:323)
8866== Block was alloc'd at
8866== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB36: llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call() (ManagedStatic.h:24)
8866== by 0x9ABFD99: llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const (ManagedStatic.cpp:42)
8866== by 0x1469B5DF: llvm::ManagedStatic<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl, llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>, llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl> >::operator*() (ManagedStatic.h:67)
8866== by 0x14698F9D: clang::ast_matchers::internal::DynTypedMatcher::trueMatcher(clang::ast_type_traits::ASTNodeKind) (ASTMatchersInternal.cpp:195)
8866== by 0x164C9D3B: _ZNK5clang12ast_matchers8internal11TrueMatchercvNS1_7MatcherIT_EEINS_8QualTypeEEEv (ASTMatchersInternal.h:1247)
8866== by 0x16501458: __static_initialization_and_destruction_0(int, int) (LoopConvertCheck.cpp:48)
8866== by 0x16501976: _GLOBAL__sub_I_LoopConvertCheck.cpp (LoopConvertCheck.cpp:920)
8866== by 0x4010732: call_init (dl-init.c:72)
8866== by 0x4010732: _dl_init (dl-init.c:119)
8866== by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so)

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

llvm-svn: 363068
2019-06-11 14:19:09 +00:00
Clement Courbet f63feaf3c2 [clang-tidy] Fix typo in bugprone-string-constructor.
s/bigger then/bigger than/

llvm-svn: 363053
2019-06-11 12:12:06 +00:00
Dmitri Gribenko be20daa8eb Fixed google-readability-casting test to work in c++17
Summary: Fixed google-readability-casting.cpp to get tests working in c++17

Reviewers: gribozavr, hokein

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Patch by Shaurya Gupta.

llvm-svn: 363047
2019-06-11 10:59:22 +00:00
Haojian Wu b011ee8ae8 [clangd] Add missing header guard.
llvm-svn: 363037
2019-06-11 08:50:35 +00:00
Mikael Holmen e2acbeb94c [clangd] Fix gcc warning by removing extra ";"
llvm-svn: 363034
2019-06-11 06:02:01 +00:00
Sam McCall c920c37361 [clangd] Remove old hidden -use-dex-index flag
llvm-svn: 362978
2019-06-10 20:38:16 +00:00
Sam McCall 25c6257ba0 [clangd] Revamp textDocument/onTypeFormatting.
Summary:
The existing implementation (which triggers on }) is fairly simple and
has flaws:
 - doesn't trigger frequently/regularly enough (particularly in editors that type the }
 for you)
 - often reformats too much code around the edit
 - has jarring cases that I don't have clear ideas for fixing

This implementation is designed to trigger on newline, which feels to me more
intuitive than } or ;.
It does have allow for reformatting after other characters - it has a
basic behavior and a model for adding specialized behavior for
particular characters. But at least initially I'd stick to advertising
\n in the capabilities.

This also handles comment splitting: when you insert a line break inside
a line comment, it will make the new line into an aligned line comment.

Working on tests, but want people to patch it in and try it - it's hard to
see if "feel" is right purely by looking at a test.

Reviewers: ilya-biryukov, hokein

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

Tags: #clang

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

llvm-svn: 362939
2019-06-10 14:26:21 +00:00
Sam McCall 149786d5b7 [clangd] Stop marshalling/requiring FormattingOptions. We never did anything with them.
llvm-svn: 362934
2019-06-10 13:01:49 +00:00
Ilya Biryukov a7a1147d4f [clangd] Return empty results on spurious completion triggers
Summary:
We currently return an error, this causes `coc.nvim` and VSCode to
show an error message in the logs.

Returning empty list of completions allows to avod the error message
without altering other user-visible behavior.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 362811
2019-06-07 16:24:38 +00:00
Haojian Wu a4f5a2ad1f [clang-tidy] Another attempt to fix misc-redundant-expression check.
Correct the fix of rL3627011, the isValueDependent guard was added in a wrong place in rL362701.

llvm-svn: 362706
2019-06-06 13:43:38 +00:00
Nikolai Kosjar 60e1296a9a [clang-tidy] Make the plugin honor NOLINT
Instantiate a ClangTidyDiagnosticConsumer also for the plugin case and
let it forward the diagnostics to the external diagnostic engine that is
already in place.

One minor difference to the clang-tidy executable case is that the
compiler checks/diagnostics are referred to with their original name.
For example, for -Wunused-variable the plugin will refer to the check as
"-Wunused-variable" while the clang-tidy executable will refer to that
as "clang-diagnostic- unused-variable". This is because the compiler
diagnostics never reach ClangTidyDiagnosticConsumer.

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

llvm-svn: 362702
2019-06-06 13:13:27 +00:00
Haojian Wu df95e6109e [clang-tidy] Fix an assertion failure in misc-redundant-expression.
Summary:
The assertion "isIntegerConstantExpr" is triggered in the
isIntegerConstantExpr(), we should not call it if the expression is value
dependent.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362701
2019-06-06 12:58:48 +00:00
Ilya Biryukov 54eeb3f40a [clangd] Remove unused signature help quality signal. NFC
ContainsActiveParameter is not used anywhere, set incorrectly (see the
removed FIXME) and has no unit tests.
Removing it to simplify the code.

llvm-svn: 362686
2019-06-06 08:32:25 +00:00
Haojian Wu 448acbc06f [clang-tidy] Fix make-unique tests on C++2a.
Summary:
These test cases are illgal in C++2a ("new Foo{}" needs to see the
default constructor), so move them to the C++14-only tests.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362679
2019-06-06 07:48:55 +00:00
George Burgess IV 5b2a85d0de android: add a close-on-exec check on pipe()
On Android, pipe() is better to be replaced by pipe2() with O_CLOEXEC
flag to avoid file descriptor leakage.

Patch by Jian Cai!

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

llvm-svn: 362673
2019-06-06 05:21:45 +00:00
George Burgess IV 3da331b456 android: add a close-on-exec check on pipe2()
On Android, pipe2() is better to set O_CLOEXEC flag to avoid file
descriptor leakage.

Patch by Jian Cai!

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

llvm-svn: 362672
2019-06-06 05:21:39 +00:00
Ilya Biryukov 2df387b057 [clangd] Minor cleanup. NFC
Removed unused using declaration from TweakTests.cpp

llvm-svn: 362517
2019-06-04 16:19:11 +00:00
Kadir Cetinkaya a7f9f42d28 [clangd] Also apply adjustArguments when returning fallback commands
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362496
2019-06-04 13:38:36 +00:00
Simon Pilgrim 5b41fe58de Fix -Wparentheses warning. NFCI.
llvm-svn: 362491
2019-06-04 11:31:45 +00:00
Simon Pilgrim 5f7c20e279 Fix Wshadow warning
llvm-svn: 362489
2019-06-04 11:11:51 +00:00
Ilya Biryukov 4ef0f82b71 [clangd] Support offsets for parameters in signatureHelp
Summary: Added to LSP in version 3.14

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 362481
2019-06-04 09:36:59 +00:00
Ilya Biryukov 65de43bc8b [clangd] Fix a crash when clang-tidy is disabled
llvm-svn: 362469
2019-06-04 07:19:11 +00:00
Nathan Ridge 73e6f47da2 [clangd] SymbolCollector support for relations
Summary:
The only relation currently collected is RelationBaseOf, because this is
all we need for type hierarchy subtypes. Additional relations can be
collected in the future as the need arises.

This patch builds on D59407 and D62459.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362467
2019-06-04 04:25:44 +00:00
Ilya Biryukov 1a44584588 [CodeComplete] Add a bit more whitespace to completed patterns
Summary:
E.g. we now turn `while(<#cond#>){` into `while (<#cond#>) {`

This slightly improves the final output. Should not affect clients that
format the result on their own.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 362363
2019-06-03 08:34:25 +00:00
Haojian Wu ceb0cc54f9 [clang-tidy] Fix make-unique check to work in C++17 mode.
Summary:
Previously, we intended to omit the check fix to the case when constructor has
any braced-init-list argument. But the HasListInitializedArgument was not
correct to handle all cases (Foo(Bar{1, 2}) will return false in C++14
mode).

This patch fixes it, corrects the tests, and makes the check to run at C++17 mode.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362361
2019-06-03 08:14:15 +00:00
Nathan Ridge 92524f9bf8 [clangd] Serialization support for RelationSlab
Summary: This builds on D59407 to provide YAML and RIFF serialization support.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362353
2019-06-03 05:07:52 +00:00
Nathan Ridge 3fc299df3d [clangd] Add RelationSlab
Summary:
RelationSlab is a new index data structure that stores relations between
symbols.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362352
2019-06-03 04:55:46 +00:00
Stephane Moore ec1982f07f Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

This is an amended re-submission of https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d.

Contributed By: yaqiji

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

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

llvm-svn: 362279
2019-05-31 23:41:15 +00:00
Haojian Wu 488c509d45 [clangd] Add missing license for rename.cpp, NFC.
llvm-svn: 362226
2019-05-31 14:38:16 +00:00
Nathan Ridge b2f45ac299 [clangd] clang-format SymbolCollector.cpp
llvm-svn: 362176
2019-05-30 23:54:43 +00:00
Chris Bieneman 760a9ee63c Support codesigning bundles and forcing
Summary:
Clangd's framework is assembled by copying binaries from the lib and bin directories into a bundle shape. This results in an invalid bundle code signature because the signature only applies to the binaries not the resources.

This patch adds two new options to `llvm_codesign` to enable re-signing the library and XPC service as bundles.

The `BUNDLE_PATH` option allow specifying an explicit path to codesign, which enables signing bundles which aren't generated using CMake's `FRAMEWORK` or `BUNDLE` target properties.

The `FORCE` option allows re-signing binaries that have already been signed. This is required for how clangd exposes the clangd library and tools as both XPC and non-XPC services using the same binary.

Reviewers: jkorous, bogner

Reviewed By: bogner

Subscribers: mgorny, ilya-biryukov, dexonsmith, arphaman, kadircet, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 362169
2019-05-30 22:25:48 +00:00
Ilya Biryukov f6faa382f3 [Index] Compute correct symbol kind for variable templates
Summary:
The index library itself seems to never pass variable templates as
input, however clangd does.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361996
2019-05-29 17:49:30 +00:00
Ilya Biryukov c450874cb8 [clangd] Map typedefs to the same LSP completion kind as VSCode
For consistency and, more importantly, to get a nicer icon for those in VSCode.

llvm-svn: 361969
2019-05-29 15:10:19 +00:00
Haojian Wu 228b130a4b [clangd] Fix buildbot error.
llvm-svn: 361960
2019-05-29 14:11:53 +00:00
Haojian Wu 4c5a0d1683 [clangd] Remove the whitelist std symbols in CanonicalIncludes.
Summary: These symbols have been included via StdSymbolMap.inc.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 361952
2019-05-29 12:08:11 +00:00
Haojian Wu 78c5fa97eb [clangd] Another improvement for std include mapping.
Summary:
Improve the way of checking a symbol name is in the first cell. The previous way
is not very robost for cases where a cell lists multiple symbols (e.g. int8_t).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 361951
2019-05-29 12:03:41 +00:00
Ilya Biryukov bf559a7f3f [Index] Correctly set symbol kind of IndirectFieldDecl
Summary: The kind has been 'unknown' before, now it is 'field'.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361941
2019-05-29 10:11:14 +00:00
Ilya Biryukov f9169d0896 [clangd] Represent Hover result using FormattedString
Reviewers: sammccall, kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 361940
2019-05-29 10:01:00 +00:00
Stephane Moore 9ac757bf09 Rollback "Revise the google-objc-global-variable-declaration check to match the style guide." 💥
The change introduced new test failures.

Phabricator URL of original commit: https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d

llvm-svn: 361914
2019-05-29 02:23:32 +00:00
Stephane Moore 12e3726fad Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

Contributed by yaqiji.

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

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

llvm-svn: 361907
2019-05-29 01:36:23 +00:00
Sam McCall 81748bae47 [clangd] Add SourceManager accessor to ParsedAST. NFC
llvm-svn: 361883
2019-05-28 21:52:34 +00:00
Joel E. Denny 91f8066d1d [OpenMP] Set pragma start loc to `#pragma` loc
This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

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

llvm-svn: 361867
2019-05-28 19:27:19 +00:00
Ilya Biryukov 800db530d9 [clangd] Fix test output for r361841
llvm-svn: 361846
2019-05-28 16:28:27 +00:00
Ilya Biryukov 8534675cef [clangd] Place cursor better after completing patterns
Summary:
By producing the $0 marker in the snippets at the last placeholder.
This produces nicer results in most cases, e.g. for
   namespace <#name#> {
     <#decls#>
   }

we now produce ${0:decls} instead of ${2:decls} and the final cursor
placement is more convenient.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 361841
2019-05-28 15:33:37 +00:00
Haojian Wu eb006d3268 [clang-tidy] Fix description for misc-definitions-in-headers.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361834
2019-05-28 14:50:42 +00:00
Haojian Wu dfc0ca0c80 [clang-tidy] Verify fix description for misc-unused-using-decl.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361833
2019-05-28 14:47:39 +00:00
Ilya Biryukov b4a394506c [clangd] Compute expected type for templates
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 361823
2019-05-28 13:56:21 +00:00
Haojian Wu 2255b31cec [clang-tidy] Fix null pointer dereference in readability-identifier-naming
Summary:
readability-identifier-naming causes a null pointer dereference when checking an identifier introduced by a structured binding whose right hand side is an undeclared identifier.

Running the check on a file that is just the following results in a crash:
```
auto [left] = right;
```

Patch by Mark Stegeman!

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, aaron.ballman

Subscribers: madsravn, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361809
2019-05-28 11:54:01 +00:00
Kadir Cetinkaya c6578eefdd [clangd] Introduce a structured hover response
Summary:
Change ClangdServer layer to output a structured response for Hover,
which can be rendered by client according to their needs.

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 361803
2019-05-28 10:29:58 +00:00
Ilya Biryukov d12f48beda [clangd] Never end command-line flag description with a period. NFC
For consistency. Not having a period at the end is much more common and
seems to be the preferred style for command-line options.

llvm-svn: 361800
2019-05-28 09:31:27 +00:00
Ilya Biryukov 536a62d007 [clangd] Rename -run-synchronously to -sync
llvm-svn: 361798
2019-05-28 09:20:57 +00:00
Haojian Wu c11de5eada [clang-tidy] Fix unused-variable warning after r361647.
Summary:
A range-for was added in r361647 where the range variable was only used in an
assertion.  As a result, it warned for Release builds. This revision
restructures the assertion to avoid the problem.

Patch by Yitzhak Mandelbaum.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361749
2019-05-27 08:09:02 +00:00
Mads Ravn bd324fa227 DeleteNullPointerCheck now deletes until the end brace of the condition.
Patch by Jonathan Camilleri

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

llvm-svn: 361735
2019-05-26 17:00:38 +00:00
Heejin Ahn e6e038c322 [clangd] tweaks: Add clangBasic dependency to LINK_LIBS
This is necessary to make builds with `-DBUILD_SHARED_LIBS=ON` work.

llvm-svn: 361687
2019-05-25 01:35:14 +00:00
Nico Weber bab1d8edcf Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory
See "[cfe-dev] The name of clang/lib/Tooling/Refactoring".

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

llvm-svn: 361684
2019-05-25 00:27:19 +00:00
Yitzhak Mandelbaum 5b33554319 [clang-tidy] In TransformerClangTidyCheck, require Explanation field.
Summary:
In general, the `Explanation` field is optional in `RewriteRule` cases. But,
because the primary purpose of clang-tidy checks is to provide users with
diagnostics, we assume that a missing explanation is a bug.  This change adds an
assertion that checks all cases for an explanation, and updates the code to rely
on that assertion correspondingly.

Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361647
2019-05-24 16:32:03 +00:00
Dmitri Gribenko b7f2a2b4c0 Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on platforms where char is unsigned
The other options are to completely specify the triple (reduces test
coverage), or to specify a regex that allows either '0' or '0U' for char
initializers, however, that relaxes the test.

llvm-svn: 361629
2019-05-24 10:50:15 +00:00
Dmitri Gribenko f2d5b7a4fa Made cppcoreguidelines-pro-type-member-init-use-assignment run in all language modes
llvm-svn: 361628
2019-05-24 10:39:00 +00:00
Ilya Biryukov 0f748e6e9b [clangd] Limit the size of synthesized fix message
Summary: A temporary workaround until we figure out a better way to present fixes.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361625
2019-05-24 10:26:23 +00:00
Ilya Biryukov cabab29af2 [CodeComplete] Filter override completions by function name
Summary:
We put only part of the signature starting with a function name into "typed text"
chunks now, previously the whole signature was "typed text".

This leads to meaningful fuzzy match scores, giving better signals to
compare with other completion items.

Ideally, we would not display the result type to the user, but that requires adding
a new kind of completion chunk.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361623
2019-05-24 10:18:39 +00:00
Simon Pilgrim c472f7b010 Fix sphinx "Malformed option description" warning
llvm-svn: 361616
2019-05-24 09:31:32 +00:00
Matthias Gehre b087129b5d [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init
Differential Revision: D24892

llvm-svn: 361601
2019-05-24 05:46:57 +00:00
Tamas Zolnai dab31924e9 [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment
Summary:
Added WarnOnlyIfThisHasSuspiciousField option to allow
to catch any copy assignment operator independently from
the container class's fields.
Added the cert alias using this option.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

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

Tags: #clang

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

llvm-svn: 361550
2019-05-23 20:29:04 +00:00
Simon Pilgrim 30905a375e Fix sphinx unknown document error
llvm-svn: 361545
2019-05-23 20:07:27 +00:00
Ilya Biryukov 346758407e [Index] Fix reported references in presence of template type aliases
Summary: See the added test for an example.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361511
2019-05-23 16:48:47 +00:00
Kadir Cetinkaya fb6ee67ab1 [clangd] Also update package-lock.json
llvm-svn: 361488
2019-05-23 12:02:14 +00:00
Dmitri Gribenko 1520dafa20 [clang-tidy] New check calling out uses of +new in Objective-C code
Summary:
Google's Objective-C style guide forbids calling or overriding +new to instantiate objects. This check warns on violations.

Style guide reference: https://google.github.io/styleguide/objcguide.html#do-not-use-new

Patch by Michael Wyman.

Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, stephanemoore, mwyman

Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman

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

Tags: #clang, #clang-tools-extra

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

llvm-svn: 361487
2019-05-23 12:01:26 +00:00
Kadir Cetinkaya 7d230d2661 [clangd] Bump vscode extension version
llvm-svn: 361486
2019-05-23 11:58:03 +00:00
Kadir Cetinkaya b970fd7188 [clangd-vscode] Do not customize uri converters in vscode
Summary:
Clangd is already resolving symlinks on the server side, therefore
there is no more need to handle it in client side. This was also resulting in
breakages whenever index contained a symbol coming from a non-existent file(like
a generated file), e.g. during workspace symbols whole response was dropped
since stat had failed.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361475
2019-05-23 09:58:29 +00:00
Ilya Biryukov eee5d425c1 [clangd-vscode] Bump versions dependencies. NFC
Result of running 'npm audit fix', which tracks security vulnerabilities.

llvm-svn: 361464
2019-05-23 08:06:24 +00:00
George Burgess IV 3d68a38be8 Remove unnecessary const&s; NFC
It's uncommon to rely on temporary lifetime extension when having a
regular, non-`const&` value behaves identically. Since `Twine::str`
and `buildFixMsgForStringFlag` both return regular `std::string`s,
there's seemingly no point in having `const&` here.

llvm-svn: 361457
2019-05-23 02:52:39 +00:00
Yitzhak Mandelbaum 9df7ce596b [clang-tidy] Add support for writing a check as a Transformer rewrite rule.
This revision introduces an adaptor from Transformer's rewrite rules
(`clang::tooling::RewriteRule`) to `ClangTidyCheck`.  For example, given a
RewriteRule `MyCheckAsRewriteRule`, it lets one define a tidy check as follows:

```
class MyTidyCheck : public TransformerClangTidyCheck {
 public:
  MyTidyCheck(StringRef Name, ClangTidyContext *Context)
      : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {}
};
```

Reviewers: aaron.ballman

Subscribers: mgorny, xazax.hun, cfe-commits, ilya-biryukov

Tags: #clang

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

llvm-svn: 361418
2019-05-22 18:56:18 +00:00
Kadir Cetinkaya eae2c64932 [clangd] improve help message for limit-results
Summary: Make it clear that the default is 100.

Patch by Brennan Vincent(@umanwizard)!

Reviewers: #clang-tools-extra, kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 361388
2019-05-22 14:19:40 +00:00
Don Hinton 24d27689bc [clang-tidy] remove default header-filter for run-clang-tidy
Summary:
run-clang-tidy.py was enforcing '-header-filter' parameter with an
unfortunate default value when none was given. Thus, leading to
overwritten clang-tidy configuration (e.g. from .clang-tidy).

This change removes the default value for '-header-filter' resulting in
the default behaviour of clang-tidy itself.

Fixes PR#41426

Reviewed By: hintonda

Patch by Torbjörn Klatt!

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361344
2019-05-22 01:01:11 +00:00
Sam McCall 0321b370f2 [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 361258
2019-05-21 13:40:31 +00:00