Commit Graph

3323 Commits

Author SHA1 Message Date
Eric Liu ec1c1a119b Revert "[clangd] Adapt file migration in r332720"
This reverts commit r332721 because the dependency r33270 will be reverted.

llvm-svn: 332752
2018-05-18 18:33:21 +00:00
Eric Liu db53a52ff2 Trying to fix clang-move tests on windows build bot broken by r332717
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10702

llvm-svn: 332732
2018-05-18 16:08:18 +00:00
Aaron Ballman 655ef1875b Silence more truncation warnings; NFC.
llvm-svn: 332723
2018-05-18 14:53:32 +00:00
Eric Liu 804f4d4650 [clangd] Adapt file migration in r332720
llvm-svn: 332721
2018-05-18 14:17:36 +00:00
Aaron Ballman 215e4718ca Silence a truncation warning; NFC.
llvm-svn: 332716
2018-05-18 13:18:41 +00:00
Eric Liu 90d308ef4b Re-enable a clang-move test on windows.
This was fixed by r332612.

llvm-svn: 332701
2018-05-18 09:25:36 +00:00
Eric Liu a907bf6a31 Disable a failing clang-move test on windows.
This was broken by r332590 but is likely caused by a bug in clang-move.

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

I don't have a windows machine to effectively debug the issue, so I'll investigate
further but for now disable the failing test on windows to unbreak build bots.

llvm-svn: 332620
2018-05-17 16:13:36 +00:00
Eric Liu 07d4730ca4 Second attempt to fix clang-move tests broken by r332590 on windows
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12010

Add back a path conversion removed in a previous attempt. I removed it
because it didn't seem necessary. Added it back to see if this would fix
the bot.

llvm-svn: 332612
2018-05-17 14:59:15 +00:00
Alexander Kornienko 85a92c3f0b [clang-tidy] Add a flag to enable alpha checkers
Summary: The alpha checkers can already be enabled using the clang driver, this allows them to be enabled using the clang-tidy as well. This can make it easier to test the alpha checkers with projects which already support the compile_commands.json. It will also allow more people to give feedback and patches about the alpha checkers since they can run it as part of clang tidy checks.

Reviewers: aaron.ballman, hokein, ilya-biryukov, alexfh, lebedev.ri, xbolva00

Reviewed By: aaron.ballman, alexfh, lebedev.ri, xbolva00

Subscribers: xbolva00, NoQ, dcoughlin, lebedev.ri, xazax.hun, cfe-commits

Patch by Paul Fultz II!

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

llvm-svn: 332609
2018-05-17 14:04:27 +00:00
Eric Liu 5e721378eb Attempt to fix clang-move tests broken by r332590 on windows
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

llvm-svn: 332603
2018-05-17 12:40:50 +00:00
Eric Liu 4c0a27bb7d Second attempt to fix buildbot failure caused by r332363
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26501

llvm-svn: 332520
2018-05-16 20:31:38 +00:00
Aaron Ballman cc740ae5bb Add a new check, readability-simplify-subscript-expr, that diagnoses array subscript expressions that can be simplified.
Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly.

Patch by Shuai Wang.

llvm-svn: 332519
2018-05-16 20:12:06 +00:00
Eric Liu ad3fed62a9 [clang-move] Fix a potential bug where realpath doesn't work on VFS.
llvm-svn: 332518
2018-05-16 20:10:10 +00:00
Ben Hamilton 35d3398f8d [clang-tidy/google-readability-casting] Disable check for Objective-C++
Summary:
Previously, `google-readability-casting` was disabled for Objective-C.

The Google Objective-C++ style allows both Objective-C and
C++ style in the same file. Since clang-tidy doesn't have a good
way to allow multiple styles per file, this disables the
check for Objective-C++.

Test Plan: New tests added. Ran tests with:
  % make -j16 check-clang-tools
  Before diff, confirmed tests failed:
  https://reviews.llvm.org/P8081
  After diff, confirrmed tests passed.

Reviewers: alexfh, Wizard, hokein, stephanemoore

Reviewed By: alexfh, Wizard, stephanemoore

Subscribers: stephanemoore, cfe-commits, bkramer, klimek

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

llvm-svn: 332516
2018-05-16 20:07:19 +00:00
Eric Liu f8947da9ce Attempt to fix buildbot failure caused by r332363
Log: http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399
llvm-svn: 332515
2018-05-16 19:59:49 +00:00
Ilya Biryukov c22d344743 [clangd] Parse all comments in Sema and completion.
Summary:
And add tests for the comment extraction code.

clangd will now show non-doxygen comments in completion for results
coming from Sema and Dynamic index.
Static index does not include the comments yet, I will enable it in
a separate commit after investigating which implications it has for
the size of the index.

Reviewers: sammccall, hokein, ioeric

Reviewed By: sammccall

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

llvm-svn: 332460
2018-05-16 12:32:49 +00:00
Ilya Biryukov 43714504a8 [clangd] Retrieve minimally formatted comment text in completion.
Summary:
Previous implementation used to extract brief text from doxygen comments.
Brief text parsing slows down completion and is not suited for
non-doxygen comments.

This commit switches to providing comments that mimic the ones
originally written in the source code, doing minimal reindenting and
removing the comments markers to make the output more user-friendly.

It means we lose support for doxygen-specific features, e.g. extracting
brief text, but provide useful results for non-doxygen comments.
Switching the doxygen support back is an option, but I suggest to see
whether the current approach gives more useful results.

Reviewers: sammccall, hokein, ioeric

Reviewed By: sammccall

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

llvm-svn: 332459
2018-05-16 12:32:44 +00:00
Eric Liu d67ec24f3e [clangd] Filter out private proto symbols in SymbolCollector.
Summary:
This uses heuristics to identify private proto symbols. For example,
top-level symbols whose name contains "_" are considered private. These symbols
are not expected to be used by users.

Reviewers: ilya-biryukov, malaperle

Reviewed By: ilya-biryukov

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

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

llvm-svn: 332456
2018-05-16 12:12:30 +00:00
Heejin Ahn 85e38ee18e [clangd] Fix a link failure in unittests
Summary: D46524 (rL332378) introduced a link failure when built with
`-DSHARED_LIB=ON`, which this patch fixes.

Reviewers: ioeric

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

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

llvm-svn: 332438
2018-05-16 08:53:57 +00:00
Yan Zhang 6a528854c4 add AR to acronyms of clang-tidy property check
Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

llvm-svn: 332382
2018-05-15 18:13:51 +00:00
Sam McCall c5707b6c36 [clangd] Extract scoring/ranking logic, and shave yaks.
Summary:
Code completion scoring was embedded in CodeComplete.cpp, which is bad:
 - awkward to test. The mechanisms (extracting info from index/sema) can be
   unit-tested well, the policy (scoring) should be quantitatively measured.
   Neither was easily possible, and debugging was hard.
   The intermediate signal struct makes this easier.
 - hard to reuse. This is a bug in workspaceSymbols: it just presents the
   results in the index order, which is not sorted in practice, it needs to rank
   them!
   Also, index implementations care about scoring (both query-dependent and
   independent) in order to truncate result lists appropriately.

The main yak shaved here is the build() function that had 3 variants across
unit tests is unified in TestTU.h (rather than adding a 4th variant).

Reviewers: ilya-biryukov

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

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

llvm-svn: 332378
2018-05-15 17:43:27 +00:00
Nicola Zaghen 0efd52487e [clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM

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

llvm-svn: 332371
2018-05-15 16:37:45 +00:00
Eric Liu 20defe18fc [clangd] Log error message instead write to errs(). NFC
llvm-svn: 332366
2018-05-15 16:22:43 +00:00
Eric Liu 63f419a5c6 [clangd] Populate #include insertions as additional edits in completion items.
Summary:
o Remove IncludeInsertion LSP command.
o Populate include insertion edits synchromously in completion items.
o Share the code completion compiler instance and precompiled preamble to get existing inclusions in main file.
o Include insertion logic lives only in CodeComplete now.
o Use tooling::HeaderIncludes for inserting new includes.
o Refactored tests.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 332363
2018-05-15 15:29:32 +00:00
Eric Liu 2c1905386c [clangd] Remove LSP command-based #include insertion.
Summary:
clangd will populate #include insertions as addtionalEdits in completion items.

The code completion tests in ClangdServerTest will be added back in D46497.

Reviewers: ilya-biryukov, sammccall

Reviewed By: ilya-biryukov

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

llvm-svn: 332362
2018-05-15 15:23:53 +00:00
Eugene Zelenko 7dbce69ba7 [Documentation] Alphabetical order of new checks in Release Notes.
llvm-svn: 332277
2018-05-14 19:12:40 +00:00
Eric Liu 155f5a4f47 [clangd] Add helper for collecting #include directives in file.
Summary: Separate unit tests for the new function will be added in followup patch which will further refactor Headers.h

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 332237
2018-05-14 12:19:16 +00:00
Ilya Biryukov a6556e26ff [clangd] Fix warning after fully covered enum switch. NFC.
By adding llvm_unreachable.

llvm-svn: 332233
2018-05-14 11:47:30 +00:00
Ilya Biryukov a907ba4cb8 [clangd] Don't query index when completing inside classes
Summary:
We used to query the index when completing after class qualifiers,
e.g. 'ClassName::^'. We should not do that for the same reasons we
don't query the index for member access expressions.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

llvm-svn: 332226
2018-05-14 10:50:04 +00:00
Gabor Horvath a49a91b555 [clang-tidy] Add terminating continue check
Patch by: Daniel Kolozsvari!

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

llvm-svn: 332223
2018-05-14 10:10:02 +00:00
Julie Hockett 65631a7c13 [clang-tidy] Fixing fuchsia-restrict-includes-headers test
Removing filepaths so windows tests pass.

llvm-svn: 332152
2018-05-11 22:58:45 +00:00
Julie Hockett b13c6aebaf [clang-tidy] Cleaning up test output (fuchsia-restrict-system-includes)
This should fix the break in the fuchsia-restrict-system-includes-headers
test.

llvm-svn: 332143
2018-05-11 21:28:34 +00:00
Julie Hockett f108a8fee1 Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"
This relands r332125 with a fixed test.

llvm-svn: 332141
2018-05-11 21:08:59 +00:00
Julie Hockett b262a0489b Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"
This reverts commit r332125 for a failing test.

llvm-svn: 332131
2018-05-11 20:03:22 +00:00
Julie Hockett 02aba94e76 [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module
Adding a check to restrict system includes to a whitelist. Given a list
of includes that are explicitly allowed, the check issues a fixit to
remove any system include not on that list from the source file.

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

llvm-svn: 332125
2018-05-11 19:23:15 +00:00
Eric Liu 9133ecdc8e [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h
Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

llvm-svn: 332089
2018-05-11 12:12:08 +00:00
Julie Hockett 546943f9f1 Reland "[tools] Updating PPCallbacks::InclusionDirective calls"
This commit relands r331905.

r331904 added SrcMgr::CharacteristicKind to the InclusionDirective
callback, this revision updates instances of it in clang-tools-extra.

llvm-svn: 332023
2018-05-10 19:13:14 +00:00
Julie Hockett b11f8b3cbc Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"
This reverts commit r331930, which was landed by accident.

llvm-svn: 331934
2018-05-09 22:28:18 +00:00
Julie Hockett 4a43843532 Revert "[tools] Updating PPCallbacks::InclusionDirective calls"
This reverts commit r331905, since it's dependent on reverted r331905.

llvm-svn: 331931
2018-05-09 22:25:43 +00:00
Julie Hockett 06af01bbc2 [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module
Adding a check to restrict system includes to a whitelist. Given a list
of includes that are explicitly allowed, the check issues a fixit to
remove any system include not on that list from the source file.

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

llvm-svn: 331930
2018-05-09 22:25:42 +00:00
Julie Hockett 4e548fe06f [tools] Updating PPCallbacks::InclusionDirective calls
[revision] added SrcMgr::CharacteristicKind to the InclusionDirective
callback, this revision updates instances of it in clang-tools-extra.

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

llvm-svn: 331905
2018-05-09 18:27:37 +00:00
Manuel Klimek d88caa21e6 Do not warn on unused parameters for functions with empty bodies.
If a function has an empty body, all parameters are trivially unused.

llvm-svn: 331875
2018-05-09 13:20:03 +00:00
Roman Lebedev 6e76a1b1ff Partially revert r331456: [clang-tidy] Remove AnalyzeTemporaryDtors option.
That broke every single .clang-tidy config out there
which happened to specify AnalyzeTemporaryDtors option:

YAML:5:24: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: false
                       ^~~~~
Error parsing <...>/.clang-tidy: Invalid argument

More so, that error isn't actually a error, the
clang-tidy does not exit with $? != 0, it continues
with the default config.

Surely this breakage isn't the intended behavior.
But if it is, feel free to revert this commit.

llvm-svn: 331822
2018-05-08 23:15:58 +00:00
Simon Pilgrim d3fec769d0 Fix Wdocumentation warning. NFCI.
llvm-svn: 331805
2018-05-08 20:24:45 +00:00
Roman Lebedev 1215251151 [clang-tidy] Profile is a per-AST (per-TU) data.
Summary:
As discussed in D45931, currently, profiling output of clang-tidy is somewhat not great.
It outputs one profile at the end of the execution, and that profile contains the data
from the last TU that was processed. So if the tool run on multiple TU's, the data is
not accumulated, it is simply discarded.

It would be nice to improve this.

This differential is the first step - make this profiling info per-TU,
and output it after the tool has finished processing each TU.
In particular, when `ClangTidyASTConsumer` destructor runs.

Next step will be to add a CSV (JSON?) printer to store said profiles under user-specified directory prefix.

Reviewers: alexfh, sbenza

Reviewed By: alexfh

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

Tags: #clang-tools-extra

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

llvm-svn: 331763
2018-05-08 13:14:21 +00:00
Yan Zhang 4f9ead2356 Add support for ObjC property name to be a single acronym.
Summary:
This change will support cases like:

```
@property(assign, nonatomic) int ID;
```

Reviewers: benhamilton, hokein

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 331545
2018-05-04 18:14:08 +00:00
Julie Hockett b59cd77c87 [clang-doc] Attaching a name to reference data
This adds the name of the referenced decl, in addition to its USR, to
the saved data, so that the backend can look at an info in isolation and
still be able to construct a human-readable name for it.

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

llvm-svn: 331539
2018-05-04 17:02:13 +00:00
Zinovy Nis 8242ca3312 Simplify test clang-tidy-__clang_analyzer__macro.cpp
llvm-svn: 331475
2018-05-03 18:31:39 +00:00
Zinovy Nis beca76823b [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer
This macro is widely used in many well-known projects, ex. Chromium.
But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered
as [[no-return]], and a lot of false-positive warnings about nullptr
dereferenced are emitted.

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

llvm-svn: 331474
2018-05-03 18:26:39 +00:00
Alexander Kornienko 961fb99894 Added trailing periods.
llvm-svn: 331461
2018-05-03 16:01:49 +00:00