Commit Graph

2308 Commits

Author SHA1 Message Date
Haojian Wu 74f823a045 [clang-rename] Support renaming qualified symbol
Summary:
The patch adds a new feature for renaming qualified symbol references.
Unlike orginal clang-rename behavior, when renaming a qualified symbol to a new
qualified symbol (e.g "A::Foo" => "B::Bar"), this new rename behavior will
consider the prefix qualifiers of the symbol, and calculate the new prefix
qualifiers.  It aims to add as few additional qualifiers as possible.

As this is an early version (only supports renaming classes), I don't change
current clang-rename interfaces at the moment, and would like to keep its
(command-line tool) behavior. So I added new interfaces for the prototype.
In the long run, these interfaces should be unified.

No functionality changes in original clang-rename command-line tool.

This patch also contains a few bug fixes of clang-rename which are discovered by
the new unittest:

* fix a potential nullptr accessment when class declaration doesn't have definition.
* add USRs of nested declartaions in "getNamedDeclFor".

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: alexfh, cfe-commits, mgorny

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

llvm-svn: 299419
2017-04-04 09:30:06 +00:00
Krystyna Gajczyk 3a42e73c3f Fixes for modernize-use-using check:
- removed unnessacary namespaces
- added option to print warning in macros
- no fix for typedef with array
- removed "void" word from functions with 0 parameters

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

llvm-svn: 299340
2017-04-02 19:12:20 +00:00
Haojian Wu 25fdc3acf4 [clang-tidy] Correct code-block in the doc.
llvm-svn: 299190
2017-03-31 07:55:22 +00:00
Chih-Hung Hsieh b7b6c907ba [clang-tidy] Revert D31406 (Reuse FileID in getLocation)
Somehow the change failed test clang-tidy/llvm-include-order.cpp
on Windows platform.

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

llvm-svn: 299146
2017-03-31 01:11:11 +00:00
Chih-Hung Hsieh 4c2647bc2a [clang-tidy] Reuse FileID in getLocation
One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.

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

llvm-svn: 299119
2017-03-30 22:09:17 +00:00
Simon Pilgrim 9a54098385 Spelling mistakes in comments. NFCI.
Based on corrections mentioned in patch for clang for PR27635

llvm-svn: 299074
2017-03-30 13:10:33 +00:00
Jonathan Coe 53667b8dff [clang-tidy] fix docs in hicpp checks
Fix for sphinx-doc warnings in r299068.

llvm-svn: 299071
2017-03-30 12:59:41 +00:00
Jonathan Coe 7a6bff0820 [clang-tidy] fix for linker errors in hicpp checks
Speculative fix for linker errors in r299068.

llvm-svn: 299070
2017-03-30 12:31:02 +00:00
Jonathan Coe 88232264ac [clang-tidy] add aliases for hicpp module
Summary: Add some hicpp checks that can be implmented as alises for existing clang-tidy checks:
hicpp-explicit-conversions
hicpp-function-size
hicpp-named-parameter
hicpp-invalid-access-moved
hicpp-member-init
hicpp-new-delete-operators
hicpp-noexcept-move
hicpp-special-member-functions
hicpp-undelegated-constructor
hicpp-use-equals-default
hicpp-use-equals-delete
hicpp-use-override

Reviewers: dberlin, jbcoe, aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: JDevlieghere

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

Patch By: Jonas Toth

llvm-svn: 299068
2017-03-30 11:57:54 +00:00
Krasimir Georgiev af4adfa3ad [clangd] Add support for vscode extension configuration
Summary: Adds vscode workspace level configuration options for path to clangd binary and its arguments.
Contributed by stanionascu!

Reviewers: cfe-commits, bkramer, krasimir

Reviewed By: krasimir

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

llvm-svn: 298696
2017-03-24 09:29:00 +00:00
Marek Kurdej 92ecb51fae [clang-tidy] Fix treating non-space whitespaces in checks list.
Summary:
This furtherly improves r295303: [clang-tidy] Ignore spaces between globs in the Checks option.
Trims all whitespaces and not only spaces and correctly computes the offset of the checks list (taking the size before trimming).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

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

llvm-svn: 298621
2017-03-23 16:32:06 +00:00
Alexander Kornienko eaada5c91e [clang-tidy] Don't use groups in the big regexy filter
Fixes https://bugs.llvm.org/show_bug.cgi?id=27641.

llvm-svn: 298619
2017-03-23 16:29:39 +00:00
Alexander Kornienko 5816a8bbb1 [clang-tidy] Fix diag message for catch-by-value
Summary:
```
catch (std::exception ex)
{
}
```

Was flagged with "catch handler catches a pointer value".

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits, JDevlieghere

Patch by Florian Gross!

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

llvm-svn: 298608
2017-03-23 15:17:44 +00:00
Alexander Kornienko c3acd2e9c0 [clang-tidy] Catch trivially true statements like a != 1 || a != 3
Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state != STARTING)
...

Patch by Blaise Watson!

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

llvm-svn: 298607
2017-03-23 15:13:54 +00:00
Alexander Kornienko 33ec2d6cb1 [clang-tidy] Tests should not rely on STL headers being available.
llvm-svn: 298501
2017-03-22 12:50:10 +00:00
Alexander Kornienko 1c657f74e2 [clang-tidy] clang-format the last patch. NFC
llvm-svn: 298500
2017-03-22 12:50:05 +00:00
Alexander Kornienko ee9247ed13 [clang-tidy] modified identifier naming case to use CT_AnyCase for ignoring case style
Summary:
Using CaseType::CT_AnyCase for selected identifier results in inheriting case style setting from more basic identifier type.

This patch changes CT_AnyCase behavior to ignore case style of specified identifier. If case style was not set, llvm::Optional will be used for keeping this information (llvm::Optional<>::hasVal), thus CT_AnyCase will no longer mean more general identifier style should be used.

This eliminates false-positives when naming convention is not clear for specific areas of code (legacy, third party) or for selected types.

Reviewers: berenm, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

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

llvm-svn: 298499
2017-03-22 12:49:58 +00:00
Aaron Ballman 73f283e6fc Reverting r298421 due to using a header that's unavailable to all systems and some other post-commit review feedback.
llvm-svn: 298470
2017-03-22 01:08:54 +00:00
Benjamin Kramer a079cdbeb8 Apply clang-tidy's performance-unnecessary-value-param to clang-tidy.
No functionality change intended.

llvm-svn: 298442
2017-03-21 21:34:58 +00:00
Chandler Carruth 08781dc3b6 Don't make unqualified calls to functions that could well be found via
ADL as reasonable extension points.

All of this would be cleaner if this code followed the more usual LLVM
convention of not having deeply nested namespaces inside of .cpp files
and instead having a `using namespace ...;` at the top. Then the static
function would be in the global namespace and easily referred to as
`::join`. Instead we have to write a fairly contrived qualified name.
I figure the authors can clean this up with a less ambiguous name, using
the newly provided LLVM `join` function, or any other solution, but this
at least fixes the build.

llvm-svn: 298434
2017-03-21 20:15:42 +00:00
Aaron Ballman 163e7166d7 Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.
Patch by Breno Rodrigues Guimaraes.

llvm-svn: 298421
2017-03-21 19:01:17 +00:00
Eric Liu 8bc2416414 [change-namespace] avoid adding leading '::' when possible.
Summary:
When changing namespaces, the tool adds leading "::" to references that need to
be fully-qualified, which would affect readability.

We avoid adding "::" when the symbol name does not conflict with the new
namespace name. For example, a symbol name "na::nb::X" conflicts with "ns::na"
since it would be resolved to "ns::na::nb::X" in the new namespace.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 298363
2017-03-21 12:41:59 +00:00
Alexander Kornienko f6cd367874 [clang-tidy] readability-container-size-empty fix for (*x).size()
llvm-svn: 298316
2017-03-20 22:15:27 +00:00
Alexander Kornienko 9bf7037ccd [clang-tidy] Small cleanup. NFC.
llvm-svn: 298315
2017-03-20 22:15:19 +00:00
Aaron Ballman dbdbabf205 Rename the clang-tidy safety module to be hicpp, for the High-Integrity C++ coding standard from PRQA.
This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly.

llvm-svn: 298229
2017-03-19 17:23:23 +00:00
Alexander Kornienko b10daaf198 [Clang-tidy] Fix for misc-noexcept-move-constructor false triggers on defaulted declarations
Summary:
There is no need for triggering warning when noexcept specifier in move constructor or move-assignment operator is neither evaluated nor uninstantiated.

This fixes bug reported here: bugs.llvm.org/show_bug.cgi?id=24712

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JonasToth, JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Marek Jenda!

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

llvm-svn: 298101
2017-03-17 16:40:34 +00:00
Eric Liu 284b97c6bc [change-namespace] do not rename specialized template parameters.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 298090
2017-03-17 14:05:39 +00:00
Alexander Kornienko 70c8d291c2 [clang-tidy] Added a test with a different format.
llvm-svn: 298060
2017-03-17 10:05:49 +00:00
Alexander Kornienko bc8d14669d [clang-tidy] readability-misleading-indentation: fix chained if
Summary:
Fixed erroneously flagging of chained if statements when styled like this:

```
if (cond) {
}
else if (cond) {
}
else {
}
```

Reviewers: xazax.hun, alexfh

Reviewed By: xazax.hun, alexfh

Subscribers: JDevlieghere, cfe-commits

Patch by Florian Gross!

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

llvm-svn: 298059
2017-03-17 09:58:30 +00:00
Alexander Kornienko c7c9b75804 [clang-tidy] Verify some conditions in a matcher instead of check(). NFC
llvm-svn: 298057
2017-03-17 09:47:05 +00:00
Alexander Kornienko 7bcf7516df [clang-tidy] Ignore deleted members in google-explicit-constructor.
This fixes http://llvm.org/PR32221.

llvm-svn: 298052
2017-03-17 08:40:07 +00:00
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