Commit Graph

2277 Commits

Author SHA1 Message Date
Michal Gorny 6e31072e21 [test] Fix test dependencies when using installed tools
Use the LLVM_UTILS_PROVIDED variable to determine whether test tool
dependencies should be exposed for clang-tools-extra tests. If clang is
being built stand-alone and LLVM test tools (FileCheck, count and not)
are installed, the top-level CMakeLists.txt of clang sets this variable
to indicate that they will not be built as a part of this build,
and therefore no dependencies should be emitted for them. This fixes
the dependency errors when building clang stand-alone with tests
enabled.

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

llvm-svn: 297806
2017-03-15 05:55:43 +00:00
Benjamin Kramer 5957a19630 [clangd] Fix not being able to attach a debugger on macOS
Clangd is often waiting for input on getline as it awaits requests. If the
getline is interrupted, it causes the system call (read) to fail and the EINTR
error to be set. This can be seen when attaching a debugger such as LLDB on
macOS. On macOS (and possibly other operating systems), this system call is not
restarted after interruption but on Linux it is restarted which is why
attaching a debugger does work correctly there.

The solution is to work around the non-restarting system call by checking the
errno for EINTR when the stream fails and try again. This should be safe on all
Unixish platforms.

See also http://bugs.llvm.org/show_bug.cgi?id=32149 for some background
discussion.

Patch by Marc-Andre Laperle!
Differential Revision: https://reviews.llvm.org/D30675

llvm-svn: 297779
2017-03-14 20:41:28 +00:00
Aaron Ballman 9dd8caad1f Add the 'AllowSoleDefaultDtor' and 'AllowMissingMoveFunctions' options to the cppcoreguidelines-special-member-functions check.
Patch by Florian Gross.

llvm-svn: 297671
2017-03-13 21:39:00 +00:00
Sam McCall 9c5ebf7039 [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.
Summary:
Add fuzzy SymbolIndex, where identifier needn't match exactly.

The purpose for this is global autocomplete in clangd. The query will be a
partial identifier up to the cursor, and the results will be suggestions.

It's in include-fixer because:

  - it handles SymbolInfos, actually SymbolIndex is exactly the right interface
  - it's a good harness for lit testing the fuzzy YAML index
  - (Laziness: we can't unit test clangd until reorganizing with a tool/ dir)

Other questionable choices:

  - FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is
    an interface to allow extension to large monorepos (*cough*)
  - an always-true safety check that Identifier == Name is removed from
    SymbolIndexManager, as it's not true for fuzzy matching
  - exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and
    a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though.

Reviewers: bkramer

Subscribers: cfe-commits, mgorny

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

llvm-svn: 297630
2017-03-13 15:55:59 +00:00
Haojian Wu b7da0eb50e [clang-rename] Introduce an unittest skeleton for clang-rename.
Summary: This will make references rename tests easier.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits, alexfh, mgorny

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

llvm-svn: 297450
2017-03-10 10:30:14 +00:00
Sam McCall 573050e703 [include-fixer] Remove line number from Symbol identity
Summary:
Remove line number from Symbol identity.

For our purposes (include-fixer and clangd autocomplete), function overloads
within the same header should mostly be treated as a single combined symbol.

We may want to track individual occurrences (line number, full type info)
and aggregate this during mapreduce, but that's not done here.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 297371
2017-03-09 10:47:44 +00:00
Haojian Wu 8247fefead [clang-tidy] Update the doc according to r297311.
llvm-svn: 297367
2017-03-09 09:15:16 +00:00
Alexander Kornienko 5d698cf9a0 [clang-tidy] readability-function-size: remove default param count threshold
llvm-svn: 297311
2017-03-08 22:19:55 +00:00
Martin Bohme 96d29e5761 [clang-tidy] misc-use-after-move: Fix failing assertion
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

This patch also fixes nondeterministic behavior in the source code
location reported for the move when the move is constained in an init list;
this was causing buildbot failures in the previous attempt to submit
this patch (see D30569 and rL297004).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko, JDevlieghere, cfe-commits

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

llvm-svn: 297272
2017-03-08 12:34:51 +00:00
Haojian Wu d7b45bc76d Do not display highlights for clang-include-fixer-at-point
Summary: When invoking clang-include-fixer-at-point, the QuerySymbolInfos point to offset 0, length 0. Rather than showing a hidden overlay, do not show any overlay at all for zero-length symbols.

Patch by Torsten Marek!

Reviewers: hokein, klimek

Reviewed By: hokein

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

llvm-svn: 297010
2017-03-06 14:49:26 +00:00
Haojian Wu 1aa5885f00 [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
Reviewers: alexfh

Reviewed By: alexfh

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

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

llvm-svn: 297009
2017-03-06 14:46:44 +00:00
Martin Bohme 2e5f130bf4 Revert "[clang-tidy] misc-use-after-move: Fix failing assertion"
This reverts commit r297004; it was causing buildbots to fail.

llvm-svn: 297006
2017-03-06 09:46:27 +00:00
Martin Bohme a6391ae52b [clang-tidy] misc-use-after-move: Fix failing assertion
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 297004
2017-03-06 08:55:42 +00:00
Sylvestre Ledru 5038d5c3c5 Replaced UserNullMacros with NullMacros in modernize-use-nullptr check docs
By patch Peter Goldsborough on https://github.com/llvm-mirror/clang-tools-extra/pull/14
See 2cd835ee5b/clang-tidy/modernize/UseNullptrCheck.cpp (L466)

llvm-svn: 296970
2017-03-04 14:06:26 +00:00
Piotr Padlewski b6e1aa58fd [clang-tidy] Yet another docs fixes
llvm-svn: 296888
2017-03-03 17:16:11 +00:00
Piotr Padlewski 26e176e558 [clang-tidy] Fix modernize-use-emplace docs
llvm-svn: 296867
2017-03-03 12:42:22 +00:00
Alexander Kornienko 17a4b2344e [clang-tidy] Format code around applied fixes
Summary:
Add -format option (disabled by default for now) to trigger formatting
of replacements.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: kimgr, malcolm.parsons, JDevlieghere, cfe-commits

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

llvm-svn: 296864
2017-03-03 11:16:34 +00:00
Alexander Kornienko db04cccb87 [clang-tidy] google-readability-casting: don't use constructor call syntax for const types
llvm-svn: 296858
2017-03-03 08:18:49 +00:00
Alexander Kornienko b7f6fe4658 [clang-tidy] google-readability-casting: detect redundant casts with top-level const
llvm-svn: 296755
2017-03-02 15:47:28 +00:00
Alexander Kornienko ce482d9269 [clang-tidy] Fix a few more issues in google-readability-casting
* suggest static_cast instead of reinterpret_cast for casts from void*
* top-level const doesn't need a const_cast
* don't emit a separate "possibly redundant cast" warning, instead suggest
  static_cast (in C++ only) and add a little hint to consider removing the cast

llvm-svn: 296753
2017-03-02 15:27:34 +00:00
Benjamin Kramer 4c18c3743f [clangd] Fix a potential race by copying the FixIts out of ASTManager before releasing the lock.
Also document the locking semantics a bit better.

llvm-svn: 296737
2017-03-02 10:25:00 +00:00
Alexander Kornienko d993e76a18 [clang-tidy] Function names configurable for cppcoreguidelines-nomalloc - checker
Summary:
Hello everybody,

this is an incremental patch for the NoMalloc-Checker I wrote. It allows to configure the memory-management functions, that are checked,
This might be helpful for a code base with custom functions in use, or non-standard functionality, like posix_memalign.

Reviewers: aaron.ballman, hokein, alexfh

Reviewed By: aaron.ballman, alexfh

Subscribers: sbenza, nemanjai, JDevlieghere

Tags: #clang-tools-extra

Patch by Jonas Toth!

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

llvm-svn: 296734
2017-03-02 08:28:55 +00:00
Benjamin Kramer 570c230357 [clangd] Unbreak the shared build.
llvm-svn: 296637
2017-03-01 16:23:40 +00:00
Benjamin Kramer f0af3e6b01 [clangd] Add support for FixIts.
Summary:
This uses CodeActions to show 'apply fix' actions when code actions are
requested for a location. The actions themselves make use of a
clangd.applyFix command which has to be implemented on the editor side. I
included an implementation for vscode.

This also adds a -run-synchronously flag which runs everything on the main
thread. This is useful for testing.

Reviewers: krasimir

Subscribers: cfe-commits

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

llvm-svn: 296636
2017-03-01 16:16:29 +00:00
Alexander Kornienko 36267277d7 [clang-tidy] Attempt to fix the test where exceptions are disabled by default.
llvm-svn: 296627
2017-03-01 14:41:11 +00:00
Krasimir Georgiev 90573e49c9 [clangd] Add a toy VS Code integration for development purposes
Summary: This patch adds bare-bone VS Code integration for development purposes of clangd.

Reviewers: klimek, bkramer, mprobst

Reviewed By: bkramer

Subscribers: mprobst

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

llvm-svn: 296618
2017-03-01 13:53:12 +00:00
Eric Liu 413671507f [change-namespace] get insertion points of forward declarations correct.
Summary:
Previously, the insertion points would conflict with the old namespace
deletion.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 296604
2017-03-01 10:29:39 +00:00
Alexander Kornienko 9108644dbf [clang-tidy] Add parametercount for readibility-function-size
Summary:
Add an option to function-size to warn about high parameter counts.

This might be relevant for cppcoreguidelines and the safety module as well. Since the safety module is not landed in master already, i did not create an alias, but that can be done later as well.

Reviewers: sbenza, alexfh, hokein

Reviewed By: alexfh, hokein

Subscribers: JDevlieghere

Patch by Jonas Toth!

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

llvm-svn: 296599
2017-03-01 10:17:32 +00:00
Alexander Kornienko eedf7ec07f [clang-tidy] Fix handling of methods with try-statement as a body in modernize-use-override
Summary:
Fix generated by modernize-use-override caused syntax error when method
used try-statement as a body. `override` keyword was inserted after last
declaration token which happened to be a `try` keyword.

This fixes PR27119.

Reviewers: ehsan, djasper, alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Paweł Żukowski!

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

llvm-svn: 296598
2017-03-01 10:16:36 +00:00
Haojian Wu b780c59b93 [clang-tidy] Fix a false positive on modernize-use-nullptr check.
Summary:
The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

```
CXXFunctionalCastExpr 0x85c9670 <col:7, col:23> 'struct ZZ' functional cast to struct ZZ <ConstructorConversion>
 `-CXXConstructExpr 0x85c9518 <col:7, col:23> 'struct ZZ' 'void (uint64, const uint64 *)'
   |-CallExpr 0x85a0a90 <col:10, col:22> 'uint64':'unsigned long long'
   | |-ImplicitCastExpr 0x85a0a78 <col:10> 'uint64 (*)(uint64)' <FunctionToPointerDecay>
   | | `-DeclRefExpr 0x85a09f0 <col:10> 'uint64 (uint64)' lvalue Function 0x85a06a0 'Hash' 'uint64 (uint64)'
   | `-CXXDefaultArgExpr 0x85a0ac8 <<invalid sloc>> 'uint64':'unsigned long long'
   `-CXXDefaultArgExpr 0x85c94f8 <<invalid sloc>> 'const uint64 *'
```

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 296479
2017-02-28 15:29:52 +00:00
Alexander Kornienko 6414ab726d Misspelled checker description (argument comment)
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko

Tags: #clang-tools-extra

Patch by Peter Szecsi!

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

llvm-svn: 296472
2017-02-28 14:13:26 +00:00
Haojian Wu d09ed40e95 [find-all-symbols] Implement operator== for SymbolAndSignals and SymbolInfo::Signals.
llvm-svn: 296461
2017-02-28 10:13:26 +00:00
Eric Liu 3a7e13140a [change-namespace] trying to fix windows buildbot failure.
llvm-svn: 296458
2017-02-28 10:00:15 +00:00
Sam McCall b27dc2245f [include-fixer] Add usage count to find-all-symbols.
Summary:
Add usage count to find-all-symbols.

FindAllSymbols now finds (most!) main-file usages of the discovered symbols.
The per-TU map output has NumUses=0 or 1 (only one use per file is counted).
The reducer aggregates these to find the number of files that use a symbol.

The NumOccurrences is now set to 1 in the mapper rather than being inferred by
the reducer, for consistency.

The idea here is to use NumUses for ranking: intuitively number of files that
use a symbol is more meaningful than number of files that include the header.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 296446
2017-02-28 08:13:15 +00:00
Benjamin Kramer f2524e6599 [clangd] Make clangd install to bin
This allows the install target to also install clangd to bin, so that
it can be deployed and used outside the build tree.

Patch by Marc-Andre Laperle!
Differential Revision: https://reviews.llvm.org/D30425

llvm-svn: 296390
2017-02-27 21:40:35 +00:00
Haojian Wu 4a92050ce2 [clang-move] Extend clang-move to support moving global variable.
Summary: Also support dumping global variables.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 296337
2017-02-27 13:19:13 +00:00
Eric Liu 4c8767fa55 [change-namespace] fix asan failure in r296110.
llvm-svn: 296113
2017-02-24 12:56:51 +00:00
Eric Liu 7fccc9995a [change-namepsace] make it possible to whitelist symbols so they don't get updated.
Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 296110
2017-02-24 11:54:45 +00:00
Daniel Marjamaki 80c3b17410 [clang-tidy] Fix readability-redundant-declaration false positive
Differential Revision: https://reviews.llvm.org/D27048

llvm-svn: 296100
2017-02-24 09:02:44 +00:00
Manuel Klimek c38cd69256 Make clang-include-fixer--insert-line work when the difference is on an empty line
`clang-include-fixer--insert-line` has an off-by-one error because it
uses `(goto-char (point-min)) (forward-char chars)`, which is (goto-char
(1+ chars))`. Because of this, when the first difference was on an empty
line (i.e. an include was appended to the block of includes), the
pointer in the `to` buffer would be on the next line.

Also wrapped calls inside another process sentinel inside `with-local-quit`.

Patch by Torsten Marek.

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

llvm-svn: 295988
2017-02-23 16:02:53 +00:00
Manuel Klimek 0042499f48 Completion related fixes for clang-include-fixer.el.
1. Quitting inside a process sentinel is not allowed, but the sentinel invokes
completion, where the user is free to hit C-g. By wrapping the call in
with-local-quit, the process sentinel invocation can finish without triggering
an error
2. Invoke completing-read instead of ido-completing-read, since this may
interfere with user customizations to completing-read-function. The user should
use something like ido-ubiquitous if ido completion is wanted
3. Compare the string returned from completion with string=, since it may be a
copy of the original string in the collection

Patch by Torsten Marek.

llvm-svn: 295818
2017-02-22 09:21:22 +00:00
Manuel Klimek cb2358991b Adds a hook clang-include-fixer-add-include-hook that is invoked with the path and type of the added include.
This patch also adds a new function clang-include-fixer-from-symbol, which prompts the user for a symbol to resolve and include.

Patch by Torsten Marek.

llvm-svn: 295814
2017-02-22 08:26:04 +00:00
Benjamin Kramer ba5df6dea5 [clang-tidy] Reword the "code outside header guard" warning.
The check doesn't really know if the code it is warning about came before
or after the header guard, so phrase it more neutral instead of complaining
about code before the header guard. The location for the warning is still
not optimal, but I don't think fixing that is worth the effort, the
preprocessor doesn't give us a better location.

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

llvm-svn: 295715
2017-02-21 11:25:45 +00:00
NAKAMURA Takumi 8b33514617 clangd/ASTManager.cpp: Appease msc19 Debug build -- Don't deref std::vector::end().
llvm-svn: 295600
2017-02-19 07:18:16 +00:00
Alexander Kornienko 93748ebf82 [clang-tidy] google-readability-casting: Handle user-defined conversions
llvm-svn: 295544
2017-02-18 09:45:00 +00:00
Simon Pilgrim 356bb00b7e Fix windows buildbots that don't have full shell support
llvm-svn: 295498
2017-02-17 21:31:31 +00:00
Ehsan Akhgari fae3ac3e9b [clang-tidy] Add -path option to clang-tidy-diff.py
Summary:
This flag allows specifying a custom path for the compilation
database.  Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.

Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295482
2017-02-17 19:31:43 +00:00
Alex Lorenz 521d222330 [Docs] 'Limitations' should be a subsection
The 'Limitations' section in thedocumentation for
readability-misleading-indentation should be a subsection, as otherwise the link
to 'Limitations' isn't indented in the 'Clang-Tidy Checks' documentation page.

llvm-svn: 295471
2017-02-17 18:11:08 +00:00
Gabor Horvath e2fa53030e [clang-tidy] Add cert-dcl58-cpp (do not modify the 'std' namespace) check.
Differential Revision: https://reviews.llvm.org/D23421

llvm-svn: 295435
2017-02-17 08:52:51 +00:00
Krasimir Georgiev 8fcdd5ab96 Fix clang-move test after clang-format update r295312
llvm-svn: 295317
2017-02-16 13:17:38 +00:00