Commit Graph

2672 Commits

Author SHA1 Message Date
Alexander Kornienko 75cd6a663f [clang-tidy] Add a regression test for google-readability-namespace-comments
Add a regression test for the google-readability-namespace-comments bug
introduced in r315057 (reverted in r315580).

llvm-svn: 315682
2017-10-13 14:11:14 +00:00
Alexander Kornienko 5d62569b04 Revert "Fix nested namespaces in google-readability-nested-namespace-comments."
This reverts r315057. The revision introduces assertion failures:
assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in
const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion()
const: isExpansion() && "Not a macro expansion SLocEntry!"
Stack trace:
    __assert_fail
    clang::SrcMgr::SLocEntry::getExpansion()
    clang::SourceManager::getExpansionLocSlowCase()
    clang::SourceManager::getExpansionLoc()
    clang::Lexer::getRawToken()
    clang::tidy::readability::NamespaceCommentCheck::check()
    clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch()
    clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches()
    clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter()
    clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch()
    clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl()
    clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
    clang::RecursiveASTVisitor<>::TraverseDecl()
    clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
    clang::RecursiveASTVisitor<>::TraverseDecl()
    clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
    clang::RecursiveASTVisitor<>::TraverseDecl()
    clang::ast_matchers::MatchFinder::matchAST()
    clang::MultiplexConsumer::HandleTranslationUnit()
    clang::ParseAST()
    clang::FrontendAction::Execute()
    clang::CompilerInstance::ExecuteAction()
    clang::tooling::FrontendActionFactory::runInvocation()
    clang::tooling::ToolInvocation::runInvocation()
    clang::tooling::ToolInvocation::run()

Still working on an isolated test case.

llvm-svn: 315580
2017-10-12 14:25:16 +00:00
Sam McCall 8a5dded8a5 [clangd] less boilerplate in RPC dispatch
Summary:
Make the ProtocolHandlers glue between JSONRPCDispatcher and
ClangdLSPServer generic.
Eliminate small differences between methods, de-emphasize the unimportant
distinction between notifications and methods.

ClangdLSPServer is no longer responsible for producing a complete
JSON-RPC response, just the JSON of the result object. (In future, we
should move that JSON serialization out, too).
Handler methods now take a context object that we may hang more
functionality off in the future.

Added documentation to ProtocolHandlers.

Reviewers: ilya-biryukov, bkramer

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 315577
2017-10-12 13:29:58 +00:00
Alexander Kornienko 7853351af8 Fix the google-readability-namespace-comments-cxx17 test after r315060.
Restore the file extension. Make the namespace longer than the
ShortNamespaceLines so that the check triggers.

llvm-svn: 315574
2017-10-12 10:41:22 +00:00
Peter Collingbourne 0dfdb44797 Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows.
This allows clients to avoid an unnecessary fs::status() call on each
directory entry. Because the information returned by FindFirstFileEx
is a subset of the information returned by a regular status() call,
I needed to extract a base class from file_status that contains only
that information.

On my machine, this reduces the time required to enumerate a ThinLTO
cache directory containing 520k files from almost 4 minutes to less
than 2 seconds.

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

llvm-svn: 315378
2017-10-10 22:19:46 +00:00
Ilya Biryukov 98a1fd7f96 [clangd] Use UniqueFunction for deferred computations.
Previsouly, `std::future` that were results of
`std::async(std::launch::deferred, ...` were used.

llvm-svn: 315325
2017-10-10 16:12:54 +00:00
Ilya Biryukov eab499d31b [clangd] Added missing #includes to Function.h
llvm-svn: 315324
2017-10-10 16:12:50 +00:00
Ilya Biryukov cfcc0d3eb6 [clangd] Added forgotten return in UniqueFunction.
This hasn't bitten us because we only used functions returning
'void'.

llvm-svn: 315323
2017-10-10 16:12:47 +00:00
Ilya Biryukov 3847be5514 [clangd] clang-format the source code. NFC.
llvm-svn: 315317
2017-10-10 14:21:04 +00:00
Ilya Biryukov e6dbb58f95 Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"
This reverts commit r315242 and restores r315214.

To fix original failure, replaced non-portable `diff -Z` with portable
alternative: `diff -b`.

llvm-svn: 315287
2017-10-10 09:08:47 +00:00
Ilya Biryukov 4923a80f00 [clangd] Fix compilation on gcc.
llvm-svn: 315284
2017-10-10 08:40:57 +00:00
Benjamin Kramer 252dd8b745 [clang-tidy] Use a more efficient map for the virtual near miss check.
DenseMap performs better here. No functionality change intended.

llvm-svn: 315277
2017-10-10 07:21:51 +00:00
Bruno Cardoso Lopes c084589877 Revert r315214 since diff -Z isn't portable, this is breaking:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

llvm-svn: 315242
2017-10-09 20:22:05 +00:00
Ilya Biryukov de0cc39462 [clangd] Added a command-line arg to mirror clangd input into a file.
Summary: The arg is useful for debugging and creating test cases.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

llvm-svn: 315214
2017-10-09 16:58:16 +00:00
Ilya Biryukov b8ea150c19 [clangd] Added a test for r315212.
llvm-svn: 315213
2017-10-09 16:53:00 +00:00
Ilya Biryukov 08e6ccbcf3 [clangd] Added move-only function helpers.
Summary:
They are now used in ClangdScheduler instead of deferred std::async
computations.
The results of `std::async` are much less effective and do not provide
a good abstraction for similar purposes, i.e. for storing additional callbacks
to clangd async tasks. The actual callback API will follow a bit later.

Reviewers: klimek, bkramer, sammccall, krasimir

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 315210
2017-10-09 16:26:26 +00:00
Simon Pilgrim a3aa724fb7 Fix signed/unsigned warning
llvm-svn: 315149
2017-10-07 12:24:10 +00:00
Ilya Biryukov 3333494132 [clangd] Run clang-format on the source code. NFC.
llvm-svn: 315065
2017-10-06 14:39:39 +00:00
Aaron Ballman 331e7f94d5 Renaming a test to start with the name of the check based on post-commit review feedback; NFC.
llvm-svn: 315060
2017-10-06 13:27:59 +00:00
Aaron Ballman 4107c00859 Fixing the command line for a test and switching from tabs to spaces.
llvm-svn: 315059
2017-10-06 13:14:28 +00:00
Aaron Ballman 9549c1180f Fix nested namespaces in google-readability-nested-namespace-comments.
Fixes PR34701.

Patch by Alexandru Octavian Buțiu.

llvm-svn: 315057
2017-10-06 12:57:28 +00:00
Ilya Biryukov d9bdfe0578 [clangd] Add textDocument/signatureHelp
Summary:
Makes clangd respond to a client's "textDocument/signatureHelp" request by
presenting function/method overloads.

Patch by Raoul Wols.

Reviewers: bkramer, ilya-biryukov, krasimir

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 315055
2017-10-06 11:54:17 +00:00
Ilya Biryukov e81b76253d [clangd] Attempt to fix compilation with MSVC.
llvm-svn: 315028
2017-10-05 22:15:15 +00:00
Ilya Biryukov dcd2169380 [clangd] Added async API to run code completion.
Summary:
ClangdServer now provides async code completion API.
It is still used synchronously by ClangdLSPServer, more work is needed
to allow processing other requests in parallel while completion (or
any other request) is running.

Reviewers: klimek, bkramer, krasimir

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 314989
2017-10-05 17:04:13 +00:00
Jonas Toth 5a09996ff7 [clang-tidy] Emit note for variable declaration that are later deleted
This patch introduces a note for variable declaration that are later deleted.
Adds FIXME notes for possible automatic type-rewriting positions as well.

Reviewed by aaron.ballman
Differential: https://reviews.llvm.org/D38411

llvm-svn: 314913
2017-10-04 16:49:20 +00:00
Reid Kleckner 3c8262136c Fix hicpp-signed-bitwise.cpp test on Windows, where the MSVC ABI changes enum underlying types
llvm-svn: 314840
2017-10-03 20:37:06 +00:00
Jonas Toth 2ce23ab6f2 [clang-tidy] fix buildbot hicpp-signed-bitwise
To finally fix the buildbot I added one single warning testcase.

llvm-svn: 314816
2017-10-03 17:08:57 +00:00
Jonas Toth 491b6b5490 [clang-tidy] potentially fix buildbot
I tried to silence lit with `| count 0`, which did not work.
Other testcases did not have `-- --` but only `--` in the RUN line.
Maybe this fixes the problem.

llvm-svn: 314812
2017-10-03 16:53:56 +00:00
Jonas Toth df7e83ea5c [clang-tidy] Remove target specification hicpp-signed-bitwise
This patch removes the targetspecification of a testcase, that broke
for ARM. The underlying problem was fixed which makes it unnecessary to
specify the target architecture (problem was the signedness of `char`).

Committing without review was accepted in https://reviews.llvm.org/D38399
by aaron.ballman.

llvm-svn: 314811
2017-10-03 16:27:41 +00:00
Jonas Toth c1f906c134 [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwise
The bug happened with stream operations, that were not recognized in all cases.
Even there were already existing test for streaming classes, they did not catch this bug.
Adding the isolated example to the existing tests did not trigger the bug.
Therefore i created a new isolated file that did expose the bug indeed.

Differential: https://reviews.llvm.org/D38399
reviewed by aaron.ballman

llvm-svn: 314808
2017-10-03 16:25:01 +00:00
Gabor Horvath 44372fe126 [clang-tidy] Fixed a small code example in docs. NFC.
llvm-svn: 314785
2017-10-03 11:40:07 +00:00
Marc-Andre Laperle bf11424b7f [clangd] Handle workspace/didChangeWatchedFiles
Summary:
The client can send notifications when it detects watched files have
changed. This patch adds the protocol handling for this type of notification.
For now, the notification will be passed down to the ClangdServer, but it will
not be acted upon. However, this will become useful for the indexer to react
to file changes.
The events could also potentially be used to invalidate other caches
(compilation database, etc).

This change also updates the VSCode extension so that it sends the events.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>

Reviewers: ilya-biryukov, Nebiroth

Subscribers: ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 314693
2017-10-02 18:00:37 +00:00
Ilya Biryukov 0c1ca6be96 [clangd] Command line arg to specify compile_commands.json path
Summary: Adds compileCommands command line argument to specify an absolute path directly to the requested compile_commands.json for flags.

Reviewed By: ilya-biryukov

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

llvm-svn: 314678
2017-10-02 15:13:20 +00:00
Ilya Biryukov a91eaeb9ba [clangd] Run clang-format on the source code. NFC.
llvm-svn: 314677
2017-10-02 15:10:41 +00:00
Faisal Vali a8e84625d8 [NFC] Sync function call with changes to interface made in r314593.
llvm-svn: 314595
2017-09-30 14:36:00 +00:00
Sam McCall 4db732a7db [clangd] simplify ClangdLSPServer by private-inheriting callback interfaces. NFC
Summary:
There doesn't seem to be any real separation between the current three objects.
Feel free to reject this if you find the current style valuable, though.

(Mostly I'm just looking around for cleanups to help me understand the code).

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 314587
2017-09-30 10:08:52 +00:00
Sam McCall ef41c34b38 Small clangd cleanups, NFC
- remove old ASTUnit includes
 - fix typo (regiterCallbackHandlers)

llvm-svn: 314532
2017-09-29 16:41:23 +00:00
Ilya Biryukov 686ff9a880 [clangd] Skip informative qualifier chunks.
Summary:
Completion results look much nicer without them.
Informative qualifiers are stored for every method from a base class, even when
calling those methods does not require any qualifiers. For example,
    struct Foo { int foo(); };
    struct Bar : Foo { };
    void test() { Bar(). // Completion item label was 'Foo::foo' before,
                         // but inserted text was simply 'foo'.
                         // We now simply show 'foo' in completion item label.

They effectively cluttered the completion list without providing much value.

Reviewers: bkramer, krasimir, rwols

Reviewed By: rwols

Subscribers: klimek, cfe-commits

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

llvm-svn: 314445
2017-09-28 18:39:59 +00:00
Marc-Andre Laperle 6571b3edd0 [clangd] LSP extension to switch between source/header file
Summary:
Small extension to LSP to allow clients to use clangd to switch between C header files and source files.
Final version will use the completed clangd indexer to use the index of symbols to be able to switch from header to source file when the file names don't match.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, cfe-commits, arphaman

Patch by: William Enright

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

llvm-svn: 314377
2017-09-28 03:14:40 +00:00
Marc-Andre Laperle 37de9718d0 [clangd] Handle InitializeParams and store rootUri
Summary:
The root Uri is the workspace location and will be useful in the context of
indexing. We could also add more things to InitializeParams in order to
configure Clangd for C/C++ sepecific extensions.

Reviewers: ilya-biryukov, bkramer, krasimir, Nebiroth

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 314309
2017-09-27 15:31:17 +00:00
Benjamin Kramer 9297af60db [clangd] Fix missing "message" key when responding with unsupported method
The language server protocol dictates that a ResponseError should have a
[message string][1] describing the error. This adds a simple message to the
error and a simple test.

[1]: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#response-message

Patch by Raoul Wols!

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

llvm-svn: 314119
2017-09-25 17:16:47 +00:00
Sylvestre Ledru 24d98f487b Fix clangd when built with LLVM_LINK_LLVM_DYLIB=ON
Reviewers: malaperle, malaperle-ericsson, bkramer

Reviewed By: bkramer

Subscribers: bkramer, mgorny, ilya-biryukov, cfe-commits

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

llvm-svn: 314107
2017-09-25 14:08:35 +00:00
Reid Kleckner 3fc649cb76 [Support] Rename tool_output_file to ToolOutputFile, NFC
This class isn't similar to anything from the STL, so it shouldn't use
the STL naming conventions.

llvm-svn: 314050
2017-09-23 01:03:17 +00:00
Richard Smith 2ccecb9d88 Fix up clang-tidy after clang r314037.
llvm-svn: 314047
2017-09-22 23:47:20 +00:00
Ilya Biryukov fee6e4aba8 [clangd] Updated gold for completion tests after cfe changes.
llvm-svn: 314020
2017-09-22 19:07:45 +00:00
Krasimir Georgiev ee0dafe3be [clang-tidy] Fix example in documentation, NFC
Summary: A fix in documentation.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: JDevlieghere, xazax.hun

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

llvm-svn: 313962
2017-09-22 04:37:56 +00:00
Ilya Biryukov f4e95d7290 [clangd] Fixed crash on MacOS.
Caused by invalid order of members in ClangdServer.
DiagnosticsMutex was used after destruction.

llvm-svn: 313801
2017-09-20 19:32:06 +00:00
Ilya Biryukov 77f61badf4 [clangd] Put inacessible items to the end of completion list.
Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

llvm-svn: 313759
2017-09-20 15:09:14 +00:00
Ilya Biryukov 47f22026b5 [clangd] Serialize onDiagnosticsReady callbacks for the same file.
Summary:
Calls to onDiagnosticsReady were done concurrently before. This sometimes
led to older versions of diagnostics being reported to the user after
the newer versions.

Reviewers: klimek, bkramer, krasimir

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 313754
2017-09-20 12:58:55 +00:00
Alexander Kornienko 621e555788 [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests
llvm-svn: 313752
2017-09-20 12:16:35 +00:00