Commit Graph

3145 Commits

Author SHA1 Message Date
Aaron Ballman 3d161ab6f4 Add support for NOLINT and NOLINTNEXTLINE comments mentioning specific check names.
Supports a comma-separated list of check names to be disabled on the given line. Also supports * as a wildcard to disable all lint diagnostic messages on that line.

Patch by Anton (xgsa).

llvm-svn: 320713
2017-12-14 16:13:57 +00:00
Ilya Biryukov 12cdb4fd33 [clangd] Changed tracing interfaces
Summary:
EventTracer interface now contains two methods:
- spanEvent for events that have duration,
- instant for events that are instant.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, luckygeck, cfe-commits

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

llvm-svn: 320708
2017-12-14 15:33:38 +00:00
Ilya Biryukov ee27d2ebae [clangd] Implemented tracing using Context
Reviewers: sammccall, ioeric, hokein

Reviewed By: sammccall

Subscribers: klimek, luckygeck, cfe-commits

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

llvm-svn: 320706
2017-12-14 15:04:59 +00:00
Eric Liu d293bf127a [clangd] Add a FileSymbols container that manages symbols from multiple files.
Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 320701
2017-12-14 14:50:58 +00:00
Eric Liu a2d4607a4b [clangd] Fix a potential use-after-move bug.
llvm-svn: 320695
2017-12-14 12:31:04 +00:00
Haojian Wu 56a5fca473 [clangd] Construct SymbolSlab from YAML format.
Summary: This will be used together with D40548 for the global index source (experimental).

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 320694
2017-12-14 12:17:14 +00:00
Eric Liu 3732cadc73 [clangd] Symbol index interfaces and an in-memory index implementation.
Summary:
o Index interfaces to support using different index sources (e.g. AST index, global index) for code completion, cross-reference finding etc. This patch focuses on code completion.

The following changes in the original patch has been split out.
o Implement an AST-based index.
o Add an option to replace sema code completion for qualified-id with index-based completion.
o Implement an initial naive code completion index which matches symbols that have the query string as substring.

Reviewers: malaperle, sammccall

Reviewed By: sammccall

Subscribers: hokein, klimek, malaperle, mgorny, ilya-biryukov, cfe-commits

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

llvm-svn: 320688
2017-12-14 11:25:49 +00:00
Haojian Wu 03e2bd76c8 [clangd] Fix the unitttest build error on buildbot.
llvm-svn: 320678
2017-12-14 09:20:21 +00:00
Ilya Biryukov 3db40ffef3 [clangd] Fix bool conversion operator of UniqueFunction
Usages of it were giving compiler errors because of the missing
explicit conversion.

llvm-svn: 320591
2017-12-13 15:42:59 +00:00
Ilya Biryukov a1d324d8b7 [clangd] Try to workaround MSVC compilation failure.
llvm-svn: 320578
2017-12-13 13:43:47 +00:00
Ilya Biryukov 5a85b8e6dd [clangd] clang-format the source code. NFC
llvm-svn: 320577
2017-12-13 12:53:16 +00:00
Ilya Biryukov 940901e8b1 [clangd] Implemented logging using Context
Reviewers: sammccall, ioeric, hokein

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

llvm-svn: 320576
2017-12-13 12:51:22 +00:00
Haojian Wu acc90d17c5 [clangd] Remove the const specifier of the takeSymbol method
otherwise we will copy an object.

llvm-svn: 320574
2017-12-13 12:39:06 +00:00
Sam McCall 8111d3b89c [clangd] Emit ranges for clangd diagnostics, and fix off-by-one positions
Summary:
 - when the diagnostic has an explicit range, we prefer that
 - if the diagnostic has a fixit, its RemoveRange is our next choice
 - otherwise we try to expand the diagnostic location into a whole token.
   (inspired by VSCode, which does this client-side when given an empty range)
 - if all else fails, we return the zero-width range as now.
   (clients react in different ways to this, highlighting a token or a char)
 - this includes the off-by-one fix from D40860, and borrows heavily from it

Reviewers: rwols, hokein

Subscribers: klimek, ilya-biryukov, cfe-commits

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

llvm-svn: 320555
2017-12-13 08:48:42 +00:00
Sam McCall d404654987 [clangd] Overload hash_value for SymbolID, fix struct/class warning
llvm-svn: 320554
2017-12-13 08:34:48 +00:00
Raoul Wols 212bcf8370 [clangd] (Attempt to) read clang-format file for document formatting
Summary:
Takes into account the clang-format file of the project, if any.
Reverts to LLVM if nothing is found. Replies with an error if any error occured.
For instance, a parse error in the clang-format YAML file.

Reviewers: ilya-biryukov, sammccall, Nebiroth, malaperle, krasimir

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 320524
2017-12-12 20:25:06 +00:00
Haojian Wu 4c1394d67d [clangd] Introduce a "Symbol" class.
Summary:
* The "Symbol" class represents a C++ symbol in the codebase, containing all the
  information of a C++ symbol needed by clangd. clangd will use it in clangd's
  AST/dynamic index and global/static index (code completion and code
  navigation).
* The SymbolCollector (another IndexAction) will be used to recollect the
  symbols when the source file is changed (for ASTIndex), or to generate
  all C++ symbols for the whole project.

In the long term (when index-while-building is ready), clangd should share a
same "Symbol" structure and IndexAction with index-while-building, but
for now we want to have some stuff working in clangd.

Reviewers: ioeric, sammccall, ilya-biryukov, malaperle

Reviewed By: sammccall

Subscribers: malaperle, klimek, mgorny, cfe-commits

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

llvm-svn: 320486
2017-12-12 15:42:10 +00:00
Ilya Biryukov ef3191fcfd [clangd] Removed unused variable. NFC
llvm-svn: 320482
2017-12-12 14:15:01 +00:00
Ilya Biryukov 9b5ffc22f6 [clangd] clang-format the code. NFC
llvm-svn: 320476
2017-12-12 12:56:46 +00:00
Ilya Biryukov 0e6a51f4f3 [clangd] Document highlights for clangd
Summary: Implementation of Document Highlights Request as described in
LSP.

Contributed by William Enright (nebiroth).

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: malaperle

Subscribers: mgrang, sammccall, klimek, ioeric, rwols, cfe-commits, arphaman, ilya-biryukov

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

llvm-svn: 320474
2017-12-12 12:27:47 +00:00
Ilya Biryukov 657159c273 [clangd] Introduced a Context that stores implicit data
Summary:
It will be used to pass around things like Logger and Tracer throughout
clangd classes.

Reviewers: sammccall, ioeric, hokein, bkramer

Reviewed By: sammccall

Subscribers: klimek, bkramer, mgorny, cfe-commits

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

llvm-svn: 320468
2017-12-12 11:16:45 +00:00
Alexander Kornienko ba874922a2 [clang-tidy] Correctly classify constant arrays and constant strings as constants when checking identifiers naming
Summary:
They are not locally const qualified so they weren't classified as
constants by the readability-identifier-naming check.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: klimek, cfe-commits, xazax.hun

Patch by Beren Minor!

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

llvm-svn: 320406
2017-12-11 19:02:26 +00:00
Sam McCall 44fdcec26f [clangd] Convert lit code completion tests to unit-tests. NFC
Summary: This improves readability of tests and error messages.

Reviewers: ioeric

Subscribers: klimek, ilya-biryukov, cfe-commits

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

llvm-svn: 320148
2017-12-08 15:00:59 +00:00
Eric Liu 5a6d57c75f [change-namespace] Fix crash when injected base-class name is used in friend declarations.
Reviewers: hokein

Subscribers: klimek, cfe-commits

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

llvm-svn: 320139
2017-12-08 10:06:16 +00:00
Matt Morehouse 468d4da4e8 [clangd-fuzzer] Update contruction of LSPServer.
The constructor for ClangdLSPServer changed in r318412 and r318925,
breaking the clangd-fuzzer build.

llvm-svn: 320074
2017-12-07 19:04:27 +00:00
Matt Morehouse 5a5c1d1c69 [CMake] Use PRIVATE in target_link_libraries for fuzzers.
Several fuzzers were missed by r319840.

llvm-svn: 319948
2017-12-06 19:52:40 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Sam McCall f6ae323ddf [clangd] Clean up code complete unit tests. NFC
llvm-svn: 319820
2017-12-05 20:11:29 +00:00
Julie Hockett a0d50ce7af Commit access test.
llvm-svn: 319812
2017-12-05 18:50:49 +00:00
Jonas Toth 3f7eb40cdb [clang-tidy] adjust cppcoreguidelines-owning-memory documentation
Summary:
A user of the check opened a bugreport and reported that `std::exchange`
triggers a false positive. I adjusted the doc to include a list of known
(std) constructs that do trigger the issue with templates forgetting the
type alias.

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

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

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

llvm-svn: 319785
2017-12-05 16:37:49 +00:00
Ilya Biryukov d3b04e3517 [clangd] Set completion options per-request.
Summary:
Previously, completion options were set per ClangdServer instance.
It will allow to change completion preferences during the lifetime
of a single ClangdServer instance.

Also rewrote ClangdCompletionTest.CompletionOptions to reuse single
ClangdServer instance, the test now runs 2x faster on my machine.

Reviewers: sammccall, ioeric, hokein

Reviewed By: sammccall, ioeric

Subscribers: klimek, cfe-commits

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

llvm-svn: 319753
2017-12-05 10:42:57 +00:00
Sam McCall 93cd99173f [clangd] Remove unused test param. NFC
llvm-svn: 319742
2017-12-05 07:34:35 +00:00
Sam McCall 9aad25f193 [clangd] Split code-completion tests out of ClangdTests. NFC.
Summary:
Common parts are mostly FS related, so pulled out TestFS.h for the common stuff.
Deliberately resisted cleaning up much here, so this is pretty mechanical.

Reviewers: hokein

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

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

llvm-svn: 319741
2017-12-05 07:20:26 +00:00
Hans Wennborg ef573fa073 Fix build after r319688: s/CPlusPlus1z/CPlusPlus17/
llvm-svn: 319690
2017-12-04 20:38:21 +00:00
Sam McCall 98775c5055 [clangd] Split CodeComplete into a separate file. NFC
Summary: Shared details of ClangdUnit and CodeComplete moved to a new Compiler file.

Reviewers: ilya-biryukov

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 319655
2017-12-04 13:49:59 +00:00
Sam McCall ecbeab0ea1 [clangd] GlobalCompilationDatabase interface changes
Summary:
- GlobalCompilationDatabase now returns a single command (that's all we use)
- fallback flags are now part of the GlobalCompilationDatabase.
  There's a default implementation that they can optionally customize.
- this allows us to avoid invoking the fallback logic on two separate codepaths
- race on extra flags fixed by locking the mutex
- made GCD const-correct (DBGCD does have mutating methods)

Reviewers: hokein

Subscribers: klimek, cfe-commits, ilya-biryukov

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

llvm-svn: 319647
2017-12-04 10:08:45 +00:00
Sam McCall 3ea964090a [clangd] Avoid enum in bitfields, can't satisfy old GCC and new MSVC
llvm-svn: 319608
2017-12-02 04:15:55 +00:00
Sam McCall 8e97cca149 [clangd] Fix FuzzyMatch tests on windows, NFC
Without specifying the signedness of the underlying type for Action,
packing it in a 1-bit field may restrict its range to [-1, 0] which
can't represent Match.

llvm-svn: 319606
2017-12-02 03:35:19 +00:00
Sam McCall a8c5d3af60 [clangd] Try to appease gcc constexpr bug (58541)
llvm-svn: 319604
2017-12-02 02:28:29 +00:00
Sam McCall 8fed634e21 [clangd] Define constants in the right namespace. NFC
llvm-svn: 319579
2017-12-01 20:03:19 +00:00
Sam McCall 87496417ff [clangd] Fuzzy match scorer
Summary:
This will be used for rescoring code completion results based on partial
identifiers.
Short-term use:
  - we want to limit the number of code completion results returned to
  improve performance of global completion. The scorer will be used to
  rerank the results to return when the user has applied a filter.
Long-term use case:
  - ranking of completion results from in-memory index
  - merging of completion results from multiple sources (merging usually
  works best when done at the component-score level, rescoring the
  fuzzy-match quality avoids different backends needing to have
  comparable scores)

Reviewers: ilya-biryukov

Subscribers: cfe-commits, mgorny

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

llvm-svn: 319557
2017-12-01 17:08:02 +00:00
Sam McCall 9fbecd5b0d [clangd] Filter completion results by fuzzy-matching identifiers.
Summary:
This allows us to limit the number of results we return and still allow them
to be surfaced by refining a query (D39852).

The initial algorithm is very conservative - it accepts a completion if the
filter is any case-insensitive sub-sequence. It does not attempt to rank items
based on match quality.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 319552
2017-12-01 16:35:50 +00:00
Sam McCall 9c8f2caa01 [clangd] Remove no-op -fsyntax-only from fallback command. NFC
This has no effect because we explicitly choose our actions.
(If it had an effect, we'd want to add it to commands we get from a CDB)

llvm-svn: 319546
2017-12-01 14:35:17 +00:00
Sam McCall 318fbeb972 [clangd] Logger implicitly adds newline
llvm-svn: 319497
2017-11-30 23:21:34 +00:00
Sam McCall fae3b02520 [clangd] Log file compile commands
llvm-svn: 319496
2017-11-30 23:16:23 +00:00
Eugene Zelenko b026bf1fcc [Documentation] Style fixes for Objective-C checks documentation to follow C/C++ example.
Release Notes should just repeat first sentence from documentation.

Remove duplicated entry from Release Notes.

llvm-svn: 319479
2017-11-30 21:42:27 +00:00
Sam McCall ff8b874548 [clangd] New conventions for JSON-marshalling functions, centralize machinery
Summary:
 - JSON<->Obj interface is now ADL functions, so they play nicely with enums
 - recursive vector/map parsing and ObjectMapper moved to JSONExpr and tested
 - renamed (un)parse to (de)serialize, since text -> JSON is called parse
 - Protocol.cpp gets a bit shorter

Sorry for the giant patch, it's prety mechanical though

Reviewers: ilya-biryukov

Subscribers: klimek, cfe-commits

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

llvm-svn: 319478
2017-11-30 21:32:29 +00:00
Yan Zhang 9ecb33edbe add new check to find NSError init invocation
Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 319460
2017-11-30 19:05:09 +00:00
Yan Zhang 8c348b3338 add new check to find NSError init invocation
Summary:
This check will find out improper initialization of NSError objects.

According to Apple developer document, we should always use factory method errorWithDomain:code:userInfo: to create new NSError objects instead of [NSError alloc] init]. Otherwise it will lead to a warning message during runtime in Xcode.

The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 319459
2017-11-30 19:05:08 +00:00
Eugene Zelenko ca3563ca73 [Documentation] Sort Clang-tidy changes next way: new modules, new checks, renamed checks, extended checks, new check aliases.
Sort checks in each section alphabetically.

llvm-svn: 319369
2017-11-29 22:17:39 +00:00
Alexander Kornienko ac4fe48caa [clang-tidy] make readability-simplify-bool-expr completely ignore macros
llvm-svn: 319325
2017-11-29 17:16:09 +00:00
Sam McCall 38a0491c68 [clangd] Simplify common JSON-parsing patterns in Protocol.
Summary:
This makes the parse() functions about as short as they can be given the
current signature, and moves all array-traversal etc code to a
central location.

We keep the ability to distinguish between optional and required fields:
and we don't propagate parse errors for optional fields.

I've made most fields required per the LSP spec - the looseness we had
here was mostly a historical accident I think.

Reviewers: ioeric

Subscribers: klimek, cfe-commits, ilya-biryukov

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

llvm-svn: 319309
2017-11-29 11:36:46 +00:00
Aaron Ballman d3d78b903a Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues with the Fuschia and Zircon coding guidelines (https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md). Adds the first of such checkers, which detects when default arguments are declared in a function declaration or when default arguments are used at call sites.
Patch by Julie Hockett

llvm-svn: 319225
2017-11-28 21:09:25 +00:00
Alexander Kornienko 1bfcba8cea [clang-tidy] Move more checks from misc- to performance-
Summary:
rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor

Reviewers: hokein, xazax.hun

Reviewed By: xazax.hun

Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits

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

llvm-svn: 319183
2017-11-28 16:41:03 +00:00
Malcolm Parsons 91e2c2addc [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw
Summary:
The readability-else-after-return check was not warning about
an else after a throw of an exception that had arguments that needed
to be cleaned up.

Reviewers: aaron.ballman, alexfh, djasper

Reviewed By: aaron.ballman

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

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

llvm-svn: 319174
2017-11-28 14:57:47 +00:00
Gabor Horvath 61d39595b4 [clang-tidy] Fix tests for ReplaceRandomShuffleCheck
Patch by: Daniel Kolozsvari!

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

llvm-svn: 319170
2017-11-28 13:54:52 +00:00
Sam McCall ec109029b1 [clangd] Switch from YAMLParser to JSONExpr
Summary:
 - Converted Protocol.h parse() functions to take JSON::Expr.
   These no longer detect and log unknown fields, as this is not that
   useful and no longer free.
   I haven't changed the error handling too much: fields that were
   treated as optional before are still optional, even when it's wrong.
   Exception: object properties with the wrong type are now ignored.
 - Made JSONRPCDispatcher parse using json::parse
 - The bug where 'method' must come before 'params' in the stream is
 fixed as a side-effect. (And the same bug in executeCommand).
 - Some parser crashers fixed as a side effect.
   e.g. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3890
 - The debug stream now prettyprints the input messages with --pretty.
 - Request params are attached to traces when tracing is enabled.
 - Fixed some bugs in tests (errors tolerated by YAMLParser, and
 off-by-ones in Content-Length that our null-termination was masking)
 - Fixed a random double-escape bug in ClangdLSPServer (it was our last
 use of YAMLParser!)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 319159
2017-11-28 09:37:43 +00:00
Sam McCall 1bb272bc74 [clangd] Add missing (but documented!) JSONExpr typed accessors
Summary:
Noticed this when I tried to port the Protocol.h parsers.
And tests for the inspect API, which caught a small bug.

Reviewers: ioeric

Subscribers: ilya-biryukov

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

llvm-svn: 319157
2017-11-28 09:25:09 +00:00
Kevin Funk 08c2f0fabb run-clang-tidy: Use check_call instead of check_output
Summary:
Streamlines the output under Python 3.x.

Before:
```
b'Enabled checks:\n    clang-analyzer-apiModeling.google.GTest\n ...
```

After:
```
Enabled checks:
    clang-analyzer-apiModeling.google.GTest
...
```

Reviewers: cfe-commits, alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere

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

Change-Id: I6287104bc73926ae6d0f66c15c250c3cb44bee33
llvm-svn: 319148
2017-11-28 07:17:01 +00:00
Aaron Ballman c566139632 Add an option to misc-move-const-arg to not diagnose on trivially copyable types.
Patch by Oleg Smolsky

llvm-svn: 319111
2017-11-27 22:59:33 +00:00
Yan Zhang 2f20b36cc3 add new check to find OSSpinlock usage
Summary:
This check finds the use of methods related to OSSpinlock in Objective-C code, which should be deprecated due to livelock issues.
The following method call will be detected:

- OSSpinlockLock()
- OSSpinlockTry()
- OSSpinlockUnlcok()

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 319098
2017-11-27 21:30:10 +00:00
Alexander Kornienko 1f71b91254 [clang-tidy] Rename qualified references to check class + support inconsistent names
llvm-svn: 319062
2017-11-27 17:59:26 +00:00
Ben Hamilton 31ef2b43fd [clang-tools-extra] Fix small typo in docs/ReleaseNotes.rst
Summary:
This is mainly a test diff to check the new Herald rule I
added in LLVM Phabricator to automatically Cc: cfe-commits on all
clang-tools-extra diffs.

Reviewers: Wizard, hokein, klimek

Reviewed By: Wizard

Subscribers: dlj, bkramer, sammccall

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

llvm-svn: 319040
2017-11-27 15:58:26 +00:00
Ben Hamilton 5d7a80eea9 [clang-tools-extra] Set up .arcconfig to point to new Diffusion CTE repository
Summary:
I'm testing out a new Diffusion repository `CTE`:

https://reviews.llvm.org/source/clang-tools-extra/

This explicitly updates clang-tools-extra's `.arcconfig` to point to
the new `CTE` repository in Diffusion, which will let us set up Herald
rules, etc.

Reviewers: klimek, sammccall

Reviewed By: sammccall

Subscribers: bkramer, dlj

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

llvm-svn: 319039
2017-11-27 15:58:25 +00:00
Alexander Kornienko 948a915924 [clang-tidy] Fix link error in clang-tidy after the recent check renames.
llvm-svn: 319034
2017-11-27 15:17:13 +00:00
Gabor Horvath 250c40dc26 [clang-tidy] Misc redundant expressions check updated for overloaded operators
Patch by: Lilla Barancsuk

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

llvm-svn: 319033
2017-11-27 15:05:24 +00:00
Alexander Kornienko 6e39e68983 [clang-tidy] Move checks from misc- to performance-
Summary:
rename_check.py misc-move-constructor-init performance-move-constructor-init
rename_check.py misc-inefficient-algorithm performance-inefficient-algorithm

Reviewers: hokein, aaron.ballman

Reviewed By: hokein, aaron.ballman

Subscribers: aaron.ballman, mgorny, xazax.hun, cfe-commits

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

llvm-svn: 319023
2017-11-27 13:06:28 +00:00
Benjamin Kramer 2d4f142726 Make helper function static. NFC.
llvm-svn: 319022
2017-11-27 12:48:26 +00:00
Alexander Kornienko 9332714361 [clang-tidy] readability-non-const-parameter fixes should update all declarations
Fixes http://llvm.org/PR34410.

llvm-svn: 319021
2017-11-27 12:42:04 +00:00
Alexander Kornienko 1d8fa7ff3f [clang-tidy] Fix link error (http://llvm.org/PR35417).
llvm-svn: 318972
2017-11-25 08:52:42 +00:00
Alexander Kornienko b43950d4a1 [clang-tidy] Actually fix header guard handling in scripts
llvm-svn: 318971
2017-11-25 08:49:04 +00:00
Simon Pilgrim 116e3b3ca0 Fix MSVC double-float implicit truncation warning. NFCI
llvm-svn: 318961
2017-11-24 18:18:42 +00:00
Alexander Kornienko a616a55c98 [clang-tidy] rename_check.py: fix header guard handling
llvm-svn: 318951
2017-11-24 14:33:06 +00:00
Alexander Kornienko d4ac4afda7 [clang-tidy] Move a few more checks from misc to bugprone.
Summary:
clang_tidy/rename_check.py misc-assert-side-effect bugprone-assert-side-effect
clang_tidy/rename_check.py misc-bool-pointer-implicit-conversion bugprone-bool-pointer-implicit-conversion
clang_tidy/rename_check.py misc-fold-init-type bugprone-fold-init-type
clang_tidy/rename_check.py misc-forward-declaration-namespace bugprone-forward-declaration-namespace
clang_tidy/rename_check.py misc-inaccurate-erase bugprone-inaccurate-erase
clang_tidy/rename_check.py misc-move-forwarding-reference bugprone-move-forwarding-reference
clang_tidy/rename_check.py misc-multiple-statement-macro bugprone-multiple-statement-macro
clang_tidy/rename_check.py misc-use-after-move bugprone-use-after-move
clang_tidy/rename_check.py misc-virtual-near-miss bugprone-virtual-near-miss

Manually fixed a reference to UseAfterMoveCheck in the hicpp module.
Manually fixed header guards.

Reviewers: hokein

Reviewed By: hokein

Subscribers: nemanjai, mgorny, javed.absar, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 318950
2017-11-24 14:16:29 +00:00
Ilya Biryukov 5fc214ec31 [clangd] Sort list of sources in CMakeLists.txt. NFC
llvm-svn: 318946
2017-11-24 13:13:41 +00:00
Ilya Biryukov 2660cc96dd [clangd] Ensure preamble outlives the AST
Summary:
In-memory preambles will not be copied anymore, so we need to make
sure they outlive the AST.

Reviewers: bkramer, sammccall, klimek

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 318944
2017-11-24 13:04:21 +00:00
Alexander Kornienko 4b9ee769ca [clang-tidy] rename_check.py misc-dangling-handle bugprone-dangling-handle
Reviewers: hokein

Reviewed By: hokein

Subscribers: mgorny, xazax.hun, cfe-commits

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

llvm-svn: 318941
2017-11-24 09:52:05 +00:00
Sam McCall 9cfd9c9a9b [clangd] Tracing improvements
Summary:
[clangd] Tracing improvements

Compose JSON using JSONExpr
Allow attaching metadata to spans (and avoid it if tracing is off)
Attach IDs and responses of JSON RPCs to their spans

The downside is that large responses make the trace viewer sluggish.
We should make our responses less huge :-) Or fix trace viewer.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 318928
2017-11-23 17:12:04 +00:00
Sam McCall b8d548a3de [clangd] Make completion scores use 0-1 floats internally.
Summary:
This scale is much easier to mix with other signals, such as fuzzy match strength.
Mostly NFC, but it does reorder some low-priority items that get folded together at a score of 0 (see completion-qualifiers.test).
Removed the exact sortText from the testcases, because it's the ranking that we want to test.

Reviewers: hokein

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 318927
2017-11-23 17:09:04 +00:00
Alexander Kornienko 6f67bcbb93 [clang-tidy] rename_check.py misc-argument-comment bugprone-argument-comment
Summary: + manually convert the unit test to lit test.

Reviewers: hokein

Reviewed By: hokein

Subscribers: mgorny, xazax.hun, cfe-commits

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

llvm-svn: 318926
2017-11-23 17:02:48 +00:00
Sam McCall adccab64f2 [clangd] Drop impossible completions (unavailable or inaccessible)
Summary: (There must be some reason why D38077 didn't just do this, but I don't get it!)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 318925
2017-11-23 16:58:22 +00:00
Alexander Kornienko 1c81d910bd [clang-tidy] rename_check.py: fix a bug in check presence detection
llvm-svn: 318922
2017-11-23 14:59:19 +00:00
Aaron Ballman 4cbef5e259 Fixing a typo; NFC.
llvm-svn: 318921
2017-11-23 14:57:24 +00:00
Alexander Kornienko ab0b81c5c2 [clang-tidy] rename_check.py: Update '=====...' line in the docs.
llvm-svn: 318918
2017-11-23 14:05:32 +00:00
Alexander Kornienko a3251bf24c [clang-tidy] rename_check.py misc-string-constructor bugprone-string-constructor
Summary:
Rename misc-string-constructor to bugprone-string-constructor +
manually update the lenght of '==='s in the doc file.

Reviewers: hokein, xazax.hun

Reviewed By: hokein, xazax.hun

Subscribers: mgorny, xazax.hun, cfe-commits

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

llvm-svn: 318916
2017-11-23 13:49:14 +00:00
Adam Balogh cb58b2bb81 [clang-tidy] Detect bugs in bugprone-misplaced-operator-in-strlen-in-alloc even in the case the allocation function is called using a constant function pointer
Detect bugs even if a function of the malloc() family is called using a constant pointer.

llvm-svn: 318913
2017-11-23 13:12:25 +00:00
Adam Balogh 0857ca489e [clang-tidy] Add support for operator new[] in check bugprone-misplaced-operator-in-strlen-in-alloc
The check now recognizes error cases like `new char[strlen(s + 1)]` and suggests
a fix in the format `new char[strlen(s) + 1]`.

llvm-svn: 318912
2017-11-23 12:56:23 +00:00
Adam Balogh 4c488975da [clang-tidy] Misplaced Operator in Strlen in Alloc
A possible error is to write `malloc(strlen(s+1))` instead of
`malloc(strlen(s)+1)`. Unfortunately the former is also valid syntactically,
but allocates less memory by two bytes (if `s` is at least one character long,
undefined behavior otherwise) which may result in overflow cases. This check
detects such cases and also suggests the fix for them.

Fix for r318906, forgot to add new files.

llvm-svn: 318907
2017-11-23 12:33:12 +00:00
Adam Balogh 2079defd8d [clang-tidy] Misplaced Operator in Strlen in Alloc
A possible error is to write `malloc(strlen(s+1))` instead of
`malloc(strlen(s)+1)`. Unfortunately the former is also valid syntactically,
but allocates less memory by two bytes (if s` is at least one character long,
undefined behavior otherwise) which may result in overflow cases. This check
detects such cases and also suggests the fix for them.

llvm-svn: 318906
2017-11-23 12:26:28 +00:00
Alexander Kornienko 6b334a212e clang-tidy/rename_check.py: support for moving between modules
llvm-svn: 318905
2017-11-23 12:08:53 +00:00
Benjamin Kramer 5a08bc891c [FindAllSymbols] Cache regexes, creating them is expensive
This is a bit annoying because LLVM regexes are always mutable to store
errors. Assert that there are never errors and fix broken hardcoded
regexes.

llvm-svn: 318840
2017-11-22 15:38:23 +00:00
Aaron Ballman feeb0b705c Silence some MSVC warnings about not all control paths returning a value; NFC.
llvm-svn: 318809
2017-11-21 22:24:13 +00:00
Sam McCall cc713cf885 [clangd] avoid divide by literal zero to satisfy msvc
llvm-svn: 318798
2017-11-21 19:37:35 +00:00
Sam McCall b67ce00e4d [clangd] use u8 strings in tests to avoid problems on windows
llvm-svn: 318793
2017-11-21 19:10:22 +00:00
Sam McCall 40f191f724 [clangd] Add JSON tests with invalid unicode
llvm-svn: 318791
2017-11-21 18:40:43 +00:00
Sam McCall bcfec0d6d5 [clangd] Include the right header for std::isxdigit
llvm-svn: 318782
2017-11-21 17:18:30 +00:00
Sam McCall d6836b8a67 [clangd] Satisfy GCC: 'changes meaning of Error'
llvm-svn: 318780
2017-11-21 17:02:24 +00:00
Sam McCall fb796d44f4 [clangd] Fix dumb && || bug from r318774
llvm-svn: 318778
2017-11-21 16:44:16 +00:00
Sam McCall adbaebc242 [clangd] Add parsing and value inspection to JSONExpr.
Summary:
This will replace the places where we're using YAMLParser to parse JSON now:
  - the new marshalling code (T::parse()) should handle fewer cases and require
    fewer explicit casts
  - we'll early-reject invalid JSON that YAMLParser accepts
  - we'll be able to fix protocol-parsing bugs caused by the fact that YAML can
    only parse forward

I plan to do the conversion as soon as this lands, but I don't want it in one
patch as the protocol.cpp changes are conflict-prone.

Reviewers: ioeric

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 318774
2017-11-21 16:00:53 +00:00
Erich Keane 0282966e38 Revert 318668, which is associated with a broken patch
llvm-svn: 318702
2017-11-20 22:10:28 +00:00
Jonas Toth f03f1fee69 [clang-tidy] revert hicpp-multiway-paths-covered
The address sanitizer found a stackoverflow with this patch.
There is no obvious fix. This patch will be reapplied when the problem
is found.

llvm-svn: 318670
2017-11-20 18:01:35 +00:00
Erich Keane 991447d6f8 extra test modifications for D34158
When adding support for D34158 which changes preprocessed output, I needed to 
make tiny test corrections for these. Adding the option -ffreestanding 
suppresses the new behavior, and that's the change I made to fix the tests.

Patch By: mibintc

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

llvm-svn: 318668
2017-11-20 17:57:20 +00:00
Jonas Toth 9b1dc4c275 [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
Summary:
This check searches for missing `else` branches in `if-else if`-chains and
missing `default` labels in `switch` statements, that use integers as condition.

It is very similar to -Wswitch, but concentrates on integers only, since enums are
already covered.

The option to warn for missing `else` branches is deactivated by default, since it is
very noise on larger code bases.

Running it on LLVM:
{F5354858} for default configuration
{F5354866} just for llvm/lib/Analysis/ScalarEvolution.cpp, the else-path checker is very noisy!

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: aaron.ballman

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

Tags: #clang-tools-extra

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

llvm-svn: 318600
2017-11-18 19:48:33 +00:00
Ilya Biryukov 11a0252888 [clangd] Release the old preamble before building a new one.
llvm-svn: 318544
2017-11-17 19:05:56 +00:00
Gabor Horvath 024d0b3bb9 [clang-tidy] Fix an oversight after renaming a check
llvm-svn: 318523
2017-11-17 12:28:58 +00:00
Gabor Horvath d984e33b1e [clang-tidy] Add a check for undelegated copy of base classes
Finds copy constructors where the constructor don't call
the copy constructor of the base class.

```
class X : public Copyable {
    X(const X &other) {} // Copyable(other) is missing
};
```

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

llvm-svn: 318522
2017-11-17 12:23:30 +00:00
Ilya Biryukov e9eb7f0cb8 [clangd] Use in-memory preambles in clangd.
Reviewers: klimek, bkramer, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 318412
2017-11-16 16:25:18 +00:00
Yan Zhang 9994581395 add check to avoid throwing objc exception according to Google Objective-C guide
Summary:
This is a small check to avoid throwing objc exceptions.
In specific it will detect the usage of @throw statement and throw warning.

Reviewers: hokein, benhamilton

Reviewed By: hokein, benhamilton

Subscribers: cfe-commits, mgorny

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

llvm-svn: 318366
2017-11-16 01:28:29 +00:00
Sam McCall afbe849d77 [clangd] Loosen more brittle tests
llvm-svn: 318339
2017-11-15 21:50:53 +00:00
Sam McCall e90fd06723 [clangd] Revert broken r318329 and disable tests on PS4
(Clearly this is not a permanent solution)

llvm-svn: 318337
2017-11-15 21:33:56 +00:00
Sam McCall b73593f2aa [clangd] Fix flag name from r318327
llvm-svn: 318329
2017-11-15 20:10:14 +00:00
Sam McCall 118a7a9986 [clangd] Try to unbreak tests on PS4 by targeting PC explicitly
llvm-svn: 318327
2017-11-15 19:38:09 +00:00
Ilya Biryukov 9e11c4c957 [clangd] clang-format the source code. NFC.
llvm-svn: 318317
2017-11-15 18:04:56 +00:00
Sam McCall 3d9e02466e [clangd] Fix time units in clangd performance trace
llvm-svn: 318316
2017-11-15 17:53:46 +00:00
Sam McCall a40371bcb6 [clangd] Support returning a limited number of completion results.
Summary:
All results are scored, we only process CodeCompletionStrings for the winners.
We now return CompletionList rather than CompletionItem[] (both are valid).
sortText is now based on CodeCompletionResult::orderedName (mostly the same).

This is the first clangd-only completion option, so plumbing changed.
It requires a small clangd patch (exposing CodeCompletionResult::orderedName).

(This can't usefully be enabled yet: we don't support server-side filtering)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 318287
2017-11-15 09:16:29 +00:00
Ben Hamilton 52161a5abd add new check for property declaration
Summary:
This check finds property declarations in Objective-C files that do not follow the pattern of property names in Apple's programming guide. The property name should be in the format of Lower Camel Case or with some particular acronyms as prefix.

Example:
@property(nonatomic, assign) int lowerCamelCase;

@property(nonatomic, strong) NSString *URLString;

Test plan:  ninja check-clang-tools

Reviewers: benhamilton, hokein

Reviewed By: hokein

Subscribers: cfe-commits, mgorny

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

llvm-svn: 318117
2017-11-13 23:54:31 +00:00
Sam McCall 39f457b36f [clangd] Fix compilation database detection
llvm-svn: 317838
2017-11-09 21:45:27 +00:00
Haojian Wu 345099ca19 [clangd] Add rename support.
Summary:
Make clangd handle "textDocument/rename" request. The rename
functionality comes from the "local-rename" sub-tool of clang-refactor.

Currently clangd only supports local rename (only symbol occurrences in
the main file will be renamed).

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

Subscribers: cfe-commits, ioeric, arphaman, mgorny

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

llvm-svn: 317780
2017-11-09 11:30:04 +00:00
Sam McCall 99beabf7ed Relax definitions.test to accept windows file paths.
Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 317692
2017-11-08 13:52:21 +00:00
Krasimir Georgiev 8fc64a7732 [clang-tidy] Add a note about modernize-replace-random-shuffle
Summary:
This adds a note warning the users that the way the suggested fix seeds the
random number generator is poor.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits, xazax.hun

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

llvm-svn: 317689
2017-11-08 13:28:53 +00:00
Sam McCall df29d899e8 [clangd] tolerate windows filepaths in tests
llvm-svn: 317686
2017-11-08 12:25:00 +00:00
Sam McCall 28ef7d662f [clangd] loosen tests for flag-dependence revealed by r317670
llvm-svn: 317673
2017-11-08 09:15:01 +00:00
Sam McCall c78ccbdefb [clangd] Sort completion results.
Summary:
This is (probably) not required by LSP, but at least one buggy client wants it.
It also simplifies some tests - changed a few completion tests to use -pretty.

Reviewers: hokein, malaperle

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 317670
2017-11-08 07:44:12 +00:00
Douglas Yung 76036fce25 Fix compile issue on MSVC.
llvm-svn: 317642
2017-11-08 00:29:42 +00:00
Marc-Andre Laperle ba070108a6 [clangd] Fix opening declarations located in non-preamble inclusion
Summary:
When an inclusion is not processed as part of the preamble, its path is
not made into an absolute path as part of the precompiled header code
(adjustFilenameForRelocatableAST in ASTWriter.cpp). Because of this,
when we convert a Decl location to retrieve the file name with
FileEntry->getName(), it is possible for this path to be relative.
Instead, we should try to use tryGetRealPathName first which returns
an absolute path.

Fixes bug 35217.

Reviewers: sammccall, ilya-biryukov, rwols, Nebiroth

Reviewed By: sammccall

Subscribers: cfe-commits, ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 317585
2017-11-07 16:16:45 +00:00
Sam McCall 0930ab094b [clangd] Fix initialize capabilities response
llvm-svn: 317584
2017-11-07 15:49:35 +00:00
Sam McCall 784e88351b [clangd] MSVC - third time's the charm
llvm-svn: 317581
2017-11-07 14:59:21 +00:00
Sam McCall 94362c61c6 [clangd] don't crash on invalid JSON-RPC ID
llvm-svn: 317580
2017-11-07 14:45:31 +00:00
Sam McCall 99633ec527 [clangd] another try at fixing MSVC
llvm-svn: 317575
2017-11-07 14:14:58 +00:00
Gabor Horvath ec87e17c84 [clang-tidy] Misc redundant expressions checker updated for macros
Redundant Expression Checker is updated to be able to detect expressions that
contain macros. Also, other small details are modified to improve the current
implementation.

The improvements in detail are as follows:
* Binary and ternary operator expressions containing two constants, with at
least one of them from a macro, are detected and tested for redundancy.

Macro expressions are treated somewhat differently from other expressions,
because the particular values of macros can vary across builds.
They can be considered correct and intentional, even if macro values equal,
produce ranges that exclude each other or fully overlap, etc. 

* The code structure is slightly modified: typos are corrected,
comments are added and some functions are renamed to improve comprehensibility,
both in the checker and the test file. A few test cases are moved to another
function.

* The checker is now able to detect redundant CXXFunctionalCastExprs as well.
A corresponding test case is added.

Patch by: Lilla Barancsuk!

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

llvm-svn: 317570
2017-11-07 13:17:58 +00:00
Haojian Wu 2375c926f4 [clangd] Add ErrorCode enum class.
Summary: Avoid using magic number in the code everywhere.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 317559
2017-11-07 10:21:02 +00:00
Sam McCall c2055486eb [clangd] fix MSVC build errors
llvm-svn: 317553
2017-11-07 08:57:54 +00:00
Haojian Wu 5529a244e1 Add new check in google module for Objective-C code to ensure global variables follow the naming convention of Google Objective-C Style Guide
Summary:
This is a new checker for objc files in clang-tidy.

The new check finds global variable declarations in Objective-C files that are not follow the pattern of variable names in Google's Objective-C Style Guide.

All the global variables should follow the pattern of "g[A-Z].*" (variables) or "k[A-Z].*" (constants). The check will suggest a variable name that follows the pattern
if it can be inferred from the original name.

Patch by Yan Zhang!

Reviewers: benhamilton, hokein, alexfh

Reviewed By: hokein

Subscribers: Eugene.Zelenko, mgorny

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

llvm-svn: 317552
2017-11-07 08:53:37 +00:00
NAKAMURA Takumi e02398022d ClangdTests/JSONExprTests.cpp: Appease g++-4.8 to move raw string literal out of macro arg.
llvm-svn: 317538
2017-11-07 02:18:24 +00:00
Sam McCall 0ed8d48c4b [clangd] Squash namespace warning
llvm-svn: 317487
2017-11-06 15:50:35 +00:00
Sam McCall dd0566bb2c Adds a json::Expr type to represent intermediate JSON expressions.
Summary:
This form can be created with a nice clang-format-friendly literal syntax,
and gets escaping right. It knows how to call unparse() on our Protocol types.
All the places where we pass around JSON internally now use this type.

Object properties are sorted (stored as std::map) and so serialization is
canonicalized, with optional prettyprinting (triggered by a -pretty flag).
This makes the lit tests much nicer to read and somewhat nicer to debug.
(Unfortunately the completion tests use CHECK-DAG, which only has
line-granularity, so pretty-printing is disabled there. In future we
could make completion ordering deterministic, or switch to unittests).

Compared to the current approach, it has some efficiencies like avoiding copies
of string literals used as object keys, but is probably slower overall.
I think the code/test quality benefits are worth it.

This patch doesn't attempt to do anything about JSON *parsing*.
It takes direction from the proposal in this doc[1], but is limited in scope
and visibility, for now.
I am of half a mind just to use Expr as the target of a parser, and maybe do a
little string deduplication, but not bother with clever memory allocation.
That would be simple, and fast enough for clangd...
[1] https://docs.google.com/document/d/1OEF9IauWwNuSigZzvvbjc1cVS1uGHRyGTXaoy3DjqM4/edit

+cc d0k so he can tell me not to use std::map.

Reviewers: ioeric, malaperle

Subscribers: bkramer, ilya-biryukov, mgorny, klimek

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

llvm-svn: 317486
2017-11-06 15:40:30 +00:00
Gabor Horvath 8de900ae1f [clang-tidy] Support relative paths in run-clang-tidy.py
Unfortunately, these python scripts are not tested currently. I did the testing
manually on LLVM by editing the CMake generated compilation database to
contain relative paths for some of the files. 

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

llvm-svn: 317468
2017-11-06 10:36:02 +00:00
Eric Liu b0b8f03874 Use ToolExecutor framework in the sample tool-template.
llvm-svn: 317333
2017-11-03 16:03:56 +00:00
Marc-Andre Laperle e7ec16aaa6 [clangd] Handle clangd.applyFix server-side
Summary:
When the user selects a fix-it (or any code action with commands), it is
possible to let the client forward the selected command to the server.
When the clangd.applyFix command is handled on the server, it can send a
workspace/applyEdit request to the client. This has the advantage that
the client doesn't explicitly have to know how to handle
clangd.applyFix. Therefore, the code to handle clangd.applyFix in the VS
Code extension (and any other Clangd client) is not required anymore.

Reviewers: ilya-biryukov, sammccall, Nebiroth, hokein

Reviewed By: hokein

Subscribers: ioeric, hokein, rwols, puremourning, bkramer, ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 317322
2017-11-03 13:39:15 +00:00
Ben Hamilton 82b077db3a Update release notes (check SVN commit-after-approval access)
Summary:
I was just granted commit-after-approval access to SVN,
and @clattner recommended I try a test commit.

So, this tweaks the release notes as a test.

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: Wizard

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

llvm-svn: 317261
2017-11-02 20:00:17 +00:00
Sam McCall 32995b3056 Fix clangd test on platforms where get_thread_name does nothing.
llvm-svn: 317194
2017-11-02 09:48:55 +00:00
Sam McCall 8567cb3720 Performance tracing facility for clangd.
Summary:
This lets you visualize clangd's activity on different threads over time,
and understand critical paths of requests and object lifetimes.
The data produced can be visualized in Chrome (at chrome://tracing), or
in a standalone copy of catapult (http://github.com/catapult-project/catapult)

This patch consists of:
 - a command line flag "-trace" that causes clangd to emit JSON trace data
 - an API (in Trace.h) allowing clangd code to easily add events to the stream
 - several initial uses of this API to capture JSON-RPC requests, builds, logs

Example result: https://photos.app.goo.gl/12L9swaz5REGQ1rm1

Caveats:
 - JSON serialization is ad-hoc (isn't it everywhere?) so the API is
   limited to naming events rather than attaching arbitrary metadata.
   I'd like to fix this (I think we could use a JSON-object abstraction).
 - The recording is very naive: events are written immediately by
   locking a mutex. Contention on the mutex might disturb performance.
 - For now it just traces instants or spans on the current thread.
   There are other things that make sense to show (cross-thread flows,
   non-thread resources such as ASTs). But we have to start somewhere.

Reviewers: ioeric, ilya-biryukov

Subscribers: cfe-commits, mgorny

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

llvm-svn: 317193
2017-11-02 09:21:51 +00:00
Shoaib Meenai 99cfb67ad2 [clangd] Remove redundant install
`add_clang_tool` already adds the install command, so the one here is
redundant.

llvm-svn: 317187
2017-11-02 05:02:24 +00:00
Shoaib Meenai 09d4efee52 [clang-tidy] Clean up installation rules
An installation rule for the executable with the correct component is
already created by `add_clang_tool`, so the rule in this file is
redundant. Correct the installation component for the Python scripts so
that they also get installed by `install-clang-tidy`.

llvm-svn: 317155
2017-11-02 01:48:20 +00:00
Shoaib Meenai c40419d94b [clang-reorder-fields] Switch to add_clang_tool
`add_clang_tool` invokes `add_clang_executable` internally, but it also
takes care of setting up the install rule. It also adds an `install-*`
build target, which is required for `LLVM_DISTRIBUTION_COMPONENTS`.

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

llvm-svn: 317149
2017-11-02 01:10:05 +00:00
Simon Pilgrim 948c0bcbd6 Add LLVM_FALLTHROUGH to silence warning. NFCI.
llvm-svn: 317083
2017-11-01 09:22:03 +00:00
Benjamin Kramer 5349eedfdd [clangd] Fix clang-tidy warnings.
No functionality change intended.

llvm-svn: 316832
2017-10-28 17:32:56 +00:00
Benjamin Kramer 1d053791a1 [clangd] Don't crash on extremely large JSON messages.
Found by clangd-fuzzer.

llvm-svn: 316774
2017-10-27 17:06:41 +00:00
Benjamin Kramer decd8a702a [clangd] Harden clangd a bit against garbage input.
There can be nullptrs here if the YAML fails to parse. Found by
clangd-fuzzer!

llvm-svn: 316770
2017-10-27 16:33:15 +00:00
Jonas Toth 8ba28c7200 [clang-tidy] Fix bug 34845, offending standard bitmask types
Summary:
The C++ standard allows implementations to choose the underlying type for
bitmask types (e.g. std::ios_base::openmode). MSVC implemented some of them
as signed integers resulting in warnings for usual code like
`auto dd = std::ios_base::badbit | std::ios_base::failbit;`

These false positives were reported in https://bugs.llvm.org/show_bug.cgi?id=34845

The fix allows bitwise |,&,^ for known standard bitmask types under the condition
that both operands are such bitmask types.
Shifting and bitwise complement are still forbidden.

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun

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

llvm-svn: 316767
2017-10-27 14:44:08 +00:00
Haojian Wu e010406e28 [clang-tidy ObjC] [3/3] New check objc-forbidden-subclassing
Summary:
This is part 3 of 3 of a series of changes to improve Objective-C
linting in clang-tidy.

This adds a new clang-tidy check `objc-forbidden-subclassing` which
ensures clients do not create subclasses of Objective-C classes which
are not designed to be subclassed.

(Note that for code under your control, you should use
__attribute__((objc_subclassing_restricted)) instead -- this
is intended for third-party APIs which cannot be modified.)

By default, the following classes (which are publicly documented
as not supporting subclassing) are forbidden from subclassing:

ABNewPersonViewController
ABPeoplePickerNavigationController
ABPersonViewController
ABUnknownPersonViewController
NSHashTable
NSMapTable
NSPointerArray
NSPointerFunctions
NSTimer
UIActionSheet
UIAlertView
UIImagePickerController
UITextInputMode
UIWebView

Clients can set a CheckOption
`objc-forbidden-subclassing.ClassNames` to a semicolon-separated
list of class names, which overrides this list.

Test Plan: `ninja check-clang-tools`

Patch by Ben Hamilton!

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: saidinwot, Wizard, srhines, mgorny, xazax.hun

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

llvm-svn: 316744
2017-10-27 07:41:36 +00:00
Benjamin Kramer ee19f16633 [clangd] Report an error on findDefinitions/signatureHelp on an unopened file instead of crashing.
Found by clangd-fuzzer.

llvm-svn: 316659
2017-10-26 12:28:13 +00:00
Benjamin Kramer b560a9a1b8 [clangd] Don't crash on empty textDocument/didChange.
Found by clangd-fuzzer.

llvm-svn: 316652
2017-10-26 10:36:20 +00:00
Benjamin Kramer 74a1895422 [clangd] Don't use /// for non-doxygen comments.
llvm-svn: 316650
2017-10-26 10:07:04 +00:00
Benjamin Kramer 09113ae2c5 [clangd] Add a simple fuzzer. It crashes a lot :)
llvm-svn: 316649
2017-10-26 10:03:11 +00:00
Haojian Wu d2825825f8 [clang-tidy ObjC] [2/3] Support non-C++ files in ClangTidyTest
Summary:
This is part 2 of 3 of a series of changes to improve
Objective-C linting in clang-tidy.

Currently, `clang::tidy::test::runCheckOnCode()` assumes all files
are C++ and unconditionally adds `-std=c++11` to the list of
`clang-tidy` options.

This updates the logic to check the extension of the source file
and only add `-std=c++11` if the extension indicates C++ or
Objective-C++.

Depends On D39188

Test Plan:

  ninja ClangTidyTests && \
  ./tools/clang/tools/extra/unittests/clang-tidy/ClangTidyTests

Patch by Ben Hamilton!

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: Wizard

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

llvm-svn: 316645
2017-10-26 08:37:25 +00:00
Haojian Wu abcd64ccbf [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checks
Summary:
This is part 1 of 3 of a series of changes to improve Objective-C
linting in clang-tidy.

This introduces a new clang-tidy module, `objc`, specifically for
Objective-C / Objective-C++ checks.

The module is currently empty; D39142 adds the first check.

Test Plan: `ninja check-clang-tools`

Patch by Ben Hamilton!

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: Wizard, mgorny

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

llvm-svn: 316643
2017-10-26 08:23:20 +00:00
Alex Lorenz fbd17e17f5 Handle PragmaDebug in PPChainedCallbacks
The test is in clang-tools-extra/test/pp-trace

llvm-svn: 316621
2017-10-25 22:01:23 +00:00
Ilya Biryukov 90bbcfd350 [clangd] Added a callback-based codeComplete in clangd.
Reviewers: klimek, bkramer, sammccall, krasimir

Reviewed By: sammccall

Subscribers: rwols, cfe-commits

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

llvm-svn: 316565
2017-10-25 09:35:10 +00:00
Ilya Biryukov 0d9b8a3ee8 [clangd] Handle exit notification (proper shutdown)
Summary:
This changes the onShutdown handler to do essentially nothing (for now), and
instead exits the runloop when we receive the exit notification from the client.

Some clients may wait on the reply from the shutdown request before sending an
exit notification. If we exit the runloop already in the shutdown request, a
client might block forever.

This also gives us the opportunity to do any global cleanups and/or
serializations of PCH preambles to disk, but I've left that out for now.

See the LSP protocol documentation for details.

Reviewers: malaperle, krasimir, bkramer, sammccall, ilya-biryukov

Reviewed By: malaperle, sammccall, ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 316564
2017-10-25 08:45:41 +00:00
Ilya Biryukov b080cb155b [clangd] Allow to pass code completion opts to ClangdServer.
Reviewers: bkramer, krasimir, sammccall

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

llvm-svn: 316327
2017-10-23 14:46:48 +00:00
Ilya Biryukov a7e3763a2b [clangd] Updated outdated test comment. NFC.
llvm-svn: 316323
2017-10-23 14:08:52 +00:00
Ilya Biryukov 01e3bf8afd [clangd] Report proper kinds for 'Keyword' and 'Snippet' completion items.
Reviewers: rwols, malaperle, krasimir, bkramer, sammccall

Reviewed By: rwols, sammccall

Subscribers: klimek, cfe-commits

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

llvm-svn: 316311
2017-10-23 06:06:21 +00:00
NAKAMURA Takumi f793fa3335 clang-tidy: Fix deps.
llvm-svn: 316260
2017-10-21 11:02:30 +00:00
Zachary Turner afc4b3857b [clang-tidy] Remove MSVC inline assembly test from cross-plat test.
This originally started out here in dev, but I moved it to another
file when it became clear this wouldn't work on non-Windows.
Unfortunately I forgot to remove it from this file.  Test is still
live, just in another source file.

llvm-svn: 316247
2017-10-20 23:09:20 +00:00
Zachary Turner fbdca1daec [clang-tidy] Don't error on MS-style inline assembly.
To get MS-style inline assembly, we need to link in the various
backends.  Some other clang tools already do this, and this issue
has been raised with clang-tidy several times, indicating there
is sufficient desire to make this work.

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

llvm-svn: 316246
2017-10-20 23:00:51 +00:00
Haojian Wu 49b8e94478 [clang-tidy] Add missing test files in r316090.
llvm-svn: 316221
2017-10-20 17:54:53 +00:00
Jonas Toth f00509c3a5 [clang-tidy] Fix 32bit platform MSVC
The previous fix only worked for 64bit MSVC, this one should fix all different
architectures.

llvm-svn: 316094
2017-10-18 16:40:19 +00:00
Jonas Toth 876b8ce52f [clang-tidy] Fix buildbot for msvc
The testcase defined `FILE` as `unsigned long`, but MSVC expect `unsigned long long`.

llvm-svn: 316093
2017-10-18 16:28:06 +00:00
Jonas Toth c9aea86e6a [clang-tidy] introduce legacy resource functions to 'cppcoreguidelines-owning-memory'
Summary:
This patch introduces support for legacy C-style resource functions that must obey
the 'owner<>' semantics.

- added legacy creators like malloc,fopen,...
- added legacy consumers like free,fclose,...

This helps codes that mostly benefit from owner:
Legacy, C-Style code that isn't feasable to port directly to RAII but needs a step in between
to identify actual resource management and just using the resources.

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: nemanjai, JDevlieghere, xazax.hun, kbarton

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

llvm-svn: 316092
2017-10-18 16:14:15 +00:00
Haojian Wu 9e0f7f1a23 Support Objective-C/C++ source files in check_clang_tidy.py
check_clang_tidy.py currently only handles C and C++ source files.

This extends the logic to also handle Objective-C (.m) and
Objective-C++ (.mm) files.

However, by default, clang compiles .m/.mm files using Objective-C 1.0
syntax. Objective-C 2.0 has been the default in Xcode for about 10
years, and Objective-C Automatic Reference Counting (ARC) for about 6
years, so this enables both by default.

(Clients which actually want to test clang-tidy checks for Objective-C
 1.0 or non-ARC files can pass custom flags to check_clang_tidy.py
 after --, which will disable the Objective-C 2.0 and ARC flags).

I did not add logic to handle running clang-tidy on Objective-C header
files alone; they also use the .h file extension, so we'd need to
look inside their contents.

I included a new test to confirm the new behavior.

Depends On D38963

Patch by Ben Hamilton!

llvm-svn: 316090
2017-10-18 15:56:39 +00:00
Haojian Wu a08422e0e4 New -assume-filename=param to check_clang_tidy.py (like clang-format)
Summary:
Currently, check_clang_tidy.py includes logic to select default
clang flags based on the extension of the source filename passed
as the first argument.

Since the source filename might be a temporary or test file with an
arbitrary extension unrelated to the file type, this adds the ability
to override the logic the same way `clang-format`'s -assume-filename=
parameter does.

I included a test with a nonstandard file extension. I confirmed
when I modified the warning message that the new test failed,
and that it passed again when I restored the warning message.

Ran tests with:

% cmake -G Ninja /path/to/llvm
% ninja check-clang-tools

Patch by Ben Hamilton!

Reviewers: hokein, alexfh

Reviewed By: hokein

Subscribers: alexfh

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

llvm-svn: 316066
2017-10-18 07:48:40 +00:00
Eric Liu b583a7ead4 [change-namespace] do not change type locs in defaulted functions.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 315892
2017-10-16 08:20:10 +00:00
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
Ilya Biryukov 83ca8a2b71 [clangd] Run clang-format on ClangdUnit.cpp. NFC.
llvm-svn: 313749
2017-09-20 10:46:58 +00:00
Ilya Biryukov e5128f7e91 [clangd] Introduced Logger interface.
Summary: This fixes a bunch of logging-related FIXMEs.

Reviewers: bkramer, krasimir, malaperle

Reviewed By: malaperle

Subscribers: malaperle, klimek, cfe-commits, mgorny

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

llvm-svn: 313730
2017-09-20 07:24:15 +00:00
Marc-Andre Laperle 85dcce4d15 [clangd] Fix codeAction not decoded properly when sent from some clients
Summary:
Fix for bug https://bugs.llvm.org/show_bug.cgi?id=34559
Also log unknown fields instead of aborting the JSON parsing because it's
common that new optional fields are added either in new versions of the protocol
or extensions.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 313536
2017-09-18 15:02:59 +00:00
Zachary Turner ce92db13ea Resubmit "[lit] Force site configs to run before source-tree configs"
This is a resubmission of r313270.  It broke standalone builds of
compiler-rt because we were not correctly generating the llvm-lit
script in the standalone build directory.

The fixes incorporated here attempt to find llvm/utils/llvm-lit
from the source tree returned by llvm-config.  If present, it
will generate llvm-lit into the output directory.  Regardless,
the user can specify -DLLVM_EXTERNAL_LIT to point to a specific
lit.py on their file system.  This supports the use case of
someone installing lit via a package manager.  If it cannot find
a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or
invalid, then we print a warning that tests will not be able
to run.

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

llvm-svn: 313407
2017-09-15 22:10:46 +00:00
Alexander Kornienko 7b9f3e28cc [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets
Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34449

**Problem:**

Clang-tidy check misc-unused-parameters comments out parameter name omitting following characters (e.g. square brackets) what results in its complete removal. Compilation errors might occur after clang-tidy fix as well.

**Patch description:**

Changed removal range. The range should end after parameter name, not after whole parameter declarator (which might be followed by e.g. square brackets).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Pawel Maciocha!

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

llvm-svn: 313355
2017-09-15 11:28:28 +00:00
Zachary Turner 83dcb68468 Revert "[lit] Force site configs to run before source-tree configs"
This patch is still breaking several multi-stage compiler-rt bots.
I already know what the fix is, but I want to get the bots green
for now and then try re-applying in the morning.

llvm-svn: 313335
2017-09-15 02:56:40 +00:00
Douglas Yung d8e4ab3efd Fix refactoring missed in previous commit r313270 which resulted in an undefined variable being used.
llvm-svn: 313290
2017-09-14 19:51:26 +00:00
Zachary Turner a0e55b6403 [lit] Force site configs to be run before source-tree configs
This patch simplifies LLVM's lit infrastructure by enforcing an ordering
that a site config is always run before a source-tree config.

A significant amount of the complexity from lit config files arises from
the fact that inside of a source-tree config file, we don't yet know if
the site config has been run.  However it is *always* required to run
a site config first, because it passes various variables down through
CMake that the main config depends on.  As a result, every config
file has to do a bunch of magic to try to reverse-engineer the location
of the site config file if they detect (heuristically) that the site
config file has not yet been run.

This patch solves the problem by emitting a mapping from source tree
config file to binary tree site config file in llvm-lit.py. Then, during
discovery when we find a config file, we check to see if we have a
target mapping for it, and if so we use that instead.

This mechanism is generic enough that it does not affect external users
of lit. They will just not have a config mapping defined, and everything
will work as normal.

On the other hand, for us it allows us to make many simplifications:

* We are guaranteed that a site config will be executed first
* Inside of a main config, we no longer have to assume that attributes
  might not be present and use getattr everywhere.
* We no longer have to pass parameters such as --param llvm_site_config=<path>
  on the command line.
* It is future-proof, meaning you don't have to edit llvm-lit.in to add
  support for new projects.
* All of the duplicated logic of trying various fallback mechanisms of
  finding a site config from the main config are now gone.

One potentially noteworthy thing that was required to implement this
change is that whereas the ninja check targets previously used the first
method to spawn lit, they now use the second. In particular, you can no
longer run lit.py against the source tree while specifying the various
`foo_site_config=<path>` parameters.  Instead, you need to run
llvm-lit.py.

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

llvm-svn: 313270
2017-09-14 16:47:58 +00:00
Alexander Kornienko e5590927d6 [clang-tidy] fixed misc-unused-parameters omitting parameters default value
Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34450

**Problem:**

Clang-tidy check misc-unused-parameters omits parameter default value what results in its complete removal. Compilation errors might occur after clang-tidy fix.

**Patch description:**

Changed removal range. The range should end after parameter declarator, not after whole parameter declaration (which might contain a default value).

Reviewers: alexfh, xazax.hun

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Pawel Maciocha!

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

llvm-svn: 313150
2017-09-13 14:55:13 +00:00
Jonas Toth 6ccc1c342a [clang-tidy] Implement type-based check for `gsl::owner`
This check implements the typebased semantic of `gsl::owner`.
Meaning, that 
- only `gsl::owner` is allowed to get `delete`d
- `new` expression must be assigned to `gsl::owner`
- function calls that expect `gsl::owner` as argument, must get either an owner
  or a newly created and recognized resource (in the moment only `new`ed memory)
- assignment to `gsl::owner` must be either a resource or another owner
- functions returning an `gsl::owner` are considered as factories, and their result
  must be assigned to an `gsl::owner`
- classes that have an `gsl::owner`-member must declare a non-default destructor

There are some problems that occur when typededuction is in place.
For example `auto Var = function_that_returns_owner();` the type of `Var` will not be
an `gsl::owner`. This case is catched, and explicitly noted.

But cases like fully templated functions
```
template <typename T> 
void f(T t) { delete t; }
// ...
f(gsl::owner<int*>(new int(42)));
```
Will created false positive (the deletion is problematic), since the type deduction
removes the wrapping `typeAlias`.

Codereview in D36354

llvm-svn: 313067
2017-09-12 20:00:42 +00:00
Jonas Toth 8bfdc0b1cc [clang-tidy] Revert Implement type-based check for gsl::owner
This should unbreak the buildbot for visual studio 2015 for now.

llvm-svn: 313059
2017-09-12 18:35:54 +00:00
Jonas Toth a5d53274f3 [clang-tidy] Implement type-based check for `gsl::owner`
This check implements the typebased semantic of `gsl::owner`.
Meaning, that 
- only `gsl::owner` is allowed to get `delete`d
- `new` expression must be assigned to `gsl::owner`
- function calls that expect `gsl::owner` as argument, must get either an owner
  or a newly created and recognized resource (in the moment only `new`ed memory)
- assignment to `gsl::owner` must be either a resource or another owner
- functions returning an `gsl::owner` are considered as factories, and their result
  must be assigned to an `gsl::owner`
- classes that have an `gsl::owner`-member must declare a non-default destructor

There are some problems that occur when typededuction is in place.
For example `auto Var = function_that_returns_owner();` the type of `Var` will not be
an `gsl::owner`. This case is catched, and explicitly noted.

But cases like fully templated functions
```
template <typename T> 
void f(T t) { delete t; }
// ...
f(gsl::owner<int*>(new int(42)));
```
Will created false positive (the deletion is problematic), since the type deduction
removes the wrapping `typeAlias`.

Please give your comments :)

llvm-svn: 313043
2017-09-12 16:20:51 +00:00
Ilya Biryukov b33c15741b [clangd] Add support for snippet completions
Enhances CompletionItemsCollector in such a way that snippet
completions can be presented to the client. Enable snippet completion
items by specifying -enable-snippets while invoking the clangd
executable.

See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#completion-request
See: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/browser/snippet.md

Patch by Raoul Wols.

llvm-svn: 313029
2017-09-12 13:57:14 +00:00
Peter Szecsi 2087113f6c [clang-tidy] SuspiciousEnumUsageCheck bugfix
iThere is a reported bug on the checker not handling the some APSInt values
correctly: https://bugs.llvm.org/show_bug.cgi?id=34400

This patch aims to fix it.

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

llvm-svn: 313016
2017-09-12 09:40:13 +00:00
Vedant Kumar 5490afa6d8 [pp-trace] Update skipped source ranges in tests
Depends on D36642

llvm-svn: 312948
2017-09-11 20:47:45 +00:00
Roman Lebedev 728284dc39 [clang-tidy] FunctionSizeCheck: wrap FunctionASTVisitor into anon namespace, NFC
This check is relatively simple, and is often being used
as an example. I'm aware of at least two cases, when
simply copying the FunctionASTVisitor class to a new
check resulted in a rather unobvious segfault. Having it
in anonymous namespace prevents such a problem.

No functionality change, so i opted to avoid phabricator,
especially since clang-tidy reviews are seriously jammed.

llvm-svn: 312912
2017-09-11 13:12:31 +00:00
Jonas Toth a735803801 [clang-tidy] add more aliases for the hicpp module
This patch will introduce even more aliases for the hicpp-module to already existing
checks and is a follow up for D30383 finishing the other sections.
It fixes a forgotten highlight in hicpp-braces-around-statements.rst, too.

llvm-svn: 312901
2017-09-11 09:20:07 +00:00
Rafael Espindola d63b2f3996 Update for PrintHelpMessage not calling exit.
llvm-svn: 312769
2017-09-08 00:33:39 +00:00
Kevin Funk d331cb66f9 Make run-clang-tidy compatible with Python 3.x
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

Tags: #clang-tools-extra

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

Change-Id: I89a95d1e082e566e7e64c2a5ca4123c543e6b1be
llvm-svn: 312532
2017-09-05 12:36:33 +00:00
Ilya Biryukov 1fab4f8a59 clangd: Tolerate additional headers
Summary:
The language server protocol specified 2 headers (Content-Length and Content-Type), but does not specify their sequence. It specifies that an empty line ends
headers. Clangd has been updated to handle arbitrary sequences of headers, extracting only the content length.

Patch by puremourning (Ben Jackson).

Reviewers: bkramer, klimek, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits, ilya-biryukov

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

llvm-svn: 312483
2017-09-04 12:28:15 +00:00
Benjamin Kramer 6be49244b1 [cppcoreguidelines] Don't rely on SmallPtrSet iteration order.
The fixit emission breaks if the iteration order changes and also missed
to emit fixits for some edge cases.

llvm-svn: 312166
2017-08-30 20:18:40 +00:00
Jonas Toth bdefd0b859 [clang-tidy] fix buildbot
Use `signed char` instead of `char`.

llvm-svn: 312141
2017-08-30 17:21:41 +00:00
NAKAMURA Takumi 89e8d5e955 clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise.cpp: Appease *-win32 to add explicit triple.
llvm-svn: 312137
2017-08-30 16:34:51 +00:00
Jonas Toth 673dbd1aff [clang-tidy] Improve hicpp-exception-baseclass to handle generic code better
Summary:
This patch is a followup to the first revision D36583, that had problems with 
generic code and its diagnostic messages, which were found by @lebedev.ri

Reviewers: alexfh, aaron.ballman, lebedev.ri, hokein

Reviewed By: aaron.ballman, lebedev.ri

Subscribers: klimek, sbenza, cfe-commits, JDevlieghere, lebedev.ri, xazax.hun

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

llvm-svn: 312134
2017-08-30 15:59:01 +00:00
Jonas Toth a8c34530df [clang-tidy] hicpp bitwise operations on signed integers
Summary:
This check implements the rule [[ http://www.codingstandard.com/section/5-6-shift-operators/ | 5.6. HIC++ ]]
that forbidds bitwise operations on signed integer types.

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

Reviewed By: aaron.ballman

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

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

llvm-svn: 312122
2017-08-30 13:32:05 +00:00
Jonas Toth a88abd58b4 [clang-tidy] test commit for granted access
llvm-svn: 312102
2017-08-30 07:50:28 +00:00
Daniel Marjamaki cad8443724 [clang-tidy] Fix 'misc-misplaced-widening-cast' assertion error.
Reviewers: alexfh, xazax.hun, danielmarjamaki

Differential Revision: http://reviews.llvm.org/D36670

llvm-svn: 311984
2017-08-29 06:25:24 +00:00
Michal Gorny a81de445c1 [cmake] Support running extra clang tool tests without static analyzer
Support running the extra clang tool tests when the static analyzer
is disabled. Disable the relevant clang-tidy tests and one include-fixer
test that require it to work.

Previously, the tests were disabled entirely with
CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being
enabled and the relevant tests are excluded and marked unsupported
appropriately.

In order to disable clang-tidy tests, the whole test directory is added
to the exclude lists, to avoid having to explicitly add 'REQUIRES' line
to every single test. If the other solution is preferable, I can update
the patch.

The yamldb_plugin include-fixer test is also updated to be disabled
without static analyzer. It fails in that case because clang is not
outputting a replacement suggestion -- but I don't know the exact
reason why it does not do that.

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

llvm-svn: 311983
2017-08-29 05:58:08 +00:00
Haojian Wu e928c2b67e [clang-tidy] Add missing IgnoreMacros doc for modernize-use-equals-default.
A followup of rL311136.

llvm-svn: 311654
2017-08-24 13:45:18 +00:00
Haojian Wu 3f495944de [clang-tidy] A follow-up fix of braced-init-list constructors in make-unique check.
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 311652
2017-08-24 13:35:55 +00:00
Alexander Kornienko 15ea4ebbb2 [clang-tidy] bugprone-undefined-memory-manipulation: include type into the message
Having the actual type in the message helps a lot understanding warnings in templates ;)

+ fix a false negative for type aliases.

llvm-svn: 311651
2017-08-24 12:11:05 +00:00
Ilya Biryukov 75337e8d66 [clangd] Updated ClangdServer comments. NFC.
llvm-svn: 311436
2017-08-22 09:16:46 +00:00
Alexander Kornienko dea43983ae [clang-tidy] Add modernize-use-equals-default.IgnoreMacros option
llvm-svn: 311136
2017-08-17 23:07:59 +00:00
Haojian Wu 80330ffc6b [clang-tidy] Ignore statements inside a template instantiation.
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 311086
2017-08-17 14:12:38 +00:00
Haojian Wu 4b956cb70d [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.
Summary:
The current fix will break the compilation -- because braced list is not
deducible in std::make_unique (with the use of forwarding) without
specifying the type explicitly.

We could support it in the future.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 311078
2017-08-17 10:14:52 +00:00
Chih-Hung Hsieh 2414429962 [clang-tidy] Remove unused static variable.
Differential Revision: https://reviews.llvm.org/D36761

llvm-svn: 311040
2017-08-16 21:00:06 +00:00
Chih-Hung Hsieh a54d379812 [clang-tidy] Use const char* to compile with VC cl.exe.
Summary:
cl.exe does not accept constexpr char FuncBindingStr[] = ...

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

llvm-svn: 311035
2017-08-16 19:13:35 +00:00
Chih-Hung Hsieh 41d29b15e8 [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.
Summary:
epoll_create() is better to be replaced by epoll_create1() with EPOLL_CLOEXEC
flag to avoid file descriptor leakage.

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

llvm-svn: 311029
2017-08-16 18:02:49 +00:00
Chih-Hung Hsieh 3be4ecb15b [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.
Summary:
epoll_create1() is better to set EPOLL_CLOEXEC flag to avoid file descriptor leakage.

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

llvm-svn: 311028
2017-08-16 17:53:12 +00:00
Chih-Hung Hsieh 5ac20c9c25 [clang-tidy] Add a close-on-exec check on accept4() in Android module.
Summary:
accept4() is better to set SOCK_CLOEXEC flag to avoid file descriptor leakage.

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

llvm-svn: 311027
2017-08-16 17:46:18 +00:00
Chih-Hung Hsieh ae3527e6bb [clang-tidy] Add a close-on-exec check on accept() in Android module.
Summary:
accept() is better to be replaced by accept4() with SOCK_CLOEXEC
flag to avoid file descriptor leakage.

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

llvm-svn: 311024
2017-08-16 17:18:16 +00:00
Chih-Hung Hsieh fec506daaa [clang-tidy] Use CloexecCheck as base class.
Summary:
Simplify registerMatchers and check functions in CloexecCreatCheck,
CloexecSocketCheck, CloexecFopenCheck, and CloexecOpenCheck.

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

llvm-svn: 311020
2017-08-16 16:59:26 +00:00
Chih-Hung Hsieh 7651e66cdf [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.
Summary:
inotify_init1() is better to set IN_CLOEXEC flag to avoid file descriptor leakage.

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

llvm-svn: 310863
2017-08-14 17:45:48 +00:00
Chih-Hung Hsieh 2e6f9a16f9 [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.
Summary:
inotify_init() is better to be replaced by inotify_init1() with IN_CLOEXEC flag to avoid file descriptor leakage.

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

llvm-svn: 310861
2017-08-14 17:25:41 +00:00
Chih-Hung Hsieh 56650e7fc5 [clang-tidy] Add a close-on-exec check on dup() in Android module.
Summary:
dup() is better to be replaced by fcntl() to avoid file descriptor leakage.

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

llvm-svn: 310858
2017-08-14 17:04:16 +00:00
Simon Pilgrim 0f311a4189 Add braces to silence gcc dangling-else warnings. NFCI.
llvm-svn: 310830
2017-08-14 11:05:56 +00:00
Ilya Biryukov db8b2d7b20 [clangd] Use multiple working threads in clangd.
Reviewers: bkramer, krasimir, klimek

Reviewed By: klimek

Subscribers: arphaman, cfe-commits

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

llvm-svn: 310821
2017-08-14 08:45:47 +00:00
Ilya Biryukov 91dbf5b6b4 [clangd] Check if CompileCommand has changed on forceReparse.
Reviewers: krasimir, bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 310819
2017-08-14 08:37:32 +00:00
Ilya Biryukov c5ad35fb23 [clangd] Fixed a data race.
Summary:
Calling addDocument after removeDocument could have resulted in an
invalid program state (AST and Preamble for the valid document could
have been incorrectly removed).
This commit also includes an improved CppFile::cancelRebuild
implementation that allows to cancel reparse without waiting for
ongoing rebuild to finish.

Reviewers: krasimir, bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 310818
2017-08-14 08:17:24 +00:00
Simon Pilgrim 7c87ebf3cd Fix Wdocumentation warning - typo in argument list. NFCI.
llvm-svn: 310783
2017-08-12 18:50:53 +00:00
Aaron Ballman 9253e89e47 Enable exceptions for this test case to speculatively fix the build bots.
Hopefully corrects: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/15666

llvm-svn: 310732
2017-08-11 16:46:45 +00:00
Aaron Ballman a3274e5443 Add hicpp-exception-baseclass to the HIC++ module.
This enforces that throwing an exception in C++ requires that exception to inherit from std::exception.

Patch by Jonas Toth.

llvm-svn: 310727
2017-08-11 16:31:51 +00:00
Aaron Ballman 6c2920a30a Implement hicpp-braces-around-statements as an alias to readability-braces-around-statements.
Patch by Jonas Toth.

llvm-svn: 310707
2017-08-11 12:12:36 +00:00
Yan Wang b21739f988 [clang-tidy] Fix for buildbot.
Summary:
Fix an issue for windows.

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

llvm-svn: 310669
2017-08-10 22:09:22 +00:00
Reid Kleckner 8d4d57035f Revert "[clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module."
This reverts commit r310630.

The new code broke on Windows and was untested. On Linux, it was
selecting the "int" overload of operator<<, which definitely does not
print the right thing when fed a "Mode" char.

llvm-svn: 310661
2017-08-10 21:21:15 +00:00
Yan Wang acd70d3c6b [clang-tidy] Fix a buildbot.
Fix format in ReleaseNotes.rst.

llvm-svn: 310643
2017-08-10 18:19:40 +00:00
Yan Wang d61c2a18cb [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.
Summary:
1. Refactor the structure of the code by adding a base class for all close-on-exec checks, which implements most of the needed functions.
2. memfd_create() is better to set MFD_CLOEXEC flag to avoid file descriptor leakage.

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh, hokein

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

Tags: #clang-tools-extra

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

llvm-svn: 310630
2017-08-10 17:18:10 +00:00
Gabor Horvath 0b16c10de3 [clang-tidy] Add integer division check
Patch by: Reka Nikolett Kovacs

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

llvm-svn: 310589
2017-08-10 13:30:30 +00:00
Alexander Kornienko 83eae8724e [clang-tidy] Updated docs and release notes for r310584
llvm-svn: 310587
2017-08-10 12:54:05 +00:00
Alexander Kornienko a4d94689fc [clang-tidy] Add a test.
llvm-svn: 310586
2017-08-10 12:38:46 +00:00
Alexander Kornienko 57fd153c46 [clang-tidy] Enable test for http://llvm.org/PR26228
llvm-svn: 310585
2017-08-10 12:24:52 +00:00
Alexander Kornienko ff6b2af499 [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option
llvm-svn: 310584
2017-08-10 12:19:05 +00:00
Haojian Wu b7a3856538 [clang-tidy] Fix an error in the doc.
llvm-svn: 310578
2017-08-10 10:15:48 +00:00
Haojian Wu 75de614684 [clang-tidy] add forwarders in the aliased checks from hicpp module
Summary: Adds redirections notes and the actual redirections in the documentation for hicpp

Patch by: Jonas Toth

Reviewers: aaron.ballman, hokein, alexfh

Reviewed By: aaron.ballman, hokein

Subscribers: JDevlieghere, xazax.hun

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

llvm-svn: 310577
2017-08-10 10:12:31 +00:00
Gabor Horvath 875ccc5864 [clang-tidy] Fix a check-fixes line
llvm-svn: 310560
2017-08-10 09:29:39 +00:00
Gabor Horvath aa660b5149 [clang-tidy] Minor documentation improvement
Patch by: Lilla Barancsuk

llvm-svn: 310559
2017-08-10 09:13:26 +00:00
Haojian Wu 6e596e2938 [clang-tidy] Add missing doc in cppcoreguidelines-c-copy-assignment-signature check.
llvm-svn: 310558
2017-08-10 09:12:32 +00:00
Benjamin Kramer 1436192d68 [clang-tidy] Don't compute the edit distance if it's over the threshold.
No functional change intended.

llvm-svn: 310532
2017-08-09 22:09:29 +00:00
Haojian Wu be5d4487b4 [clang-tidy] Fix another crash in make-unique check.
Summary:
The crash happens when calling `reset` method without any preceding
operation like "->" or ".", this could happen in a subclass of the
"std::unique_ptr".

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 310496
2017-08-09 17:03:42 +00:00
Alexander Kornienko 9b8df6ae02 [clang-tidy] Ignore newlines in checks list
This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that
LLVM YAML parser doesn't support multiline literal folding.

llvm-svn: 310491
2017-08-09 16:00:31 +00:00
Ilya Biryukov c22824a6fc [clangd] Fixed a bug in make_tagged.
It accidentally std::move'd from Value parameter if it deduced to an
l-value ref.

llvm-svn: 310470
2017-08-09 12:55:13 +00:00
Gabor Horvath 40b6512d9e [clang-tidy] Add new readability non-idiomatic static access check
Patch by: Lilla Barancsuk

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

llvm-svn: 310371
2017-08-08 15:33:48 +00:00
Alexander Kornienko f1a6552a95 [clang-tidy] 'implicit cast' -> 'implicit conversion'
Summary:
This patch renames checks, check options and changes messages to use correct
term "implicit conversion" instead of "implicit cast" (which has been in use in
Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++
standard).

  * performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop
  * readability-implicit-bool-cast -> readability-implicit-bool-conversion
    - readability-implicit-bool-cast.AllowConditionalIntegerCasts ->
      readability-implicit-bool-conversion.AllowIntegerConditions
    - readability-implicit-bool-cast.AllowConditionalPointerCasts ->
      readability-implicit-bool-conversion.AllowPointerConditions

Reviewers: hokein, jdennett

Reviewed By: hokein

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

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

llvm-svn: 310366
2017-08-08 14:53:52 +00:00
Florian Gross fa857b174d [clang-tidy] Added clang-tidy test cases related to rL310095
Differential Revision: https://reviews.llvm.org/D36308

llvm-svn: 310096
2017-08-04 19:01:56 +00:00
Haojian Wu 6a030d1bbf [clang-tidy] Add missing documents for "IgnoreMacros" option.
llvm-svn: 310051
2017-08-04 11:25:05 +00:00
Haojian Wu 115b707584 [clang-tidy] Ignore macros in make-unique check.
Summary:
The check doesn't fully support smart-ptr usages inside macros, which
may cause incorrect fixes, or even crashes, ignore them for now.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 310050
2017-08-04 11:18:00 +00:00
Haojian Wu dc1c7610b8 [clang-tidy] Support initializer-list constructor cases in modernize-make-unique.
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: malcolm.parsons, JDevlieghere, xazax.hun, cfe-commits

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

llvm-svn: 310035
2017-08-04 08:07:05 +00:00
Michal Gorny c1a0c00d50 [test] Fix clang library dir in LD_LIBRARY_PATH For stand-alone build
Prepend the clang library directory (determined using SHLIBDIR, alike
in clang) to the LD_LIBRARY_PATH to ensure that just-built clang
libraries will be used instead of a previous installed version.

When a stand-alone build is performed, LLVM_LIBS_DIR contains the path
to installed LLVM library directory. The same directory frequently
contains a previously installed version of clang. SHLIBDIR, on the other
hand, is always the build-tree directory, and therefore contains
the freshly built clang libraries.

In a non-stand-alone build, both paths will be the same and therefore
including them both will not cause any issues.

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

llvm-svn: 309979
2017-08-03 19:41:33 +00:00
NAKAMURA Takumi 55aebd689e ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.
llvm-svn: 309936
2017-08-03 13:30:43 +00:00
Manuel Klimek 7b9c117b82 Adapt clang-tidy checks to changing semantics of hasDeclaration.
Differential Revision: https://reviews.llvm.org/D36154

llvm-svn: 309810
2017-08-02 13:13:11 +00:00
Ilya Biryukov 574b753bfd [clangd] Run clang-format on all clangd sources. NFC.
llvm-svn: 309801
2017-08-02 09:08:39 +00:00
Ilya Biryukov 4ca7d85d2a [clangd] Capitalized descriptions of clangd options. NFC.
To follow the style of other options shown on `clangd -help`.

llvm-svn: 309800
2017-08-02 08:53:48 +00:00
Ilya Biryukov 6e1f3b1c90 [clangd] Fix more MSVC compilation failures.
It turns out MSVC does not allow non-copyable classes in std::future
and std::promise template arguments.

llvm-svn: 309720
2017-08-01 18:27:58 +00:00
Ilya Biryukov e925caf416 [clangd] Fixed MSVC compilation failures.
llvm-svn: 309705
2017-08-01 17:17:37 +00:00
Ilya Biryukov 02d5870de3 [clangd] Rewrote AST and Preamble management.
Summary: The new implementation allows code completion that never waits for AST.

Reviewers: bkramer, krasimir, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 309696
2017-08-01 15:51:38 +00:00
Malcolm Parsons 2f96843396 [clang-tidy] Handle anonymous structs/unions in member init checks.
Use getAnyMember() instead of getMember() to avoid crash on anonymous
structs/unions.
Don't warn about initializing members of an anonymous union.

Fixes PR32966.

Reviewed by alexfh.

llvm-svn: 309668
2017-08-01 09:54:05 +00:00
Ilya Biryukov ed99e4c5b2 [clangd] Allow to get vfs::FileSystem used inside codeComplete.
Summary: This is useful for managing lifetime of VFS-based caches.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

llvm-svn: 309585
2017-07-31 17:09:29 +00:00
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