Commit Graph

1905 Commits

Author SHA1 Message Date
Kirill Bobyrev d7f2a35cac [clang-tidy] Bugfix for readability-redundant-control-flow check
This check did not create FixItHints when the statement before the redundant
control flow was not followed by a semicolon.

Patch by Malcolm Parsons!

Reviewers: alexfh

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

llvm-svn: 281713
2016-09-16 10:12:08 +00:00
Kirill Bobyrev e5e7e153b5 [clang-rename] Merge rename-{at|all} & optimise.
Having both rename-at and rename-all both seems confusing and introduces
unneeded difficulties. After merging rename-at and rename-all maintaining main
function wrappers and custom help becomes redundant while CLI becomes less
confusing.

D24224 (which was the original patch causing buildbot failures) wasn't aware of
bugs caused by passing both -offset and -qualified-name. After D24224 was landed
it caused buildbot failures and therefor I just reverted it.

Two things that make this patch different from D24224 are:

* unittests/clang-rename was deleted, because it is unmaintained and doesn't do
much.
* Passing both `-offset` and `-qualified-name` isn't allowed anymore for the
sake of preventing bugs.

This patch is a trivial enhancement of accepted D24224 revision.

Tested with `ninja check-all`.

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

llvm-svn: 281710
2016-09-16 08:45:19 +00:00
Eugene Zelenko a8c46ce608 [Release notes] Mention readability-container-size-empty improvements.
Differential revision: https://reviews.llvm.org/D24526

llvm-svn: 281510
2016-09-14 17:41:51 +00:00
Martin Bohme cd56273ff1 [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule
Summary:
This is needed for the recently submitted misc-use-after-move check (rL281453).
For some reason, this still built under Linux, but it caused the PPC build bot
to fail.

Subscribers: beanz, cfe-commits, mgorny

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

llvm-svn: 281460
2016-09-14 13:33:11 +00:00
Kirill Bobyrev 8d78af4bb4 reverting r281456
llvm-svn: 281459
2016-09-14 13:23:14 +00:00
Kirill Bobyrev c2ed91fc4e [clang-rename] Merge rename-{at|all} & optimize.
Having both rename-at and rename-all both seems confusing and introduces
unneeded difficulties. Allowing to use both -qualified-name and -offset at once
while performing efficient renamings seems like a feature, too. Maintaining main
function wrappers and custom help becomes redundant while CLI becomes less
confusing.

Reviewers: alexfh

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

llvm-svn: 281456
2016-09-14 13:00:36 +00:00
Martin Bohme 2ca3196998 [clang-tidy] Make test for misc-use-after-move pass under Windows
Summary: Adds -fno-delayed-template-parsing

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 281455
2016-09-14 12:22:35 +00:00
Martin Bohme 42d3839bc5 [clang-tidy] Add check 'misc-use-after-move'
Summary:
The check warns if an object is used after it has been moved, without an
intervening reinitialization.

See user-facing documentation for details.

Reviewers: sbenza, Prazek, alexfh

Subscribers: beanz, mgorny, shadeware, omtcyfz, Eugene.Zelenko, Prazek, fowles, ioeric, cfe-commits

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

llvm-svn: 281453
2016-09-14 10:29:32 +00:00
Kirill Bobyrev 0d0bbfd63e [clang-tidy] Fix naming in container-size-empty.
llvm-svn: 281313
2016-09-13 10:19:13 +00:00
Kirill Bobyrev acb6b35b56 [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()
This patch extends readability-container-size-empty check allowing it to produce
warnings not only for STL containers, but also for containers, which provide two
functions matching following signatures:

* `size_type size() const;`
* `bool empty() const;`

Where `size_type` can be any kind of integer type.

This functionality was proposed in https://llvm.org/bugs/show_bug.cgi?id=26823
by Eugene Zelenko.

Approval: alexfh

Reviewers: alexfh, aaron.ballman, Eugene.Zelenko

Subscribers: etienneb, Prazek, hokein, xazax.hun, cfe-commits

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

llvm-svn: 281307
2016-09-13 08:58:11 +00:00
Daniel Marjamaki 03ea468a1c [clang-tidy] readability-misplaced-array-index: add new check that warns when array index is misplaced.
Reviewers: alexfh

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

llvm-svn: 281206
2016-09-12 12:04:13 +00:00
Ahmed Bougacha 7d61594f33 Revert "Resubmit "Add a test for clang-tidy using the clang-cl driver.""
This reverts commit r280839.
It's problematic on OS X, where the '/Users/...' paths are interpreted
as '/U' options.

Investigation ongoing in http://llvm.org/PR30328.

llvm-svn: 280975
2016-09-08 18:02:14 +00:00
Zachary Turner 8c9a7d7c41 Fix a few oversights in the clang-tidy VS plugin.
Over-zealous cleanup of using statements removed some that were
actually needed.  Also cleaned up a few warnings.

llvm-svn: 280844
2016-09-07 19:41:19 +00:00
Zachary Turner 1122be8e15 Add a clang-tidy visual studio extension.
For now this only adds the UI necessary to configure clang-tidy
settings graphically, and it enables reading in and saving out
of .clang-tidy files.  It does not actually run clang-tidy on
any source files yet.

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

llvm-svn: 280840
2016-09-07 18:28:55 +00:00
Zachary Turner b7a619c1fa Resubmit "Add a test for clang-tidy using the clang-cl driver."
This was originally reverted because the patch on the clang
tooling side was reverted.  That patch is being resubmitted,
so this patch is resubmitted as well.

llvm-svn: 280839
2016-09-07 18:28:42 +00:00
Haojian Wu cd63701245 [include-fixer] Support finding headers for the symbol under cursor.
Summary:
* Add a `query-symbol` option to query symbol without parsing the source file.
* Update Vim & Emacs integration scripts.

Reviewers: bkramer, massberg

Subscribers: cfe-commits

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

llvm-svn: 280824
2016-09-07 16:34:35 +00:00
Eugene Zelenko 1a14e4734e [include-fixer] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D24179

llvm-svn: 280741
2016-09-06 19:53:26 +00:00
Eugene Zelenko 31c9621320 [Release notes] Fix links.
Differential revision: https://reviews.llvm.org/D24201

llvm-svn: 280725
2016-09-06 17:52:44 +00:00
Kirill Bobyrev cd369a3802 [clang-rename] Add comment after namespace closing
llvm-svn: 280653
2016-09-05 09:42:02 +00:00
Kirill Bobyrev 8769778aca [clang-rename] Enforce LLVM policy about braces around single line control flow statement body.
Although it is not explicitly stated in LLVM Coding Standards, LLVM developers
prefer to omit braces around flow control statements with single line body.

For example the following piece of code

```
if (condition)
  std::cout << "Hello, world!" << std::endl;
```

is preferred to

```
if (condition) {
  std::cout << "Hello, world!" << std::endl;
}
```

So far clang-rename has ignored this. This patch makes clang-rename more
"LLVM-ish".

llvm-svn: 280640
2016-09-04 22:50:41 +00:00
Kirill Bobyrev 9504e3a4f0 [clang-rename] add failing test
For some reason clang-rename fails to rename method of templated class. Add
XFAIL test reproducing the issue.

llvm-svn: 280639
2016-09-04 22:28:39 +00:00
Kirill Bobyrev b2e2c19978 [clang-rename] Fix Clang-tidy and IWYU warnings; other minor fixes
Patch by Eugene Zelenko!

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

Reviewers: omtcyfz
llvm-svn: 280638
2016-09-04 22:19:52 +00:00
Hans Wennborg 5a39e2b0a5 Remove link to clang's release notes; keeping it up-to-date is hard
llvm-svn: 280539
2016-09-02 20:39:46 +00:00
Alexander Shaposhnikov bf3c84cff7 Add clang-reorder-fields to clang-tools-extra
This diff adds v0 of clang-reorder-fields tool to clang/tools/extra.
The main idea behind this tool is to simplify and make less error-prone refactoring of large codebases when
someone needs to change the order fields of a struct/class (for example to remove excessive padding).

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

llvm-svn: 280456
2016-09-02 02:56:07 +00:00
Alexander Shaposhnikov 3efddd22b9 Revert https://reviews.llvm.org/D23279 because the tests have failed on several platforms
llvm-svn: 280438
2016-09-02 00:24:06 +00:00
Alexander Shaposhnikov ae4ff453a4 Add clang-reorder-fields to clang-tools-extra
This diff adds v0 of clang-reorder-fields tool to clang/tools/extra.
The main idea behind this tool is to simplify and make less error-prone refactoring of large codebases when
someone needs to change the order fields of a struct/class (for example to remove excess padding).

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

llvm-svn: 280431
2016-09-01 23:49:48 +00:00
Haojian Wu 25df3b853b [include-fixer] Fix an undefined variable exception in vim script when there is
only one candidate header.

llvm-svn: 280359
2016-09-01 12:17:28 +00:00
Haojian Wu 997c31e54b [clang-tidy docs] Add missing option docs.
Reviewers: alexfh, Eugene.Zelenko, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 280236
2016-08-31 13:21:18 +00:00
Haojian Wu 544a8d03ab [docs] Fix docs build error.
llvm-svn: 280235
2016-08-31 13:17:48 +00:00
Piotr Padlewski d57be707b8 [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix
Summary:
Bugfix for 27321. When the constructor of stored pointer
type is private then it is invalid to change it to
make_shared or make_unique.

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: cfe-commits

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

llvm-svn: 280180
2016-08-31 00:06:55 +00:00
Eugene Zelenko 8899d52c18 [Release notes] Fix highlighting.
llvm-svn: 280119
2016-08-30 17:47:07 +00:00
Haojian Wu 2c5ee4454d [clang-tidy docs] Fix build errors on Sphinx 1.4.6
llvm-svn: 280095
2016-08-30 14:29:36 +00:00
NAKAMURA Takumi 795a1e9a15 clang-tools-extra/test/clang-tidy/misc-move-forwarding-reference.cpp: Appease ms targets with -fno-delayed-template-parsing.
llvm-svn: 280078
2016-08-30 12:34:03 +00:00
Martin Bohme b1ce6c6d57 [clang-tidy] Add check 'misc-move-forwarding-reference'
Summary:
The check emits a warning if std::move() is applied to a forwarding reference, i.e. an rvalue reference of a function template argument type.

If a developer is unaware of the special rules for template argument deduction on forwarding references, it will seem reasonable to apply std::move() to the forwarding reference, in the same way that this would be done for a "normal" rvalue reference.

This has a consequence that is usually unwanted and possibly surprising: If the function that takes the forwarding reference as its parameter is called with an lvalue, that lvalue will be moved from (and hence placed into an indeterminate state) even though no std::move() was applied to the lvalue at the callsite.

As a fix, the check will suggest replacing the std::move() with a std::forward().

This patch requires D23004 to be submitted before it.

Reviewers: sbenza, aaron.ballman

Subscribers: klimek, etienneb, alexfh, aaron.ballman, Prazek, Eugene.Zelenko, mgehre, cfe-commits

Projects: #clang-tools-extra

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

llvm-svn: 280077
2016-08-30 12:11:12 +00:00
Miklos Vajna 5a99207d11 clang-rename: fix formatting in USRFinder
As detected by clang-format.

llvm-svn: 280063
2016-08-30 07:24:57 +00:00
Miklos Vajna 2e5fca77a6 clang-rename: improve error message when -old-name is used and could not find symbol
Old output was:

clang-rename: could not find symbol at tools/clang/tools/extra/test/clang-rename/ClassFindByName.cpp:1:1 (offset 0).

Reviewers: omtcyfz

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

llvm-svn: 280062
2016-08-30 07:23:24 +00:00
Sylvestre Ledru 24b481370a Fix some typos in the doc
llvm-svn: 279944
2016-08-28 20:33:42 +00:00
Eugene Zelenko 8e8fa78821 [Clang-tidy] Fix some checks documentation style.
Differential revision: https://reviews.llvm.org/D23894

llvm-svn: 279846
2016-08-26 17:46:51 +00:00
Haojian Wu 0a1986790c [clang-tidy] Some tweaks on header guard checks.
* Implement missing storeOption interfaces.
* Remove unnecessary parameter copy in isHeaderFileExtension.
* Fix doc style.

llvm-svn: 279814
2016-08-26 11:15:38 +00:00
Mads Ravn 041b804a9f [clang-tidy] Added hh, hxx and hpp to header guard checks.
Changed the extension check to include the option of ",h,hh,hpp,hxx" instead of just returning whether the file ended with ".h".

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

llvm-svn: 279803
2016-08-26 05:59:53 +00:00
Alexander Kornienko eedcd9c1ea [clang-tidy misc-move-const-arg] more specific messages + suggest alternative solution
llvm-svn: 279666
2016-08-24 21:23:24 +00:00
Eugene Zelenko 5f45722b03 Clang-tidy documentation style. Two Google checks are aliases.
Differential revision: https://reviews.llvm.org/D23815

llvm-svn: 279659
2016-08-24 20:05:36 +00:00
Eugene Zelenko 29da951a3a [Documentation] Fix style of Clang-tidy readability-non-const-parameter.
llvm-svn: 279541
2016-08-23 17:57:24 +00:00
Alexander Kornienko bb56052b66 [clang-tidy] Merge ExtraArgs(Before) instead of overriding them.
Added proper tests.

llvm-svn: 279519
2016-08-23 14:48:29 +00:00
Alexander Kornienko 42fd75ea86 [clang-tidy] Fix the order of ExtraArgsBefore
Added tests for the relative order of -extra-arg(-before) and ExtraArgs(Before).

llvm-svn: 279516
2016-08-23 14:13:31 +00:00
Daniel Marjamaki 9e4ecfaec7 [clang-tidy] readability-non-const-parameter: add new check that warns when function parameters should be const
The check will warn when the constness will make the function interface safer.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 279507
2016-08-23 10:09:08 +00:00
Eugene Zelenko f0ae81da0b Fix style in some Clang-tidy checks documentation.
Differential revision: https://reviews.llvm.org/D23728

llvm-svn: 279494
2016-08-23 00:19:43 +00:00
Alexander Kornienko 179c18d338 [clang-tidy docs] Further cleanup of options
llvm-svn: 279442
2016-08-22 17:19:23 +00:00
Kirill Bobyrev 405699ef1d minor header guards and help messages cleanup
llvm-svn: 279226
2016-08-19 09:36:14 +00:00
Eugene Zelenko a1c76530d9 [Documentation] Fixed style in modernize-use-emplace.rst.
llvm-svn: 279170
2016-08-18 22:11:27 +00:00