Commit Graph

2535 Commits

Author SHA1 Message Date
Ilya Biryukov a2e7ca99e0 [clangd] Add ':' to completion trigger characters.
Summary:
Without it we don't get completion requests from VSCode after
nested name qualifiers (e.g. after 'std::').

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

llvm-svn: 309550
2017-07-31 09:27:52 +00:00
Alexander Shaposhnikov b687fdda29 [clang-reorder-fields] Emit warning when reordering breaks member init list dependencies
This diff adds a warning emitted by clang-reorder-fields 
when reordering breaks dependencies in the initializer list.

Patch by Sam Conrad!

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

llvm-svn: 309505
2017-07-30 06:43:03 +00:00
Alexander Kornienko f288ace639 [clang-tidy] Expand readability-redundant-function-ptr-dereference test
llvm-svn: 309380
2017-07-28 12:46:08 +00:00
Alexander Kornienko f3321c5f68 [clang-tidy] readability-redundant-declaration: ignore friends and macros
llvm-svn: 309379
2017-07-28 12:46:02 +00:00
Ilya Biryukov 4dafd14d1a [clangd] Workaround for a test failure on Windows.
Previous workaround (r308959) didn't account for a case when system drive
letter is not 'C:'.

llvm-svn: 309378
2017-07-28 12:25:51 +00:00
Ilya Biryukov de46274d7b [clangd] Don't reverse priorities of completion items.
Summary: Current algorithm incorrectly provides completion results in a reverse order.

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

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

llvm-svn: 309295
2017-07-27 17:43:07 +00:00
Felix Berger 603ea2df2a [clang-tidy] Do not issue fixit for explicit template specializations
Summary:

Do not issue fixit in UnnecessaryValueParamCheck if the function is an explicit template specialization as this could cause build breakages.

Reviewers: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 309067
2017-07-26 00:45:41 +00:00
Kevin Funk fe284e4616 [clang-tidy] Fixup clang-apply-replacements/invalid-files test
llvm-svn: 308975
2017-07-25 14:39:08 +00:00
Kevin Funk bb5cfb5dd3 [clang-tidy] clang-apply-replacements: Don't insert null entry
Summary:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Fix crash when running clang-apply-replacements on YML files which
contain an invalid file path. Make sure we never add a nullptr into the
map. The previous code started adding nullptr to the map after the first
warnings via errs() has been emitted.

Backtrace:
```
Starting program:
/home/kfunk/devel/build/llvm/bin/clang-apply-replacements /tmp/tmpIqtp7m
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
Described file '.moc/../../../../../../src/qt5.8/qtremoteobjects/src/remoteobjects/qremoteobjectregistrysource_p.h' doesn't exist. Ignoring...
...

Program received signal SIGSEGV, Segmentation fault.
main (argc=<optimized out>, argv=<optimized out>) at /home/kfunk/devel/src/llvm/tools/clang/tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:262
(gdb) p FileAndReplacements.first
$1 = (const clang::FileEntry *) 0x0
(gdb)
```

Added tests.

Before patch:

```
******************** TEST 'Clang Tools :: clang-apply-replacements/invalid-files.cpp' FAILED ********************
Script:
--
mkdir -p /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
clang-apply-replacements /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
ls -1 /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files | FileCheck /home/kfunk/devel/src/llvm/tools/clang/tools/extra/test/clang-apply-replacements/invalid-files.cpp --check-prefix=YAML
--
Exit Code: 139

Command Output (stderr):
--
Described file 'idonotexist.h' doesn't exist. Ignoring...
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/invalid-files.cpp.script: line 4:  9919 Segmentation fault      clang-apply-replacements /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-   replacements/Output/Inputs/invalid-files

--
```

After Patch:

```
PASS: Clang Tools :: clang-apply-replacements/invalid-files.cpp (5 of 6)
```

Reviewers: alexfh, yawanng

Reviewed By: alexfh

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

Tags: #clang-tools-extra

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

llvm-svn: 308974
2017-07-25 14:28:16 +00:00
Krasimir Georgiev e4130d52da [clangd] Reuse compile commands during reparse
Summary:
Previously we always queried the compilation database and discarded the results
if the file was already opened.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 308970
2017-07-25 11:37:43 +00:00
Ilya Biryukov e98fa38292 [clangd] Workaround Windows test failures.
To properly fix this, Unix-specific paths should not be used when
running tests on Windows.

llvm-svn: 308959
2017-07-25 09:31:51 +00:00
Gabor Horvath 97c8e09790 [clang-tidy] Handle incomplete types in bugprone-undefined-memory-manipulation
check

Patch by: Reka Nikolett Kovacs

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

llvm-svn: 308954
2017-07-25 06:52:08 +00:00
NAKAMURA Takumi 3545ee5f3f clangDaemon: Update libdeps in r308738.
llvm-svn: 308807
2017-07-21 23:48:26 +00:00
Ilya Biryukov 04db368a3f [clangd] Replace ASTUnit with manual AST management.
Summary:
This refactoring does not aim to introduce any significant changes to
the behaviour of clangd to keep the change as simple as possible.

Reviewers: klimek, krasimir, bkramer

Reviewed By: krasimir

Subscribers: malaperle, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 308738
2017-07-21 13:29:29 +00:00
Alexander Kornienko 16300e1265 [clang-tidy] Add option to export fixes to run-clang-tidy.py
This patch adds the option to keep the list of proposed fixes even though they
should not be applied.

This allows to detect possible fixes using the parallelised run-clang-tidy.py
and apply them using clang-apply-replacements at a later time.
Essentially the patch causes the individual temporary yaml files by the parallel
clang-tidy instances to be merged into one user-defined file.

Patch by Michael F. Herbst!
Differential revision: https://reviews.llvm.org/D31326

llvm-svn: 308726
2017-07-21 10:31:26 +00:00
Ilya Biryukov ba3bd7ce3e [clangd] Specified --gcc-toolchain explicitly in VFS test.
In order to avoid platform-specific configuration quirks.
(Possible fix for https://bugs.llvm.org/show_bug.cgi?id=33842)

llvm-svn: 308721
2017-07-21 08:20:47 +00:00
Alexander Shaposhnikov eaf833ca2b [clang-tools-extra] Add support for plain C structs in clang-reorder-fields
This diff updates the tool clang-reorder-fields
to enable reordering of fields of plain C structs.

Test plan: make check-all

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

llvm-svn: 308678
2017-07-20 21:41:20 +00:00
Alexander Kornienko deda4b2ae0 [clang-tidy] s/1/true/, NFC
llvm-svn: 308621
2017-07-20 14:56:52 +00:00
Alexander Kornienko b1c7432117 [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used
llvm-svn: 308605
2017-07-20 12:02:03 +00:00
Krasimir Georgiev 0dcb48eab1 [clangd] Allow specifying -resource-dir
Summary: This patch allows clangd to specify its -resource-dir.

Reviewers: bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 308486
2017-07-19 15:43:35 +00:00
Hans Wennborg 1298fd907c Clear release notes for 6.0.0
llvm-svn: 308479
2017-07-19 14:15:27 +00:00
Hans Wennborg 25aedcc7b2 Bump docs version to 6.0
llvm-svn: 308467
2017-07-19 13:51:07 +00:00
Manuel Klimek 89970d46da Add autoload cookies for clang-include-fixer lisp functions.
Annotate all public functions with the autoload magic cookie so that
update-directory-autoloads will find them.

Patch by Brendan O'Dea.

llvm-svn: 308290
2017-07-18 10:15:07 +00:00
Faisal Vali cb8e01acd0 [NFC] Update function call names as changed in MacroInfo that should refer to Parameters (as opposed to Arguments).
This syncs them up with clang commit r308190

Thanks!

llvm-svn: 308191
2017-07-17 17:20:57 +00:00
Alexander Kornienko 31176afd16 [clang-tidy] Add modernize-use-bool-literals.IgnoreMacros option
llvm-svn: 308181
2017-07-17 14:43:06 +00:00
NAKAMURA Takumi 8de96ca8bc ClangApplyReplacementsTests: Add clangBasic in libdeps.
r308015 introduced clangBasic to instantiate Diagnostics &c,

llvm-svn: 308085
2017-07-15 06:32:10 +00:00
Gabor Horvath 5aae773d86 [clang-tidy] Minor documentation fix. NFC.
llvm-svn: 308022
2017-07-14 12:31:21 +00:00
Gabor Horvath 46a9db45c6 [clang-tidy] Add bugprone-undefined-memory-manipulation check
Patch by: Reka Nikolett Kovacs

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

llvm-svn: 308021
2017-07-14 12:20:19 +00:00
Gabor Horvath 829e75a037 [clang-tidy] Add bugprone-suspicious-memset-usage check
Created new module bugprone and placed the check in that.

Finds memset() calls with potential mistakes in their arguments.
Replaces and extends the existing google-runtime-memset-zero-length check.

Cases covered:
* Fill value is a character '0'. Integer 0 might have been intended.
* Fill value is out of char range and gets truncated.
* Byte count is zero. Potentially swapped with the fill value argument.

Patch by: Reka Nikolett Kovacs

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

llvm-svn: 308020
2017-07-14 12:15:55 +00:00
Alexander Kornienko 8b4fcb7197 [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
Summary:
To get properly integration Clang-Tidy with CLion IDE, next things were implemented:
* Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
* Export all diagnostics, not just the ones with fixes
* Test-cases

Reviewers: alexfh, ilya-biryukov

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

Tags: #clang-tools-extra

Patch by Vladimir Plyashkun!

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

llvm-svn: 308015
2017-07-14 10:37:46 +00:00
NAKAMURA Takumi 02d34adfd8 clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-header.cpp: Resolve flakiness in the test.
Tests would go flaky if;
1. Using %T (not %t)
2. Put a file with common name like header.h into %T
3. Other tests (eg. misc-unused-parameters.cpp) are doing as well

We should avoid using %T unless it really makes sense.

llvm-svn: 307876
2017-07-13 02:06:30 +00:00
Yan Wang b38045d02e [clang-tidy] Add a new Android check "android-cloexec-socket"
Summary: socket() is better to include SOCK_CLOEXEC in its type argument to avoid the file descriptor leakage.

Reviewers: chh, Eugene.Zelenko, alexfh, hokein, aaron.ballman

Reviewed By: chh, alexfh

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

Tags: #clang-tools-extra

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

llvm-svn: 307818
2017-07-12 17:43:36 +00:00
Haojian Wu a9a1b403bc [clang-tidy] Ignore blank spaces between cast's ")" and its sub expr.
Summary:
Before the change:

`auto i = (Enum) 5;` => `auto i = static_cast<Enum>( 5);`

After the change:

`auto i = (Enum) 5;` => `auto i = static_cast<Enum>(5);`

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 307812
2017-07-12 16:38:59 +00:00
Chih-Hung Hsieh 98a6b3ea87 [clang-tidy] add regression test to performance-unnecessary-value-param
This test shows the problem in https://bugs.llvm.org/show_bug.cgi?id=33734

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

llvm-svn: 307810
2017-07-12 16:27:00 +00:00
Gabor Horvath 5314521328 [clang-tidy] Add new modernize use unary assert check
Patch by: Lilla Barancsuk

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

llvm-svn: 307791
2017-07-12 13:43:35 +00:00
Alexander Kornienko c2dcdd9984 [clang-tidy] add_new_check.py updates ReleaseNotes.rst now
llvm-svn: 307787
2017-07-12 13:13:41 +00:00
Marc-Andre Laperle 9647a28fb7 [clangd] Fix Go to Definition not working in VSCode extension
Summary:
The URI conversion logic was returning 'undefined' when going from server to
VSCode which broke the Go to Definition functionality.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 307715
2017-07-11 21:26:18 +00:00
Reid Kleckner f84c2fc51a Fix clang-tidy diagnostic.cpp test on Windows
llvm-svn: 307701
2017-07-11 20:22:17 +00:00
Alexander Kornienko 9e3abbd5a5 [clang-tidy] Extend diagnostics test.
* test that no diagnostics are redirected to stderr
  * test that a file-based compilation database is not picked up when the
    command line after -- contains an error

llvm-svn: 307661
2017-07-11 15:23:05 +00:00
Philipp Stephani d7901b29ce Use new command replace-buffer-contents if available
Reviewers: klimek

Reviewed By: klimek

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

llvm-svn: 307635
2017-07-11 09:01:58 +00:00
Petr Hosek fe0e145aed [CMake] Use tools template for clangd and modularize
This makes them usable as distribution components in the build.

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

llvm-svn: 307601
2017-07-11 00:18:07 +00:00
Philipp Stephani 7ac5d59554 Improve error message when run from a buffer that doesn't visit a file
Summary: In this case, users currently get a confusing type error.  Make the error message more obvious.

Reviewers: klimek

Reviewed By: klimek

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

llvm-svn: 307535
2017-07-10 13:49:18 +00:00
Alexander Kornienko 91dafe09b0 [clang-tidy] Fix modernize-use-override incorrect replacement
Summary:
For the following code: `modernize-use-override` generates a replacement with incorrect location.
```
struct IntPair
{
  int first, second;
};

struct A
{
  virtual void il(IntPair);
};

struct B : A
{
  void il(IntPair p = {1, (2 + 3)}) {};
  // Generated Fixit: void il(IntPair p = override {1, (2 + 3)}) {};
  // Should be: void il(IntPair p = {1, (2 + 3)}) override {};
};
```
This fixes that and adds a unit test.

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Victor Gao!

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

llvm-svn: 307379
2017-07-07 10:15:24 +00:00
Krasimir Georgiev c2a16a3567 [clangd] Add support for per-file extra flags
Summary:
This patch adds the ability to specify user-defined extra flags per opened file
through the LSP layer. This is a non-standard extension to the protocol.
I've already created a feature request about it for upstream lsp:
https://github.com/Microsoft/language-server-protocol/issues/255

The particular use-case is ycmd, which has a python script for figuring out
extra flags per file:
https://github.com/Valloric/ycmd#flagsforfile-filename-kwargs-

Reviewers: ilya-biryukov, klimek, bkramer

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 307241
2017-07-06 08:44:54 +00:00
Haojian Wu 040c0f96cc [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.
Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

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

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

llvm-svn: 307130
2017-07-05 07:49:00 +00:00
NAKAMURA Takumi 7a0fb798ae ClangdServer.cpp: Suppress a warning. [-Wunused-lambda-capture]
llvm-svn: 307068
2017-07-04 12:12:14 +00:00
Jonas Devlieghere b63eb61fc4 [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive
Summary: https://bugs.llvm.org/show_bug.cgi?id=33557

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

Reviewed By: aaron.ballman, hokein

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

Tags: #clang-tools-extra

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

llvm-svn: 307040
2017-07-03 16:46:46 +00:00
Ilya Biryukov 53d69e329b [clangd] Add -ffreestanding on VFS tests.
Summary:
They don't provide proper gcc installations and may fail on implicit
<stdc-predef.h> include.

Reviewers: klimek, krasimir, bkramer

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 307025
2017-07-03 14:46:03 +00:00
Richard Smith 02c3baaad2 Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
This is a short-term fix for PR33650 aimed to get the modules build bots green again.

Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
macros to try to locally specialize a global template for a global type. That's
not how C++ works.

Instead, we now centrally define how to format vectors of fundamental types and
of string (std::string and StringRef). We use flow formatting for the former
cases, since that's the obvious right thing to do; in the latter case, it's
less clear what the right choice is, but flow formatting is really bad for some
cases (due to very long strings), so we pick block formatting. (Many of the
cases that were using flow formatting for strings are improved by this change.)

Other than the flow -> block formatting change for some vectors of strings,
this should result in no functionality change.

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

Corresponding LLVM change is r306878.

llvm-svn: 306879
2017-06-30 20:57:16 +00:00
Alex Lorenz bf38b4effc Move ClassReplacements.cpp test from clang-rename tests to the
clang-apply-replacements tests

The ClassReplacements.cpp test in the clang-rename tests uses
clang-apply-replacements. I moved it back to the clang-tools-extra repository
for now to ensure that the clang-rename tests can pass when clang is compiled
without clang-tools-extra.

llvm-svn: 306843
2017-06-30 16:58:36 +00:00