Commit Graph

5483 Commits

Author SHA1 Message Date
Vladimir Plyashkun 4de6b15868 Add an option to hicpp-signed-bitwise for positive integer literals.
This gives developers a way to deviate from the coding standard to reduce the
chattiness of the check.
2019-10-30 14:11:29 -04:00
Aaron Ballman 0de262d718 Move this release note to its appropriate location; NFC. 2019-10-30 13:48:26 -04:00
Aaron Ballman 661d2ce619 Fix modernize-use-nodiscard for classes marked [[nodiscard]]
Current implementation suggests to add [[nodiscard]] to methods even if the
return type is marked already as [[nodiscard]].

Patch by Eugene Sedykh.
2019-10-30 13:45:37 -04:00
Aaron Ballman 1caa66d075 Fix a false positive in misc-redundant-expression check
Do not warn for redundant conditional expressions when the true and false
branches are expanded from different macros even when they are defined by
one another.

Patch by Daniel Krupp.
2019-10-30 13:38:25 -04:00
Aaron Ballman 29dc0b17de Add the readability-redundant-access-specifiers check.
This finds redundant access specifier declarations inside classes, structs, and unions.

Patch by Mateusz Mackowski.
2019-10-30 13:30:57 -04:00
Haojian Wu 80b0cdde0f [clangd] Add a hidden tweak to dump symbol under the cursor.
Summary:
This provides a convenient way to see the SymbolID/USR of the symbol, mainly
for debugging purpose.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69517
2019-10-29 13:06:34 +01:00
Haojian Wu f821ab807d [clangd] NFC, use URI::resolve to simplify the code. 2019-10-29 10:53:16 +01:00
Haojian Wu 94cd2f0303 [clangd] Add missing highlights for using decls.
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69506
2019-10-29 09:49:42 +01:00
Simon Pilgrim 93a3128a67 Remove extra ';'. NFCI. 2019-10-28 16:32:02 +00:00
Ilya Biryukov 4c430a7c6f [clangd] Do not report anonymous entities in findExplicitReferences
Summary:
Otherwise every client dealing with name location should handle
anonymous names in a special manner.

This seems too error-prone, clients can probably handle anonymous
entities they care about differently.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69511
2019-10-28 14:41:34 +01:00
Kadir Cetinkaya 3cb5764f90
[clangd] Flush streams when printing HoverInfo Name and Definition
Summary: Fixes some windows breakages when compiled via msvc.
2019-10-28 12:05:03 +01:00
Ilya Biryukov c814f4c459 [clangd] Do not highlight keywords in semantic highlighting
Summary:
Editors are good at highlightings the keywords themselves.
Note that this only affects highlightings of builtin types spelled out
as keywords in the source code. Highlightings of typedefs to builtin
types are unchanged.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69431
2019-10-28 12:03:09 +01:00
Ilya Biryukov d9971d0b2e [clangd] Do not insert parentheses when completing a using declaration
Summary:
Would be nice to also fix this in clang, but that looks like more work
if we want to preserve signatures in informative chunks.

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

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69382
2019-10-28 09:45:10 +01:00
Kadir Cetinkaya f4d7caf6df
[clangd] Reland Store Index in Tweak::Selection
Summary:
Incoming define out-of-line tweak requires access to index.

This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69165
2019-10-28 07:55:58 +01:00
Kadir Cetinkaya 3d65def1fd
[clangd] Reland DefineInline action apply logic with fully qualified names
Summary:
Initial version of DefineInline action that will fully qualify every
name inside function body.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66647
2019-10-28 07:45:38 +01:00
Kadir Cetinkaya 5ab9a850f6
[clangd] Reland DefineInline action availability checks
Summary:
Introduces DefineInline action and initial version of availability
checks.

Reviewers: sammccall, ilya-biryukov, hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65433
2019-10-28 07:28:21 +01:00
Kadir Cetinkaya 1a9c01c7f6
[clangd] Pass ExtraArgs to TestTU in TweakIsAvailable matcher 2019-10-28 07:18:26 +01:00
Kadir Cetinkaya 8e567b0730
[clangd] Revert define-inline action changes to un-break windows build-bots 2019-10-25 18:40:01 +02:00
Kadir Cetinkaya 43e931cb5f
[clangd][NFC] Get rid of raw string literals in macros to make stage1 compiler happy 2019-10-25 15:01:28 +02:00
Kadir Cetinkaya ce1e249a68
Fix compilation error in clangd/refactor/tweaks/ExpandAutoType.cpp
Summary:
During the compilation of the `clangd/refactor/tweaks/ExpandAutoType.cpp`, MSVC returns the following error:

llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2146: syntax error: missing ')' before identifier 'and'
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2065: 'and': undeclared identifier
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(86): error C2143: syntax error: missing ';' before '<template-id>'
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(73): fatal error C1075: '{': no matching token found

So, && must be used instead of `and`.

Patch By Pavel Samolysov (@psamolysov) !

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D69427
2019-10-25 14:16:59 +02:00
Kadir Cetinkaya 8aa84ad37d
[clangd] Store Index in Tweak::Selection
Summary:
Incoming define out-of-line tweak requires access to index.

This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69165
2019-10-25 12:15:20 +02:00
Kadir Cetinkaya d62e3ed3f4
[clangd] Implement GetEligiblePoints
Summary:
This is an helper for incoming move definition out-of-line action to
figure out possible insertion locations for definition of a qualified name.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68024
2019-10-25 12:13:30 +02:00
Kadir Cetinkaya dfd6374c78
[clangd] DefineInline action apply logic with fully qualified names
Summary:
Initial version of DefineInline action that will fully qualify every
name inside function body.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66647
2019-10-25 11:52:47 +02:00
Kadir Cetinkaya 74d39a42f1
[clangd] DefineInline action availability checks
Summary:
Introduces DefineInline action and initial version of
availability checks.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65433
2019-10-25 11:52:47 +02:00
Ilya Biryukov ed913a2915 [clangd] Fix case of variables and functions in code complete tests. NFC 2019-10-24 15:41:50 +02:00
Haojian Wu 13fc899cde [clangd] Handle the missing constructor initializers in findExplicitReferences.
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69241
2019-10-24 10:38:37 +02:00
Haojian Wu bf71e4fe0a [clangd] Collect name references in the index.
Summary:
This is used for cross-file rename. When renaming a class, we expect to
rename all related constructors/destructors.

Reviewers: kadircet, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69338
2019-10-24 10:25:16 +02:00
Sam McCall 8bda5f2067 [clangd] abort if shutdown takes more than a minute.
Summary:
A certain class of bug (e.g. infloop on an AST worker thread) currently means
clangd never terminates, even if the editor shuts down the protocol and closes
our stdin, and the main thread recognizes that.

Instead, let's wait 60 seconds for threads to finish cleanly, and then crash
if they haven't.

(Obviously, we should still fix these bugs).

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69329
2019-10-23 17:52:59 +02:00
Kadir Cetinkaya 10c8dbcb84 [clangd] Propogate context in TUScheduler::run
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69328
2019-10-23 15:31:24 +02:00
Reid Kleckner 90c64a3456 Move endian constant from Host.h to SwapByteOrder.h, prune include
Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

llvm-svn: 375316
2019-10-19 00:48:11 +00:00
Haojian Wu 65f61c0030 [clangd] Report declaration references in findExplicitReferences.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 375226
2019-10-18 12:07:19 +00:00
Haojian Wu c8e3f43ab5 [clangd] Use our own relation kind.
Summary:
Move the RelationKind from Serialization.h to Relation.h. This patch doesn't
introduce any breaking changes.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 375117
2019-10-17 14:08:28 +00:00
Simon Pilgrim 2ea8b58cb6 clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

llvm-svn: 375102
2019-10-17 11:12:53 +00:00
Joel E. Denny d3dd489b9a [lit] Fix another test case that r374652 missed
llvm-svn: 375058
2019-10-16 23:58:58 +00:00
Michael Liao b4874226de [clangd] Add the missing dependency on `clangLex`.
llvm-svn: 375039
2019-10-16 20:22:54 +00:00
Utkarsh Saxena b62b454121 [clangd] Add RemoveUsingNamespace tweak.
Summary:
Removes the 'using namespace' under the cursor and qualifies all accesses in the current file.
E.g.:
  using namespace std;
  vector<int> foo(std::map<int, int>);
Would become:
  std::vector<int> foo(std::map<int, int>);

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

Tags: #clang

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

llvm-svn: 374982
2019-10-16 09:53:59 +00:00
Kadir Cetinkaya b18170660e [clangd][NFC] Update comments to use triple-slashes
llvm-svn: 374901
2019-10-15 14:59:08 +00:00
Kadir Cetinkaya 9d66247e9b [clangd] Propagate main context into ClangdServer
Summary:
Currently clangd initializes the ClangdServer lazily during
onInitialize request, and it results in propagation of caller's context rather
than the main context created ClangdLSPServer.

This patch changes the logic to store main context that created ClangdLSPServer
and pass it onto to ClangdServer and other objects like CDBs.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 374892
2019-10-15 14:20:52 +00:00
Michal Gorny 9c9bd1657c [clang-tools-extra] Fix overzealous linking of dylib to clangTidy
Fix accidentally making clangTidy library link to dylib.  This causes
libclang.so to also link to dylib which results in duplicate symbols
from shared and static libraries, and effectively to registering
command-line options twice.

Thanks to Sylvestre Ledru for noticing this and tracking it down
to r373786.  Fixes PR#43589.

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

llvm-svn: 374885
2019-10-15 13:05:38 +00:00
Jan Korous c5d14b5c6f [clang-scan-deps] Support for clang --analyze in clang-scan-deps
The goal is to have 100% fidelity in clang-scan-deps behavior when
--analyze is present in compilation command.

At the same time I don't want to break clang-tidy which expects
__static_analyzer__ macro defined as built-in.

I introduce new cc1 options (-setup-static-analyzer) that controls
the macro definition and is conditionally set in driver.

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

llvm-svn: 374815
2019-10-14 20:15:01 +00:00
Nathan Ridge 37e31e629d [clangd] Improve semantic highlighting in dependent contexts (fixes #154)
Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 374799
2019-10-14 18:26:13 +00:00
Nico Weber eecef1e5a5 clangd tests: use extended regex with sed
The escaped parens seem to confuse the combination of lit, cygwin
quoting, and cygwin's sed. unxutils sed in cmd.exe is fine with both
forms, so use the extended regex form that doesn't need an escaped
paren.

llvm-svn: 374753
2019-10-14 03:44:47 +00:00
Nico Weber 282b36c1ce convert another test to unix line endings
llvm-svn: 374752
2019-10-14 02:21:12 +00:00
Nico Weber 61d2655690 convert a test to unix line endings
llvm-svn: 374751
2019-10-14 02:14:18 +00:00
Nico Weber a05d254b82 fix typo in 374747
llvm-svn: 374750
2019-10-14 01:44:29 +00:00
Nico Weber 1f1703f5c7 Prefer 'env not' over 'not env' in tests.
That way, lit's builtin 'env' command can be used for the 'env' bit.

Also it's clearer that way that the 'not' shouldn't cover 'env'
failures.

llvm-svn: 374749
2019-10-14 01:41:56 +00:00
Nico Weber 9f1bb5b9a8 Make symbols.test pass on Windows.
See commit message of r374746 for details.

Hopefully final bit of PR43592.

llvm-svn: 374747
2019-10-14 01:19:53 +00:00
Nico Weber 3e54997e77 Make code-action-request.test and request-reply.test pass on Windows.
clangd's test:// scheme expands to /clangd-test on non-Win and to
C:/clang-test on Win, so it can't be mixed freely with
file:///clangd-test since that's wrong on Windows. This makes both
tests consistenly use the test:// scheme. (Alternatively, we could use
the //INPUT_DIR pattern used in a few other tests.)

Part of PR43592.

llvm-svn: 374746
2019-10-14 01:00:33 +00:00
Nico Weber c445c0cb0a Don't run background-index.test on Windows.
The test had a "UNSUPPORTED: win32" line, but the spelling of that
changed in r339307 a year ago. Finally update this test too.

Part of PR43592.

llvm-svn: 374745
2019-10-14 00:45:02 +00:00
Nico Weber 5d8870bc76 Add missing "REQUIRES: shell" to system-include-extractor.test
Part of PR43592.

llvm-svn: 374730
2019-10-13 17:43:16 +00:00
Nico Weber 9d80a722d7 Make the last to clangd unit tests pass on Windows.
(Some lit tests still fail.)

See FIXME in diff for details.

Part of PR43592.

llvm-svn: 374727
2019-10-13 17:19:00 +00:00
Nico Weber 51fa7409e7 Make most clangd unittests pass on Windows
The Windows triple currently turns on delayed template parsing, which
confuses several unit tests that use templates.

For now, just explicitly disable delayed template parsing. This isn't
ideal, but:

- the Windows triple will soon no longer use delayed template parsing
  by default

- there's precedent for this in the clangd unit tests already

- let's get the clangd tests pass on Windows first before making
  behavioral changes

Part of PR43592.

llvm-svn: 374718
2019-10-13 13:15:27 +00:00
Csaba Dabis d2b790eb68 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 4
llvm-svn: 374715
2019-10-13 10:59:30 +00:00
Csaba Dabis b56989bcc7 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 3
On Windows the signed/unsigned int conversions of APInt seems broken, so that
two of the test files marked as unsupported on Windows, as a hotfix.

llvm-svn: 374713
2019-10-13 10:41:13 +00:00
Csaba Dabis 78037577f1 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 2
llvm-svn: 374712
2019-10-13 10:20:58 +00:00
Csaba Dabis 3965c76abc [clang-tidy] bugprone-not-null-terminated-result: checker adjustments
llvm-svn: 374711
2019-10-13 09:46:56 +00:00
Csaba Dabis adac533d95 [clang-tidy] bugprone-not-null-terminated-result: Sphinx adjustments 2
llvm-svn: 374710
2019-10-13 08:49:43 +00:00
Csaba Dabis 2e77fcb05b [clang-tidy] bugprone-not-null-terminated-result: Sphinx adjustments
llvm-svn: 374709
2019-10-13 08:41:24 +00:00
Csaba Dabis 82f8f8b44c [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length
Summary:
New checker called bugprone-not-null-terminated-result. This checker finds
function calls where it is possible to cause a not null-terminated result.
Usually the proper length of a string is `strlen(src) + 1` or equal length
of this expression, because the null terminator needs an extra space.
Without the null terminator it can result in undefined behaviour when the
string is read.

The following and their respective `wchar_t` based functions are checked:

`memcpy`, `memcpy_s`, `memchr`, `memmove`, `memmove_s`, `strerror_s`,
`strncmp`, `strxfrm`

The following is a real-world example where the programmer forgot to
increase the passed third argument, which is `size_t length`.
That is why the length of the allocated memory is not enough to hold the
null terminator.

```
    static char *stringCpy(const std::string &str) {
      char *result = reinterpret_cast<char *>(malloc(str.size()));
      memcpy(result, str.data(), str.size());
      return result;
    }
```

In addition to issuing warnings, fix-it rewrites all the necessary code.
It also tries to adjust the capacity of the destination array:

```
    static char *stringCpy(const std::string &str) {
      char *result = reinterpret_cast<char *>(malloc(str.size() + 1));
      strcpy(result, str.data());
      return result;
    }
```

Note: It cannot guarantee to rewrite every of the path-sensitive memory
allocations.

Reviewed By: JonasToth, aaron.ballman, whisperity, alexfh

Tags: #clang-tools-extra, #clang

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

llvm-svn: 374707
2019-10-13 08:28:27 +00:00
Dmitri Gribenko aa87b081cd Updated add_new_check.py to create checker tests in the new directory
llvm-svn: 374551
2019-10-11 13:46:55 +00:00
Dmitri Gribenko d103e2d267 [ClangTidy] Separate tests for infrastructure and checkers, fixup
Renamed a file that I missed in r374540.

llvm-svn: 374549
2019-10-11 13:16:49 +00:00
Dmitri Gribenko 885c559369 [ClangTidy] Separate tests for infrastructure and checkers
Summary:
This change moves tests for checkers and infrastructure into separate
directories, making it easier to find infrastructure tests. Tests for
checkers are already easy to find because they are named after the
checker. Tests for infrastructure were difficult to find because they
were outnumbered by tests for checkers. Now they are in a separate
directory.

Reviewers: jfb, jdoerfert, lebedev.ri

Subscribers: srhines, nemanjai, aheejin, kbarton, christof, mgrang, arphaman, jfb, lebedev.ri, cfe-commits

Tags: #clang

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

llvm-svn: 374540
2019-10-11 12:05:42 +00:00
Jordan Rose 7b5c879243 Get ClangdXPC.framework building (barely) with CMake's Xcode generator
The output directories for CMake's Xcode project generator are
specific to the configuration, and so looking in
CMAKE_LIBRARY_OUTPUT_DIRECTORY isn't going to work. Fortunately, CMake
already provides generator expressions to find the output of a given
target.

I call this "barely" building because the built framework isn't going
to respect the configuration; that is, I can't have both Debug and
RelWithDebInfo variants of ClangdXPC.framework at the same time like I
can with normal library or executable targets. To do that we'd have to
put the framework in a configuration-specific output directory or use
CMake's native support for frameworks instead.

https://reviews.llvm.org/D68846

llvm-svn: 374494
2019-10-11 01:23:56 +00:00
Yitzhak Mandelbaum fbdf83521b [libTooling] Move Transformer files to their own directory/library.
Summary:
The Transformer library has been growing inside of
lib/Tooling/Refactoring. However, it's not really related to anything else in
that directory. This revision moves all Transformer-related files into their own
include & lib directories.  A followup revision will (temporarily) add
forwarding headers to help any users migrate their code to the new location.

Reviewers: gribozavr

Subscribers: mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 374271
2019-10-10 02:34:47 +00:00
Kadir Cetinkaya 9a3a87d189 [clangd] Make sure ReplyCallbacks are destroyed before RequestCancelersMutex
Summary:
After rL374163, replycallbacks might have a cancellable context, which
will try to access RequestCancellers on destruction. See
http://45.33.8.238/mac/1245/step_7.txt for a sample failure.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 374168
2019-10-09 13:59:31 +00:00
Kadir Cetinkaya 1bb91093e7 [clangd] Propagate context into reply handlers
llvm-svn: 374163
2019-10-09 12:48:41 +00:00
Nico Weber 8cb804a3c9 Try to get readability-deleted-default.cpp to pass on Windows.
In MS compatibility mode, "extern inline void g()" is not a redundant
declaration for "inline void g()", because of redeclForcesDefMSVC()
(see PR19264, r205485).

To fix, run the test with -fms-compatiblity forced on and off
and explicit check for the differing behavior for extern inline.

Final bit of PR43593.

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

llvm-svn: 374103
2019-10-08 19:14:34 +00:00
Ilya Biryukov 1b36caf45e [clangd] Disable expand auto on decltype(auto)
Summary: Applying it produces incorrect code at the moment.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 374048
2019-10-08 14:03:45 +00:00
Kadir Cetinkaya 3c4646194e [clangd] Bump timeouts in speculative completion tests
llvm-svn: 374047
2019-10-08 13:54:03 +00:00
Nico Weber 0db7b6a44c Attempt to fix a few clang-tidy tests on Windows, see PR43593.
llvm-svn: 373951
2019-10-07 19:54:19 +00:00
Nico Weber 29f7e17cb8 Try to get clangd tests passing on Windows.
Part of PR43592. See also r328645.

llvm-svn: 373932
2019-10-07 17:55:05 +00:00
Kadir Cetinkaya de8599776b [clangd] Fix raciness in code completion tests
Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 373924
2019-10-07 17:12:18 +00:00
Haojian Wu 77c97002dc [clangd] Catch an unchecked "Expected<T>" in HeaderSourceSwitch.
Summary: Also fixes a potential user-after-scope issue of "Path".

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 373897
2019-10-07 11:37:25 +00:00
Sam McCall 368e0f3757 [clangd] If an undocumented definition exists, don't accept documentation from other forward decls.
Summary:
This fixes cases like:
  foo.h
    class Undocumented{}
  bar.h
    // break an include cycle. we should refactor this!
    class Undocumented;
Where the comment doesn't describe the class.

Note that a forward decl that is *visible to the definition* will still have
its doc comment used, by SymbolCollector: Merge isn't involved here.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 373892
2019-10-07 10:53:56 +00:00
Haojian Wu 2fa81d201f [clangd] Collect missing macro references.
Summary: Semantic highlghting is missing a few macro references.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 373889
2019-10-07 10:10:31 +00:00
Michal Gorny 0820041e1d [clang-tools-extra] [cmake] Link against libclang-cpp whenever possible
Use clang_target_link_libraries() in order to support linking against
libclang-cpp instead of static libraries.

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

llvm-svn: 373786
2019-10-04 20:30:02 +00:00
Haojian Wu bc4e43e9c1 [clangd] update the package-lock.json.
llvm-svn: 373739
2019-10-04 12:35:16 +00:00
Ilya Biryukov 8613e90ba7 [CodeComplete] Ensure object is the same in compareOverloads()
Summary:
This fixes a regression that led to size() not being available in clangd
when completing 'deque().^' and using libc++.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 373710
2019-10-04 08:10:27 +00:00
Michal Gorny cb46b69e3e [clang-tools-extra] [cmake] Use add_clang_tool() to install tools
Replace add_clang_executable() calls with add_clang_tool() that takes
care of creating correct, distribution-friendly install target.  While
at it, remove redundant install calls.

This change also causes clang-move and pp-trace to be installed.

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

llvm-svn: 373694
2019-10-04 05:40:29 +00:00
Aaron Ballman b879fd05bd Add the misc-init-local-variables check.
This checks finds all primitive type local variables (integers, doubles, pointers) that are declared without an initial value. Includes fixit functionality to initialize said variables with a default value. This is zero for most types and NaN for floating point types. The use of NaNs is copied from the D programming language.

Patch by Jussi Pakkanen.

llvm-svn: 373489
2019-10-02 17:18:57 +00:00
Shaurya Gupta a24762e773 [Clangd] ExtractFunction: Don't extract body of enclosing function.
Summary:
This patch disable extraction of the body of the enclosing function.
`void f() [[{}]]`

Extracting this CompoundStmt would leave the enclosing function without
a body.

Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 373472
2019-10-02 13:52:14 +00:00
Shaurya Gupta f175807954 [Clangd] Ensure children are always RootStmt in ExtractFunction (Fixes #153)
Summary:
We weren't always checking if children are RootStmts in ExtractFunction.

For `void f([[int a]]);`, the ParmVarDecl appeared as a RootStmt since
we didn't perform the check and ended up being casted to a (null) Stmt.

Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 373471
2019-10-02 13:51:06 +00:00
Haojian Wu d44fc23abd [clangd] Bail out early if we are sure that the symbol is used outside of the file.
Summary:
This would reduce the false positive when the static index is in an
unavailable state, e.g. background index is not finished.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 373444
2019-10-02 10:46:37 +00:00
Sam McCall 20c5fbb1af [clangd] SelectionTree should mark a node as fully-selected if the only claimed tokens were early-claimed.
Summary:
Previously they would be marked as partially-selected based on the early claim,
and never updated as no more tokens were claimed.
This affects simple VarDecls like "int x".

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 373442
2019-10-02 10:01:53 +00:00
Sam McCall 442be72777 [clang-tidy] Fix typo in r373428
llvm-svn: 373436
2019-10-02 09:16:48 +00:00
Kadir Cetinkaya e95e516596 [clangd] Always send file URIs to editors
Summary:
Editors only know about file URIs, make sure we do not use any custom
schemes while sending edits.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 373435
2019-10-02 09:12:01 +00:00
Adam Balogh 1c57143742 [clang-tidy] Fix for commits rL372706 and rL372711
The patch committed was not the accepted version but the
previous one. This commit fixes this issue.

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

llvm-svn: 373428
2019-10-02 07:14:11 +00:00
Stephane Moore e4acb971f1 [clang-tidy] Rename objc-avoid-spinlock check to darwin-avoid-spinlock
Summary:
OSSpinLock* are Apple/Darwin functions, but were previously located with ObjC checks as those were most closely tied to Apple platforms before.

Now that there's a specific Darwin module, relocating the check there.

This change was prepared by running rename_check.py.

Contributed By: mwyman

Reviewers: stephanemoore, dmaclach

Reviewed By: stephanemoore

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

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

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

llvm-svn: 373392
2019-10-01 21:18:40 +00:00
Haojian Wu 9f2bf666bc [clangd] Implement getBeginning for overloaded operators.
Summary:
This will fix some bugs where navigation doesn't work on cases like
`std::cout <^< "hello"`.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 373323
2019-10-01 11:03:56 +00:00
Haojian Wu d6d5eddcdb [clangd] Use the index-based API to do the header-source switch.
Summary:
If the file heuristic fails, we try to use the index&AST to do the
header/source inference.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 373320
2019-10-01 10:21:15 +00:00
Ilya Biryukov 1d32da8249 [clangd] Handle template arguments in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 373318
2019-10-01 10:02:23 +00:00
Ilya Biryukov a160a0ba53 [clangd] Handle OverloadExpr in targetDecl
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 373305
2019-10-01 07:27:55 +00:00
Dmitri Gribenko d1337ec22d [clang-tidy] Fix module registry name and description for Darwin clang-tidy module.
Summary: When creating the module, must have copy-pasted from the misc module, and forgotten to update the name/description of the module in the registry.

Reviewers: stephanemoore, benhamilton, gribozavr

Reviewed By: gribozavr

Subscribers: xazax.hun, cfe-commits

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

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

llvm-svn: 373304
2019-10-01 07:17:26 +00:00
Haojian Wu fdbe5b4b6f [clangd] Implement a smart version of HeaderSource switch.
Summary:
This patch implements another version header-source switch by incorporating the
AST and index, it will be used:
  - to improve the current header-source switch feature (layer with the
    existing file heuristic);
  - by the incoming define-outline code action;

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 373197
2019-09-30 10:48:02 +00:00
Ilya Biryukov 4ae2381430 [clangd] Fix template type aliases in findExplicitReference
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 373104
2019-09-27 17:55:46 +00:00
Nico Weber d69fa737ff clang-tidy: Don't repeat list of all checks in three places.
Instead, put all checks in a cmake variable and reference this.

Also, make clangd use the the ClangTidyForceLinker.h header instead
of duplicating the list of modules -- the duplicate copy was missing
the new "darwin" checker added in r373065.

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

llvm-svn: 373082
2019-09-27 12:56:14 +00:00
Haojian Wu 7e317cab73 [clangd] Remove an unrelated comment, NFC.
llvm-svn: 373079
2019-09-27 12:32:19 +00:00
Dmitri Gribenko 6328f948ad Fixed indentation in a ClangTidy test
llvm-svn: 373068
2019-09-27 10:58:10 +00:00
Ilya Biryukov c383509ce6 [clangd] Handle type template parameters in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 373067
2019-09-27 10:55:53 +00:00
Dmitri Gribenko 69f9f20fc5 Moved -fblocks from an individual test to check_clang_tidy.py
This way, all tests will benefit from it and will not have to worry
about setting up language options properly.

llvm-svn: 373066
2019-09-27 10:54:28 +00:00
Dmitri Gribenko 405c3a6be1 [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage.
Summary:
Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check.

The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible.

This is a re-land of https://reviews.llvm.org/D67567

Reviewers: thakis, gribozavr, stephanemoore

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, jkorous, arphaman, kadircet, usaxena95

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

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

llvm-svn: 373065
2019-09-27 10:49:12 +00:00
Ilya Biryukov 2774457b2a [clangd] Support OverloadExpr in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 373057
2019-09-27 09:39:10 +00:00
Dmitri Gribenko 847f4d3f6d Revert "[clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage"
This reverts commit r373028, because the new test fails on Linux.

llvm-svn: 373032
2019-09-26 23:28:31 +00:00
Stephane Moore aa7d6544c1 [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage
Summary:
Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check.

The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible.

Contributed By: mwyman

Reviewers: benhamilton, hokein, stephanemoore, aaron.ballman, gribozavr

Reviewed By: stephanemoore, gribozavr

Subscribers: jkorous, arphaman, kadircet, usaxena95, NoQ, xazax.hun, lebedev.ri, mgorny, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 373028
2019-09-26 23:04:59 +00:00
Haojian Wu 1822087fac [clangd] Bump vscode-clangd v0.0.18
CHANGELOG:
- enable semantic highlighting by default
- upgrade the LSP dependencies to pickup the incoming LSP v3.15.0

llvm-svn: 372981
2019-09-26 14:11:23 +00:00
Haojian Wu 2745e5ea4a [clangd][vscode] Add npm helper commands to package/release the extension.
Summary: Help to fix https://github.com/clangd/clangd/issues/159.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 372980
2019-09-26 14:04:52 +00:00
Dmitri Gribenko bb7a9dcd42 Return results by value from ClangTidyCheckFactories::createChecks
llvm-svn: 372979
2019-09-26 13:55:01 +00:00
Dmitri Gribenko 5338ffcfa1 Use std::unique_ptr in ClangTidyCheckFactories
I had to explicitly define some destructors that could only be defined
in the corresponding .cpp files.

llvm-svn: 372978
2019-09-26 13:47:29 +00:00
Haojian Wu e69f12d6cf [clangd][vscode] Update vscode lsp dependencies to pickup the new changes in LSP v3.15.0.
Summary: This would enable the newly-added semantic selection feature in vscode.

Reviewers: usaxena95

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

Tags: #clang

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

llvm-svn: 372970
2019-09-26 11:35:34 +00:00
Haojian Wu 0f61f9fca8 [clangd][vscode] Turn on the semantic highlighting by default.
Summary:
We have turned on the flag manually and used it for a while, and don't see any
major issues, let's enable it by default.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 372969
2019-09-26 11:34:11 +00:00
Haojian Wu 0d808e5064 [clang-tidy] Make llvm-header-guard work on llvm git monorepo
Reviewers: gribozavr

Reviewed By: gribozavr

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

Tags: #clang

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

llvm-svn: 372953
2019-09-26 09:56:37 +00:00
Kadir Cetinkaya bbb0442bbf [clangd] Add a helper for extracting nonlocal decls in a FunctionDecl
Summary:
To be used by define-inline code action to determine whether the
function/method body will still be valid in another context.

Traverses clang-ast to find all decl nodes under the function decl and stores
the non-local ones.

Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 372948
2019-09-26 07:27:43 +00:00
Kadir Cetinkaya 007e4fe901 [clangd] Change constness of parameters to findExplicitRefs
Summary:
Recursive AST requires non-const ast nodes, but it doesn't really
mutate them. In addition to that, in clangd we mostly have const ast nodes. So
it makes sense to move the const_cast into callee rather than having it at every
caller in the future.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 372888
2019-09-25 15:44:26 +00:00
Kadir Cetinkaya 194117f04b [clangd] Fix parseNamespaceEvents to parse the last token
Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 372875
2019-09-25 14:12:05 +00:00
Haojian Wu c00627f4dc [clangd] Add missing header guard, NFC.
llvm-svn: 372860
2019-09-25 12:54:53 +00:00
Ilya Biryukov f96d2e1754 [clangd] A helper to find explicit references and their names
Summary:
Allows to simplify pending code tweaks:
  - the upcoming DefineInline tweak (D66647)
  - remove using declaration (D56612)
  - qualify name under cursor (D56610)

Another potential future application is simplifying semantic highlighting.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 372859
2019-09-25 12:40:22 +00:00
Haojian Wu e259a5fd0d [clangd] Move the existing heder-source-switch implemenation out of clangdServer.
Summary: This is a NFC change.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 372841
2019-09-25 10:30:22 +00:00
Haojian Wu f8ecb24822 [clangd] Fix the stale documentation about background indexing.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 372825
2019-09-25 08:26:32 +00:00
Utkarsh Saxena 55925da4c9 [clangd] Add semantic selection to ClangdLSPServer.
Summary:
This adds semantic selection to the LSP Server.
Adds support for serialization of input request and the output reply.
Also adds regression tests for the feature.

Currently we do not support multi cursor.The LSP Server only accepts single position in the request as opposed to many position in the spec.

Spec:
https://github.com/microsoft/language-server-protocol/blob/dbaeumer/3.15/specification.md#textDocument_selectionRange

Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 372753
2019-09-24 13:38:33 +00:00
Haojian Wu 3a415c20ad [clangd] Save an unnecessary copy, NFC.
llvm-svn: 372752
2019-09-24 13:25:38 +00:00
Haojian Wu 7e3c74bc63 [clangd] Collect macros in the preamble region of the main file
Summary:
- store all macro references in the ParsedAST;
- unify the two variants of CollectMainFileMacros;

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 372725
2019-09-24 11:14:06 +00:00
Fangrui Song a0d79d846f [clang-tidy][test] Add -fexceptions to bugprone-infinite-loop.test
This fixes llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast.

-fexceptions is disabled by default on XCore and PS4.

llvm-svn: 372715
2019-09-24 09:55:35 +00:00
Mikael Holmen e07376a320 [modularize] Fix compilation warning after r372681
In r372681 lang_cxx_11 and lang_cxx_14 were added to LanguageIDs
but they were not handled in the switch in VisitLinkageSpecDecl in
Modularize.cpp so at clang 8 complained with

/data/repo/master/clang-tools-extra/modularize/Modularize.cpp:583:13: error: enumeration values 'lang_cxx_11' and 'lang_cxx_14' not handled in switch [-Werror,-Wswitch]
    switch (D->getLanguage()) {
            ^
1 error generated.

With this patch we now treat lang_cxx, lang_cxx_11 and lang_cxx_14 the
same way in the switch in VisitLinkageSpecDecl.

llvm-svn: 372714
2019-09-24 09:44:55 +00:00
Fangrui Song 168b3fb38b [clang-tidy] Add bugprone-infinite-loop.rst from D64736 to fix buildbot
llvm-svn: 372711
2019-09-24 09:32:00 +00:00
Fangrui Song 3352bdfaab [clang-tidy] Add missing InfiniteLoopCheck.h, InfiniteLoopCheck.cpp and test from D64736
llvm-svn: 372706
2019-09-24 09:06:31 +00:00
Simon Pilgrim cb3d969453 Revert rL372693 : [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops
Finding infinite loops is well-known to be impossible (halting problem).
However, it is possible to detect some obvious infinite loops, for example,
if the loop condition is not changed. Detecting such loops is beneficial
since the tests will hang on programs containing infinite loops so
testing-time detection may be costly in large systems. Obvious cases are
where the programmer forgets to increment/decrement the counter or
increments/decrements the wrong variable.

Differential Revision: https://reviews.llvm.org/D64736
-------
Broke some buildbots "No SOURCES given to target: obj.clangTidyBugproneModule"

llvm-svn: 372704
2019-09-24 08:56:44 +00:00
Adam Balogh 54b78f3bb6 [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops
Finding infinite loops is well-known to be impossible (halting problem).
However, it is possible to detect some obvious infinite loops, for example,
if the loop condition is not changed. Detecting such loops is beneficial
since the tests will hang on programs containing infinite loops so
testing-time detection may be costly in large systems. Obvious cases are
where the programmer forgets to increment/decrement the counter or
increments/decrements the wrong variable.

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

llvm-svn: 372693
2019-09-24 07:43:26 +00:00
Shaurya Gupta 7e56dd0229 [Clang-doc] NFC: Fixed link to llvm bugs in documentation
llvm-svn: 372627
2019-09-23 16:55:13 +00:00
Haojian Wu b70323e5d3 [clangd] Simplify the callside of URI::resolve, NFC.
Summary:
- Add a overrloded URI::resolve, which accepts a string URI;
- also fixed some callside that don't check the error;

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 372617
2019-09-23 14:39:37 +00:00
Dmitri Gribenko 7964e89409 Added a test for agreement between paths used in ClangTidy's diagnostics and header filter
This test would have been broken by r372388.

llvm-svn: 372607
2019-09-23 13:44:42 +00:00
Dmitri Gribenko ddc9a06e95 Revert "[clang-tidy] Fix relative path in header-filter."
This reverts commit r372388. It made '-header-filter' inconsistent with
paths printed in diagnostics.

llvm-svn: 372601
2019-09-23 13:06:25 +00:00
Dmitri Gribenko 04b34a20b9 Removed an incorred namespace-end comment
llvm-svn: 372593
2019-09-23 12:07:10 +00:00
Stephane Moore 2f6a52816f [clang-tidy] Add check for classes missing -hash ⚠️
Summary:
Apple documentation states that:
"If two objects are equal, they must have the same hash value. This last
point is particularly important if you define isEqual: in a subclass and
intend to put instances of that subclass into a collection. Make sure
you also define hash in your subclass."
https://developer.apple.com/documentation/objectivec/1418956-nsobject/1418795-isequal?language=objc

In many or all versions of libobjc, -[NSObject isEqual:] is a pointer
equality check and -[NSObject hash] returns the messaged object's
pointer. A relatively common form of developer error is for a developer to
override -isEqual: in a subclass without overriding -hash to ensure that
hashes are equal for objects that are equal.

It is assumed that an override of -isEqual: is a strong signal for
changing the object's equality operator to something other than pointer
equality which implies that a missing override of -hash could result in
distinct objects being equal but having distinct hashes because they are
independent instances. This added check flags classes that override
-isEqual: but inherit NSObject's implementation of -hash to warn of the
potential for unexpected behavior.

The proper implementation of -hash is the responsibility of the
developer and the check will only verify that the developer made an
effort to properly implement -hash. Developers can set up unit tests
to verify that their implementation of -hash is appropriate.

Test Notes:
Ran check-clang-tools.

Reviewers: aaron.ballman, benhamilton

Reviewed By: aaron.ballman

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

Tags: #clang

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

llvm-svn: 372445
2019-09-21 01:22:22 +00:00
Dmitri Gribenko 4a13c828f6 [clang-tidy] Fix relative path in header-filter.
Summary:
Clang-tidy supports output diagnostics from header files if user
specifies --header-filter. But it can't handle relative path well.
For example, the folder structure of a project is:

```
// a.h is in /src/a/a.h

// b.h is in /src/b/b.h
...

// c.cpp is in /src/c.cpp

```

Now, we set --header-filter as --header-filter=/a/. That means we only
want to check header files under /src/a/ path, and ignore header files
uder /src/b/ path, but in current implementation, clang-tidy will check
/src/b/b.h also, because the name of b.h used in clang-tidy is
/src/a/../b/b.h.

This change tries to fix this issue.

Reviewers: alexfh, hokein, aaron.ballman, gribozavr

Reviewed By: gribozavr

Subscribers: MyDeveloperDay, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Patch by Yubo Xie.

llvm-svn: 372388
2019-09-20 13:19:32 +00:00
Yitzhak Mandelbaum 57990b4be0 [clang-tidy] Fix bugprone-argument-comment-check to correctly ignore implicit constructors.
Summary:
After revision 370919, this check incorrectly flags certain cases of implicit
constructors. Specifically, if an argument is annotated with an
argument-comment and the argument expression triggers an implicit constructor,
then the argument comment is associated with argument of the implicit
constructor.

However, this only happens when the constructor has more than one argument.
This revision fixes the check for implicit constructors and adds a regression
test for this case.

Note: r370919 didn't cause this bug, it simply uncovered it by fixing another
bug that was masking the behavior.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 372317
2019-09-19 13:12:05 +00:00
Haojian Wu d94c7bf06e [clang-tidy] Fix a potential infinite loop in readability-isolate-declaration check.
Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 372206
2019-09-18 09:21:35 +00:00
Benjamin Kramer 957a6c6bed [clangd] Fix another TSAN issue
llvm-svn: 372128
2019-09-17 14:56:11 +00:00
Utkarsh Saxena 79d19bdf81 Add SemanticRanges to Clangd server.
Summary:
Adds Semantic Ranges capabilities to Clangd server.
Also adds tests for running it via clangd server.

This differs from the LSP spec as the spec needs this to be evaluated on multiple 'pos' and the expected output is an list of list of semantic ranges.
This is majorly for multi cursor and assuming this is a rare thing, we don't want to optimize make things complicated just for this.
This should be done in the LSP level by queueing one request per 'pos' in the input.

LSP Spec:
https://github.com/microsoft/language-server-protocol/blob/dbaeumer/3.15/specification.md#textDocument_selectionRange

Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 372102
2019-09-17 10:28:05 +00:00
Ilya Biryukov b6c05b2a52 [clangd] Remove stale comment. NFC
llvm-svn: 372074
2019-09-17 06:49:50 +00:00
Jian Cai 9d2066af8d [clang-tidy] add checks to bugprone-posix-return
This check now also checks if any calls to pthread_* functions expect negative return values. These functions return either 0 on success or an errno on failure, which is positive only.

llvm-svn: 372037
2019-09-16 21:43:56 +00:00
Ilya Biryukov 685d8a95c5 [clangd] Simplify semantic highlighting visitor
Summary:
- Functions to compute highlighting kinds for things are separated from
  the ones that add highlighting tokens.
  This keeps each of them more focused on what they're doing: getting
  locations and figuring out the kind of the entity, correspondingly.

- Less special cases in visitor for various nodes.

This change is an NFC.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 372008
2019-09-16 16:16:03 +00:00
Haojian Wu 91154d6516 [clangd][vscode] update the development doc.
llvm-svn: 371986
2019-09-16 14:03:06 +00:00
Haojian Wu 72b9c4f3bc [clangd] Bump vscode-clangd v0.0.17
CHANGELOG:
- added semantic highlighting support (under the clangd.semanticHighlighting
  flag);
- better error message when clangd fails to execute refactoring-like
  actions;
- improved the readme doc;

llvm-svn: 371980
2019-09-16 12:51:07 +00:00
Utkarsh Saxena 73c09eb734 Implement semantic selections.
Summary:
For a given cursor position, it returns ranges that are interesting to the user.
Currently the semantic ranges correspond to the nodes of the syntax trees.

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

Tags: #clang

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

llvm-svn: 371976
2019-09-16 11:29:35 +00:00
Haojian Wu af28bb6502 [clangd] Fix a crash when renaming operator.
Summary:
The renamelib uses a tricky way to calculate the end location by relying
on decl name, this is incorrect for the overloaded operator (the name is
"operator++" instead of "++"), which will cause out-of-file offset.

We also disable renaming operator symbol, this case is tricky, and
renamelib doesnt handle it properly.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 371971
2019-09-16 10:16:56 +00:00
Haojian Wu 3716547c5f Fix the rst doc, unbreak buildbot.
llvm-svn: 371968
2019-09-16 09:46:53 +00:00
Haojian Wu ad7a7cea89 [clang-tidy] performance-inefficient-vector-operation: Support proto repeated field
Summary:
Finds calls that add element to protobuf repeated field in a loop
without calling Reserve() before the loop. Calling Reserve() first can avoid
unnecessary memory reallocations.

A new option EnableProto is added to guard this feature.

Patch by Cong Liu!

Reviewers: gribozavr, alexfh, hokein, aaron.ballman

Reviewed By: hokein

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

Tags: #clang, #clang-tools-extra

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

llvm-svn: 371963
2019-09-16 08:54:10 +00:00
Jan Korous f69c91780f [Support] Add overload writeFileAtomically(std::function Writer)
Differential Revision: https://reviews.llvm.org/D67424

llvm-svn: 371890
2019-09-13 20:08:27 +00:00
Tim Shen 75e963ec6f [ClangTidy] Adjust the name getCheckName to getCheckerName due to API change.
llvm-svn: 371773
2019-09-12 21:18:44 +00:00
Heejin Ahn 4f0245fd98 [clang-tidy] Fix build with -DBUILD_SHARED_LIB=ON
Summary: This fixes build failures with `-DBUILD_SHARED_LIB=ON` after D67419.

Reviewers: NoQ

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 371706
2019-09-12 03:10:57 +00:00
Artem Dergachev f0bb45fac3 [analyzer] NFC: Move PathDiagnostic classes to libAnalysis.
At this point the PathDiagnostic, PathDiagnosticLocation, PathDiagnosticPiece
structures no longer rely on anything specific to Static Analyzer, so we can
move them out of it for everybody to use.

PathDiagnosticConsumers are still to be handed off.

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

llvm-svn: 371661
2019-09-11 20:54:27 +00:00
Haojian Wu 8dd26fd84e [clangd] Collect location of macro definition in the ParsedAST
allows semantic hightlighting macro definition

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

Tags: #clang

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

llvm-svn: 371504
2019-09-10 10:10:36 +00:00
Haojian Wu 2fa2d45963 [clangd] some tweaks on the vscode readme, NFC
llvm-svn: 371495
2019-09-10 08:07:12 +00:00
Ilya Biryukov 6d7fba6aae [clangd] Attempt to fix failing Windows buildbots.
The assertion is failing on Windows, probably because path separator is different.

For the failure see:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/28072/steps/test/logs/stdio

llvm-svn: 371422
2019-09-09 17:03:49 +00:00
Ilya Biryukov 8b76709bac [clangd] Use pre-populated mappings for standard symbols
Summary:
This takes ~5% of time when running clangd unit tests.

To achieve this, move mapping of system includes out of CanonicalIncludes
and into a separate class

Reviewers: sammccall, hokein

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 371408
2019-09-09 15:32:51 +00:00
Ilya Biryukov e237520a8f [clangd] Add a new highlighting kind for typedefs
Summary:
We still attempt to highlight them as underlying types, but fallback to
the generic 'typedef' highlighting kind if the underlying type is too
complicated.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 371402
2019-09-09 14:33:10 +00:00
Yitzhak Mandelbaum f9ce864558 [clang-tidy] Fix bug in bugprone-use-after-move check
Summary:
The bugprone-use-after-move check exhibits false positives for certain uses of
the C++17 if/switch init statements. These false positives are caused by a bug
in the ExprSequence calculations.

This revision adds tests for the false positives and fixes the corresponding
sequence calculation.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 371396
2019-09-09 12:59:14 +00:00
Fangrui Song ff354de294 [clang-doc] sys::fs::F_None -> OF_None. NFC
F_None, F_Text and F_Append are kept for compatibility.

llvm-svn: 371394
2019-09-09 12:42:10 +00:00
Kadir Cetinkaya 5b270932cc [clangd] Support multifile edits as output of Tweaks
Summary:
First patch for propogating multifile changes from tweak outputs to LSP
WorkspaceEdits.

Uses SM to convert tooling::Replacements to TextEdits.
Errors out if there are any inconsistencies between the draft version and the
version generated the edits.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 371392
2019-09-09 12:28:44 +00:00
Sam McCall 7c5697c8b2 [clangd] Update clangd-vscode docs to be more user-focused.
Summary: Relegate "updating the extension" docs to a separate file.

Reviewers: hokein, kadircet

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

Tags: #clang

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

llvm-svn: 371390
2019-09-09 11:34:01 +00:00
Ilya Biryukov d5588293a8 [clangd] Highlight typedefs to template parameters as template parameters
Summary:
Template parameters were handled outside `addType`, this led to lack of highlightings for typedefs
to template types.

This was never desirable, we want to highlight our typedefs as their underlying type.
Note that typedefs to more complicated types, like pointers and references are still not highlighted.

Original patch by Johan Vikström.

Reviewers: hokein, jvikstrom

Reviewed By: hokein

Subscribers: nridge, javed.absar, kristof.beyls, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 371379
2019-09-09 09:37:17 +00:00
Ilya Biryukov 63d5d16237 [clangd] Replace HighlightingKind::NumKinds with LastKind. NFC
Summary:
The latter simplifies the client code by avoiding the need to handle it
as a separate case statement.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 371375
2019-09-09 08:57:17 +00:00
Ilya Biryukov ad3841fcae [clangd] Improve output of semantic highlighting tests in case of failures
Summary:
Instead of matching lists of highlightings, we annotate input code with
resulting highlightings and diff it against the expected annotated input.

In case of failures, this produces much nicer output in form of text-based
diffs.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 371373
2019-09-09 08:47:05 +00:00
Jan Korous 4b5542f29d [clang][Index][NFC] Put IndexingOptions to a separate header
llvm-svn: 371250
2019-09-06 20:08:32 +00:00
Haojian Wu 2ebd24cc13 [clangd] Use override keyword to override the base class method, NFC
llvm-svn: 371194
2019-09-06 10:24:39 +00:00
Ilya Biryukov 886382ff07 [clangd] Initialize int field to zero. NFC
To make sure we do not have uninitialized values and undefined behavior.

llvm-svn: 371081
2019-09-05 15:30:05 +00:00
Alexander Kornienko 30424e4268 [clang-tidy] Make most ArgumentCommentCheck options local, as they should be
llvm-svn: 371076
2019-09-05 14:48:31 +00:00
Alexander Kornienko 42443e50ce Add a bugprone-argument-comment option: IgnoreSingleArgument.
Summary:
Add bugprone-argument-comment option: IgnoreSingleArgument.
When true, the check will ignore the single argument.

Sometimes, it's not necessary to add comment to single argument.
For example:

> std::string name("Yubo Xie");
> pScreen->SetWidth(1920);
> pScreen->SetHeight(1080);

This option can ignore such single argument in bugprone-argument-comment check.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang

Patch by Yubo Xie.

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

llvm-svn: 371075
2019-09-05 14:48:23 +00:00
Alexander Kornienko b6d9703050 [clang-tidy] Fix bugprone-argument-comment bug: negative literal number is not checked.
Summary:
For example:
```
void foo(int a);
foo(-2);
```
should be fixed as:
```
foo(/*a=*/-2);
```
This change tries to fix this issue.

Reviewers: alexfh, hokein, aaron.ballman

Reviewed By: alexfh, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Patch by Yubo Xie.

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

llvm-svn: 371072
2019-09-05 14:13:57 +00:00
Haojian Wu 32048464ee [clangd][vscode] Add a flag to enable semantic highlighting in clangd
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 371038
2019-09-05 09:26:03 +00:00
Haojian Wu 8db9e0e697 [clangd][vscode] Make SemanticHighlightingFeature more self-contained.
Summary:
so that we don't have too many usage from the client side (just a single
occurrance for register), this also aligns with how other builtin feature
being implemented in vscode.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 371036
2019-09-05 09:14:04 +00:00
Kadir Cetinkaya 4a16c29551 [clang-tidy] Fix definitions in headers check to respect qualifiers
Summary:
The check was generating a fix without taking qualifiers in return type
into account. This patch changes the insertion location to be before qualifers.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 371022
2019-09-05 08:11:21 +00:00
Alexander Kornienko 240a2e25c6 [clang-tidy] Fix bugprone-argument-comment bug if there are marcos.
Summary:
Fix bugprone-argument-comment bug if there are marcos.

For example:
```
void j(int a, int b, int c);
j(X(1), /*b=*/1, X(1));
```

clang-tidy can't recognize comment "/*b=*/". It suggests fix like this:
```
j(X(1), /*b=*//*b=*/1, X(1));
```

This change tries to fix this issue.

Reviewers: alexfh, hokein, aaron.ballman

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Patch by Yubo Xie.

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

llvm-svn: 370919
2019-09-04 16:19:32 +00:00
Ilya Biryukov 433927595d [Driver] Use shared singleton instance of DriverOptTable
Summary:
This significantly reduces the time required to run clangd tests, by
~10%.

Should also have an effect on other tests that run command-line parsing
multiple times inside a single invocation.

Reviewers: gribozavr, sammccall

Reviewed By: sammccall

Subscribers: kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370908
2019-09-04 14:26:28 +00:00
Kadir Cetinkaya f1b3cd6c90 [clangd] Add TUScheduler.h to CodeComplete.cpp to unbreak builds
llvm-svn: 370895
2019-09-04 13:04:34 +00:00
Sam McCall 3d79fd6fcc [clangd] Fix SelectionTree behavior on implicit 'this'
llvm-svn: 370884
2019-09-04 12:15:20 +00:00
Sam McCall b2a984c0a8 [clangd] Remove macro-expansion-location from getBeginningOfIdentifier. Inline into relevant callsites. NFC
llvm-svn: 370869
2019-09-04 10:15:27 +00:00
Sam McCall 2ae9da2639 [clangd] Remove obsolete includes. NFC
llvm-svn: 370865
2019-09-04 10:01:05 +00:00
Sam McCall 4ca718561f [clangd] Move threading helper to more appropriate header. NFC
llvm-svn: 370864
2019-09-04 09:53:24 +00:00
Sam McCall 915f9785e0 [clangd] Rename ClangdUnit.h -> ParsedAST.h. NFC
This much better reflects what is (now) in this header.
Maybe a rename to ParsedTU would be an improvement, but that's a much
more invasive change and life is too short.

ClangdUnit is dead, long live ClangdUnitTests!

llvm-svn: 370862
2019-09-04 09:46:06 +00:00
Sam McCall cf3a585fff [clangd] Split Preamble.h out of ClangdUnit.h. NFC
Summary:
Add comment describing use of preamble in clangd.
Remove deps on ClangdUnit.h where possible.

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

Tags: #clang

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

llvm-svn: 370843
2019-09-04 07:35:00 +00:00
Sam McCall 19cefc2878 [clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop dependencies on ClangdUnit from some headers. NFC
llvm-svn: 370768
2019-09-03 15:34:47 +00:00
Michael Liao de52403843 [clangd] Remove redundant semi-colon.
llvm-svn: 370763
2019-09-03 15:02:46 +00:00
Haojian Wu 67853ac4e0 [clang-tidy] Fix a false positive in unused-using-decl check
The previous matcher "hasAnyTemplateArgument(templateArgument())" only
matches the first template argument, but the check wants to iterate all
template arguments. This patch fixes this.

Also some refactorings in this patch (to make the code reusable).

llvm-svn: 370760
2019-09-03 14:13:00 +00:00
Sam McCall 97e5de522e [clangd] Decouple macro/decl-under-cursor finding. Don't pretend there can be multiple macros. NFC.
llvm-svn: 370759
2019-09-03 14:12:48 +00:00
Ilya Biryukov 72379548eb [clangd] Fix a data race in test code
Found by TSan, thanks bkramer for pointing this out.

llvm-svn: 370758
2019-09-03 13:56:03 +00:00
Sam McCall 80195e7d1c [clangd] Wrong attribute on debug function in r370746
llvm-svn: 370757
2019-09-03 13:54:27 +00:00
Simon Pilgrim 54b989cf98 Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 370750
2019-09-03 13:05:13 +00:00
Sam McCall 489cc589c5 [clangd] Add targetDecl(), which determines what declaration an AST node refers to.
Summary:
This is the first part of an effort to "unbundle" our libIndex use into separate
concerns (AST traversal, token<->node mapping, node<->decl mapping,
decl<->decl relationshipes).

Currently, clangd relies on libIndex to associate tokens, AST nodes, and decls.
This leads to rather convoluted implementations of e.g. hover and
extract-function, which are not naturally thought of as indexing applications.

The idea is that by decoupling different concerns, we make them easier
to use, test, and combine, and more efficient when only one part is needed.
There are some synergies between e.g. traversal and finding
relationships between decls, hopefully the benefits outweight these.

Reviewers: kadircet, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370746
2019-09-03 11:35:50 +00:00
Daniel Sanders 0cdb04c3cf Make add_new_check.py's insertion of registerCheck<> match the sort order
Summary:
Following on from review comments in D65919 about the ordering
of the registerCheck<> calls. Sort based on the check name which might
be on the line after the registerCheck<>

Reviewers: aaron.ballman

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

llvm-svn: 370527
2019-08-30 20:47:02 +00:00
Daniel Sanders 5b4f640499 [clang-tidy] Add llvm-prefer-register-over-unsigned to clang-tidy
Summary:
This clang-tidy check is looking for unsigned integer variables whose initializer
starts with an implicit cast from llvm::Register and changes the type of the
variable to llvm::Register (dropping the llvm:: where possible).

Reviewers: arsenm, bogner

Subscribers: jholewinski, MatzeB, qcolombet, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, wdng, nhaehnle, mgorny, sbc100, jgravelle-google, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, javed.absar, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, tpr, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, Jim, s.egerton, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 370512
2019-08-30 20:01:59 +00:00
Johan Vikstrom becbdc66dc [clangd] Add highlighting for macro expansions.
Summary: https://github.com/clangd/clangd/issues/134

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370482
2019-08-30 15:47:27 +00:00
Johan Vikstrom 268f45bfb8 [clangd] Added highlighting for structured bindings.
Summary: Structured bindings are in a BindingDecl. The decl the declRefExpr points to are the BindingDecls. So this adds an additional if statement in the addToken function to highlight them.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370473
2019-08-30 14:07:05 +00:00
Shaurya Gupta 3b08a61f7e [Clangd] ExtractFunction Added checks for broken control flow
Summary:
- Added checks for broken control flow
- Added unittests

Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 370455
2019-08-30 09:57:56 +00:00
Johan Vikstrom 84b4c4a495 [clangd] Collecting main file macro expansion locations in ParsedAST.
Summary: TokenBuffer does not collect macro expansions inside macro arguments which is needed for semantic higlighting. Therefore collects macro expansions in the main file in a PPCallback when building the ParsedAST instead.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370452
2019-08-30 09:33:27 +00:00
Dmitri Gribenko b22804b354 [Tooling] Migrated APIs that take ownership of objects to unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370451
2019-08-30 09:29:34 +00:00
Haojian Wu 0491d13ca5 [clangd] Add .vscode-test to .gitignore.
Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 370446
2019-08-30 09:06:18 +00:00
Nathan Ridge bd0f840f83 [clangd] Add distinct highlightings for static fields and methods
Reviewers: hokein, ilya-biryukov, jvikstrom

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 370429
2019-08-30 03:37:24 +00:00
Dmitri Gribenko 907452107d Changed FrontendActionFactory::create to return a std::unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370379
2019-08-29 16:38:36 +00:00
Shaurya Gupta 6a801454f1 [Clangd] NFC: Added fixme for checking for local/anonymous types for extracted parameters
llvm-svn: 370372
2019-08-29 15:11:59 +00:00
Haojian Wu 1a28e11892 [clangd] Update out-of-date links in readme, NFC.
llvm-svn: 370371
2019-08-29 14:57:32 +00:00
Kadir Cetinkaya 1c4cd49608 [clangd][NFC] Update background-index command line description
Summary:
We didn't change this in D64019 just in case we revert it back.
Deleting it now.

Reviewers: hokein, sammccall

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

Tags: #clang

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

llvm-svn: 370367
2019-08-29 14:38:02 +00:00
Simon Pilgrim 46b346ea7b Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 370343
2019-08-29 12:37:02 +00:00
Dmitri Gribenko 349ef2f2f9 [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored clients to use it instead of inventing their own solution
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370338
2019-08-29 11:47:34 +00:00
Dmitri Gribenko 8d32053f11 [Index] Stopped wrapping FrontendActions in libIndex and its users
Exposed a new function, createIndexingASTConsumer, that creates an
ASTConsumer. ASTConsumers compose well.

Removed wrapping functionality from createIndexingAction.

llvm-svn: 370337
2019-08-29 11:43:05 +00:00
Johan Vikstrom 4683eec2d3 [clangd] Update themeRuleMatcher when color theme changes in vscode extension.
Summary:
Add event listener that listens to configuration changes and reloads the ThemeRuleMatcher when the theme changes.

Right now it will not recolor the files, depends on the colorizer CL for that.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370305
2019-08-29 08:40:17 +00:00
Sam McCall d792204288 Reland "[clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC"
This reverts commit 3dcf55aa45bad800533b36b70a14ebeb2b84e219, and avoids
use of multiline raw strings in macro calls.

llvm-svn: 370304
2019-08-29 08:20:48 +00:00
Heejin Ahn 660efa596f [clangd] Fix ExtractFunction dependencies
Summary: Without these dependencies, builds with `-DBUILD_SHARED_LIBS=ON` fail.

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 370273
2019-08-28 23:17:38 +00:00
Sam McCall 7bb847478b Revert "[clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC"
This reverts commit 8f85685b5c, which
breaks on old gcc that have the macro + raw strings bug.

llvm-svn: 370262
2019-08-28 21:05:49 +00:00
Shaurya Gupta bf4773485e [Clangd] Initial version of ExtractFunction
Summary:
- Only works for extraction from free functions
- Basic analysis of the code being extracted.
- Extract to void function
- Bail out if extracting a return, continue or break.
- Doesn't hoist decls yet

Reviewers: kadircet, sammccall

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

Tags: #clang

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

llvm-svn: 370249
2019-08-28 19:34:17 +00:00
Sam McCall 8f85685b5c [clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC
llvm-svn: 370229
2019-08-28 16:41:22 +00:00
Haojian Wu 92e09b2f56 [clangd][vscode] Don't leak the resources
Summary: We miss a few places where we need to add them to the subscriptions.

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 370218
2019-08-28 15:09:04 +00:00
Johan Vikstrom 2dddf3e4ff [clangd] Cleans up the semantic highlighting resources if clangd stops.
Summary: Disposes of the vscode listeners when clangd crashes and reuses the old highlighter when it restarts. The reason for reusing the highlighter is because this way the highlightings will not disappear as we won't have to dispose of them.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370202
2019-08-28 13:46:22 +00:00
Haojian Wu d1a24bab3a [clang-tidy] Fix the potential infinite loop in recordIsTriviallyDefaultConstructible.
Summary:
The recordIsTriviallyDefaultConstructible may cause an infinite loop when
running on an ill-formed decl.

Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 370200
2019-08-28 13:45:53 +00:00
Sam McCall 9004c077c0 [clang-tidy] readability-identifier-naming shouldn't complain about CRTP pseudo-overrides
Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 370193
2019-08-28 12:08:57 +00:00
Sam McCall ab6594575a [clangd] Fix SelectionTree to allow selection range expression in foreach loops.
Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 370191
2019-08-28 12:05:12 +00:00
Ilya Biryukov d73ac96d80 [clangd] Surface errors from command-line parsing
Summary:
Those errors are exposed at the first character of a file,
for a lack of a better place.

Previously, all errors were stored inside the AST and report
accordingly. However, errors in command-line argument parsing could
result in failure to produce the AST, so we need an alternative ways to
report those errors.

We take the following approach in this patch:
  - buildCompilerInvocation() now requires an explicit DiagnosticConsumer.
  - TUScheduler and TestTU now collect the diagnostics produced when
    parsing command line arguments.
    If pasing of the AST failed, diagnostics are reported via a new
    ParsingCallbacks::onFailedAST method.
    If parsing of the AST succeeded, any errors produced during
    command-line parsing are stored alongside the AST inside the
    ParsedAST instance and reported as previously by calling the
    ParsingCallbacks::onMainAST method;
  - The client code that uses ClangdServer's DiagnosticConsumer
    does not need to change, it will receive new diagnostics in the
    onDiagnosticsReady() callback

Errors produced when parsing command-line arguments are collected using
the same StoreDiags class that is used to collect all other errors. They
are recognized by their location being invalid. IIUC, the location is
invalid as there is no source manager at this point, it is created at a
later stage.

Although technically we might also get diagnostics that mention the
command-line arguments FileID with after the source manager was created
(and they have valid source locations), we choose to not handle those
and they are dropped as not coming from the main file. AFAICT, those
diagnostics should always be notes, therefore it's safe to drop them
without loosing too much information.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 370177
2019-08-28 09:24:55 +00:00
Fangrui Song 180380651c [clang-doc] Use llvm::createStringError and canonicalize error messages
"Bad block found.\n" -> "bad block found"

The lower cased form with no full stop or newline is more common in LLVM
tools.

Reviewed By: juliehockett

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

llvm-svn: 370155
2019-08-28 02:56:03 +00:00
Nathan Ridge 86a4a530f4 [clangd] Add a distinct highlighting for local variables
Summary:
It's useful to be able to distinguish local variables from namespace
scope variables.

Reviewers: hokein, jvikstrom

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 370103
2019-08-27 19:39:11 +00:00
Alex Lorenz 559ae14c9b Remove clang-tidy-vs from clang-tools-extra (PR41791)
The clang-tidy-vs visual studio plugin in clang-tools-extra contains a
security vulnerability in the YamlDotNet package [1]. I posted to cfe-dev [2],
asking if there was anyone who was interested in updating the the plugin
to address the vulnerability. Reid mentioned that Zach (the original committer),
said that there's another plugin (Clang Power Tools) that provides clang-tidy support,
with additional extra features, so it would be ok to remove clang-tidy-vs.

This commit removes the plugin to address the security vulnerability, and adds
a section to the release notes that mentions that the plugin was removed, and
suggests to use Clang Power Tools.

Fixes PR 41791.

[1]: https://nvd.nist.gov/vuln/detail/CVE-2018-1000210
[2]: http://lists.llvm.org/pipermail/cfe-dev/2019-August/063196.html

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

llvm-svn: 370096
2019-08-27 18:36:08 +00:00
Alex Lorenz 1c8a4b7204 Use FileEntryRef for PPCallbacks::HasInclude
This fixes the issue where a filename dependendency was missing if the file that
was referenced with __has_include() was accessed through a symlink in an earlier run,
if the file manager was reused between runs.

llvm-svn: 370081
2019-08-27 17:32:42 +00:00
Dmitri Gribenko 3d5f48dc7f Refactor GlobList from an ad-hoc linked list to a vector
Summary: I think it makes method implementations more obvious.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 370039
2019-08-27 10:56:13 +00:00
Ilya Biryukov 999e4c4793 [Driver] Add an option for createInvocationFromCommandLine to recover on errors
Summary:
Previously, it would always return nullptr on any error.
This change adds a parameter, controlling whether the function should
attempt to return a non-null result even if unknown arguments (or other
errors were encountered).

The new behavior is only used in clangd.

Considered an alternative of changing the return value instead of adding
a new parameter, but that would require updating all callsites. Settled
with the parameter to minimize the code changes.

Reviewers: gribozavr

Reviewed By: gribozavr

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

Tags: #clang

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

llvm-svn: 370033
2019-08-27 10:02:18 +00:00
Sam McCall 37a188b6e8 [clangd] Fix for r370029 test that got left in my client
llvm-svn: 370030
2019-08-27 09:27:00 +00:00
Sam McCall c791d85b12 [clangd] Fix toHalfOpenFileRange where start/end endpoints are in different files due to #include
Summary: https://github.com/clangd/clangd/issues/129

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 370029
2019-08-27 08:44:06 +00:00
Dmitri Gribenko fd2315ce21 GlobList: added a clear test for pattern priority
Summary:
The last glob that matches the string decides whether that string is
included or excluded.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 370028
2019-08-27 08:42:42 +00:00
Sam McCall 049bb913e2 Revert "[clangd] Release notes" (wrong branch)
This reverts commit 51029e5c15.

llvm-svn: 370022
2019-08-27 06:58:05 +00:00
Alex Lorenz 6a808d5a83 Fix clangd's IndexAction for FileSkipped API update
llvm-svn: 370004
2019-08-27 01:36:00 +00:00
Alex Lorenz 67d25fede9 Use FileEntryRef for PPCallbacks::FileSkipped
This fixes the issue where a filename dependendency was missing if the file that
was skipped was included through a symlink in an earlier run, if the file
manager was reused between runs.

llvm-svn: 369998
2019-08-27 01:03:25 +00:00
Sam McCall 51029e5c15 [clangd] Release notes
llvm-svn: 369934
2019-08-26 17:47:44 +00:00
Julie Hockett 72e1f7f960 [clang-doc] Switch Generator::CreateResources to use llvm::Error
Differential Revision: https://reviews.llvm.org/D66502

llvm-svn: 369925
2019-08-26 16:39:48 +00:00
Kadir Cetinkaya 3877aa1660 [clangd] Fix docs
llvm-svn: 369920
2019-08-26 16:01:07 +00:00
Dmitri Gribenko a6fed93f0d Moved GlobList into a separate header file
Summary:
It is a separate abstraction that is used in more contexts than just
a helper for ClangTidyDiagnosticConsumer.

Subscribers: mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 369918
2019-08-26 15:44:32 +00:00
Kadir Cetinkaya 3aeed0fd5a [clangd] Add docs for configuration knobs in clangd
Summary:
This is a first step in documenting different configuration knobs we
have in clangd.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 369917
2019-08-26 15:42:16 +00:00
Yitzhak Mandelbaum 0cd4ab91ab [clang-tidy][NFC] Qualify `makeRule` call in test, for consistency with other calls.
One call `makeRule` is unqualified (and unintentionally relying on ADL to
resolve correctly). This revision qualifies that call for consistency and to
drop use of ADL.

llvm-svn: 369915
2019-08-26 15:27:05 +00:00
Yitzhak Mandelbaum 640230cc97 [clang-tidy] TransformerClangTidyCheck: change choice of location for diagnostic message.
Summary:
This patch changes the location specified to the
`ClangTidyCheck::diag()`. Currently, the beginning of the matched range is
used. This patch uses the beginning of the first fix's range.  This change both
simplifies the code and (hopefully) gives a more intuitive result: the reported
location aligns with the fix(es) provided, rather than the (arbitrary) range of
the rule's match.

N.B. this patch will break the line offset numbers in lit tests if the first fix
is not at the beginning of the match.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369914
2019-08-26 15:17:29 +00:00
Johan Vikstrom 1c9aa70b04 [clangd] Handling text editor/document lifetimes in vscode extension.
Summary:
Just reapplies highlightings for all files when visible text editors change. Could find the correct text editor that should be reapplied but going for a simple implementation instead.
Removes the associated highlighting entry from the Colorizer when a text document is closed.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369911
2019-08-26 13:56:45 +00:00
Johan Vikstrom 3b6d7040cf [clangd] Added a colorizer to the vscode extension.
Summary:
Adds the main colorizer component. It colorizes every time clangd sends a publishSemanticHighlighting notification.
Every time it colorizes it does a full recolorization (removes all decorations from the editor and applies new ones). The reason for this is that all ranges for the same scope share a TextEditorDecorationType. This is due to TextEditorDecorationTypes being very expensive to create. The prototype used one DecorationType per range but that ran into very big performance problems (it took >100 ms to apply 600 lines of highlightings which froze the editor).

This version does not share the problem of being extremly slow, but there is probably potential to optimize it even more.

No document/texteditor lifecycle management code in this CL, that will come in the next one.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369893
2019-08-26 11:36:11 +00:00
Haojian Wu 0a6000f2cb [clangd] Send highlighting diff beyond the end of the file.
Summary: This would make the client life (tracking the changes) easier.

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 369884
2019-08-26 08:38:45 +00:00
Benjamin Kramer 3c614f7b48 [clang-tidy] Manually enable exceptions in tesst that uses them
llvm-svn: 369853
2019-08-24 17:19:06 +00:00
Julie Hockett 245154de50 [clang-doc] Bump BitcodeWriter max line number to 32U
PR43039 reports hitting the assert on a very large file, so bumping this
to allow for larger files.

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

llvm-svn: 369811
2019-08-23 21:14:05 +00:00
Benjamin Kramer ccc272cd32 Fix clang-tidy warning in clang-tidy
argument name 'FixDescription' in comment does not match parameter name 'Description'

Patch by Nils Barth!

llvm-svn: 369783
2019-08-23 17:27:04 +00:00
Kristof Umann dabfea85fc [clang-tidy] Possibility of displaying duplicate warnings
Summary: In case a checker is registered multiple times as an alias, the emitted warnings are uniqued by the report message. However, it is random which checker name is included in the warning. When processing the output of clang-tidy this behavior caused some problems. In this commit the uniquing key contains the checker name too.

Reviewers: alexfh, xazax.hun, Szelethus, aaron.ballman, lebedev.ri, JonasToth, gribozavr

Reviewed By: alexfh

Subscribers: dkrupp, whisperity, rnkovacs, mgrang, cfe-commits

Patch by Tibor Brunner!

Tags: #clang

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

llvm-svn: 369763
2019-08-23 14:57:27 +00:00
Haojian Wu bc01f48da3 [clangd] Link more clang-tidy modules to clangd
Summary: There are two new clang-tidy modules being added recently.

Reviewers: sammccall, jdoerfert

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

Tags: #clang

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

llvm-svn: 369741
2019-08-23 09:13:23 +00:00
Haojian Wu c4905a232c [clang-tidy] Don't emit google-runtime-references warning for functions defined in macros.
Summary:
The macro are usually defined in the common/base headers which are hard
for normal users to modify it.

Reviewers: gribozavr, alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369739
2019-08-23 08:47:27 +00:00
Benjamin Kramer b3a991df3c Fight a bit against global initializers. NFC.
llvm-svn: 369695
2019-08-22 19:43:27 +00:00
Benjamin Kramer 15ee5ba6e7 [clangd] Fold string copy into lambda capture. NFC.
llvm-svn: 369679
2019-08-22 18:09:46 +00:00
Shaurya Gupta 1a28a06ebe [Clangd] Tweaktesting replace toString with consumeError
llvm-svn: 369676
2019-08-22 17:36:31 +00:00
Benjamin Kramer d5aecb9486 Retire llvm::less/equal in favor of C++14 std::less<>/equal_to<>.
llvm-svn: 369674
2019-08-22 17:31:59 +00:00
Shaurya Gupta 5ee01ef1e5 Fixed Missing Expected error handling
llvm-svn: 369666
2019-08-22 16:42:42 +00:00