Commit Graph

885 Commits

Author SHA1 Message Date
Daniel Jasper a3ec1a3267 clang-tidy: [misc-use-override] Add testcase with reversed attribute order
llvm-svn: 222755
2014-11-25 12:32:14 +00:00
Daniel Jasper 4525be4ebc clang-tidy: Add override before the first attribute.
Apparently attributes aren't sorted by source location.

llvm-svn: 222751
2014-11-25 10:45:23 +00:00
Alexander Kornienko b1f871cdcb [clang-tidy] Set google-readability-namespace-comments.ShortNamespaceLines to 10
This value is used in cpplint, so we'd better be consistent.

llvm-svn: 222431
2014-11-20 15:05:32 +00:00
Alexander Kornienko fc1dafba60 [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
This re-applies r222363 reverted in r222390 after compilation errors in our
out-of-tree clang-tidy tests were fixed.

llvm-svn: 222427
2014-11-20 12:05:51 +00:00
Hans Wennborg b4986e5a44 Revert r222363: "[clang-tidy] Count errors in ClangTidyDiagnosticConsumer"
This was causing clang-tidy invocations that would previously pass despite
source errors to fail.

llvm-svn: 222390
2014-11-19 22:02:11 +00:00
Alexander Kornienko efa443429d [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
llvm-svn: 222363
2014-11-19 16:07:26 +00:00
David Blaikie 34318816e8 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
llvm-svn: 222336
2014-11-19 07:49:54 +00:00
David Blaikie 8e6cf9e579 Remove uses of StringMap::GetOrCreateValue in favor of stl-compatible API usage
llvm-svn: 222305
2014-11-19 03:05:07 +00:00
David Blaikie 206b15b2e4 Update for LLVM API change
llvm-svn: 222304
2014-11-19 03:04:29 +00:00
Alexander Kornienko b23eb5e3f7 [clang-tidy] Move the missing namespace comment warnings to the closing brace
Summary:
The google-readability-namespace-comments/llvm-namespace-comment
warnings are quite confusing when they appear at the beginning of a long
namespace and the closing brace is not in sight.

For convenience added notes pointing to the start of the namespace.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 222145
2014-11-17 17:32:32 +00:00
David Blaikie 0ee6800a31 Remove some redundant virtual on overridden functions
llvm-svn: 222027
2014-11-14 19:27:22 +00:00
Alexander Kornienko e553a93ba8 Regression test for the --serialize-diagnostics problem fixed in r221884.
llvm-svn: 221885
2014-11-13 13:09:16 +00:00
Alexander Kornienko e20ce07a2f [clang-tidy] google-readability-function: skip std::nullptr_t
Parameters of type std::nullptr_t can only have one value, so it doesn't make
sense to name them.

llvm-svn: 221340
2014-11-05 11:08:39 +00:00
Alexander Kornienko ddf9767a49 [clang-tidy] Don't print a message if there's no error.
llvm-svn: 221272
2014-11-04 15:25:22 +00:00
Rafael Espindola ecc2ebe846 Use findProgramByName. NFC.
llvm-svn: 221260
2014-11-04 12:48:22 +00:00
Alexander Kornienko 5eac3c6a44 [clang-tidy] Added -fix-errors option
Summary:
Added -fix-errors option to allow applying fixes when compiler errors
are present. Without this flag -fix would bail out if there are compiler errors.
This is needed to avoid applying wrong fixes if Clang fails to recover from
compilation errors correctly.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 221152
2014-11-03 14:06:31 +00:00
NAKAMURA Takumi 5f687a036f [CMake] clangApplyReplacement: Add clangAST in libdeps to appease msc builder.
clangApplyReplacements.lib(ApplyReplacements.cpp.obj) : error LNK2001: unresolved external symbol "private: void __thiscall clang::APValue::DestroyDataAndMakeUninit(void)" (?DestroyDataAndMakeUninit@APValue@clang@@AAEXXZ)

They are not seen in mingw dll build. Investigating.

llvm-svn: 220895
2014-10-30 03:22:32 +00:00
NAKAMURA Takumi 9f99a7a417 [CMake] Prune redundant libdeps.
llvm-svn: 220893
2014-10-30 01:37:44 +00:00
NAKAMURA Takumi dc872ed908 [CMake] Add dependencies on clangToolingCore.
llvm-svn: 220890
2014-10-30 00:44:01 +00:00
NAKAMURA Takumi 90c67e5ab4 [CMake] Reformat.
llvm-svn: 220888
2014-10-30 00:43:33 +00:00
Daniel Jasper c1de000e22 Fix Makefiles after r220867.
llvm-svn: 220868
2014-10-29 18:55:41 +00:00
Alexander Kornienko 50ab15654e Shrink the set of checks enabled by default.
Summary:
Enable only compiler diagnostics and safe static analyzer checks by
default. Let the defaults be conservative and safe for an average project.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 220865
2014-10-29 18:25:09 +00:00
NAKAMURA Takumi 633239023c Suppress clang-tools-extra/test/clang-tidy/file-filter.cpp on win32 for investigaitng.
llvm-svn: 220837
2014-10-29 05:19:55 +00:00
Alexander Kornienko e15b004922 [clang-tidy] Updated docs for r220826.
llvm-svn: 220830
2014-10-28 22:43:33 +00:00
Alexander Kornienko 37f7abe424 [clang-tidy] Added -system-headers option.
Added -system-headers option to allow display of warnings from system headers.
This is needed for testing libcxx, for example.

llvm-svn: 220826
2014-10-28 22:16:13 +00:00
NAKAMURA Takumi 729be14435 Prune CRLF.
llvm-svn: 220678
2014-10-27 12:37:26 +00:00
Alexander Kornienko 106c8e0898 [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh
Summary: Make the script suitable for checking just messages. Move most of the tests to use it. Clean up the tests: shorten messages, insert line numbers, remove unnecessary RUN: lines, etc.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 220634
2014-10-26 02:58:07 +00:00
Alexander Kornienko 6775ce3ad3 [clang-tidy] Clean up test.
Simplify RUN lines and make checks stricter, check messages instead of fixes.

llvm-svn: 220633
2014-10-26 02:21:32 +00:00
Alexander Kornienko 2dd21acab4 [clang-tidy] Simplify RUN: lines in the test
llvm-svn: 220632
2014-10-26 02:18:06 +00:00
Alexander Kornienko 2192a8e519 [clang-tidy] Bring order to check registration.
Summary:
Register readability checks in a separate module. Renamed the checks
and test file names accordingly.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 220631
2014-10-26 01:41:14 +00:00
Samuel Benzaquen aedd994560 Add flag --enable-check-profile to clang-tidy.
Summary:
Add flag --enable-check-profile to clang-tidy.
It turns on per-matcher profiles in MatchFinder and prints a report to
stderr at the end.

Reviewers: alexfh

Subscribers: curdeius, cfe-commits

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

llvm-svn: 220491
2014-10-23 17:23:20 +00:00
Alexander Kornienko 4f6b06673d [clang-tidy] Add support for custom configuration file names/formats.
Summary: We're using different clang-tidy frontends (command-line, batch analysis jobs, code review integration), some of which are limited in the choice of configuration format. In order to avoid duplication of configuration information, we need to support the same configuration format in the command-line tool. This patch adds an extension point to make this possible without rewriting FileOptionsProvider.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 220199
2014-10-20 12:29:15 +00:00
Alexander Kornienko 27f126b006 [clang-tidy] Minor fixes for the NamespaceCommentCheck.
* Make SmallVector size enough for all groups.
  * Allow trailing period in the comment.
  * Fix "// anonymous namespace qqq".

llvm-svn: 219926
2014-10-16 15:11:54 +00:00
Alexander Kornienko 1efc425551 [clang-tidy] Default options in modules.
Summary:
This patch allows modules to specify default options for the checks
defined in them. This way a sufficiently configurable check can be registered in
multiple modules with different default options. E.g. the SpacesBeforeComments
option may be set to 1 for the "llvm-namespace-comments" check and to 2 for the
"google-readability-namespace-comment" check without modifying or extending the
check code.

This patch also registers the google-readability-braces-around-statements check
with suitable defaults.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 219923
2014-10-16 11:27:57 +00:00
Alexey Samsonov d1127d2d1f Avoid having "using namespace" for both "clang" and "llvm" namespaces.
This is fragile, as there are classes with the same name in both
namespaces (e.g. llvm::Module and clang::Module).

llvm-svn: 219855
2014-10-15 22:00:40 +00:00
Alexander Kornienko 81d4f939bc Fix llvm-header-guard check.
Summary:
This patch makes the check work better for LLVM code:
  * always fix existing #endif comments
  * use one space before the comment (+allow customization for other styles)

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 219789
2014-10-15 12:18:35 +00:00
Alexander Kornienko bebe0c6918 Reformatted code samples in the unit test. No functional changes.
llvm-svn: 219788
2014-10-15 11:36:48 +00:00
Alexander Kornienko 35ddae4a9b [clang-tidy] Move some of the misc checks to readability/
Summary:
Some of the misc checks belong to readability/. I'm moving them there
without changing check names for now. As the next step, I want to register some
of these checks in the google and llvm modules with suitable settings (e.g.
BracesAroundStatementsCheck). I'm not sure if we want to create a "readability"
module, probably not.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 219786
2014-10-15 10:51:57 +00:00
Alexander Kornienko f305000a91 [clang-tidy] misc-braces-around-statements.ShortStatementLines option
Add option ShortStatementLines to trigger this check only if the statement spans
over at least a given number of lines.

Modifications from the original patch:
  merged test/clang-tidy/misc-braces-around-statements-always.cpp into
  test/clang-tidy/misc-braces-around-statements.cpp and removed unnecessary
  CHECK-NOTs from the tests.

http://reviews.llvm.org/D5642

Patch by Marek Kurdej!

llvm-svn: 219611
2014-10-13 12:46:22 +00:00
Manuel Klimek 3f840a934e Re-structure clang-rename into a library and the tool.
This allows the unit tests to link the library.

Patch by Xin Huang.

llvm-svn: 219609
2014-10-13 11:30:27 +00:00
Manuel Klimek 81593db145 Small cleanups from review comments.
llvm-svn: 219409
2014-10-09 13:22:46 +00:00
Manuel Klimek 0551065cd1 Make clang-tidy's runCheckOnCode actually use the DiagnosticConsumer.
A precondition of that was to run both the preprocessor checks and AST
checks from the same FrontendAction, otherwise we'd have needed to
duplicate all involved objects in order to not have any references to a
deleted source manager.

llvm-svn: 219212
2014-10-07 15:49:36 +00:00
Alexander Kornienko 2f03c8a38d [clang-tidy] Allow space between "TODO" and "(user)"
llvm-svn: 219091
2014-10-05 23:40:30 +00:00
Benjamin Kramer d12555795e [clang-modernize] Update for API change.
NFC.

llvm-svn: 219063
2014-10-04 17:19:03 +00:00
Alexander Kornienko 44fe05beeb [clang-tidy] Documented check testing.
llvm-svn: 218962
2014-10-03 07:08:22 +00:00
Craig Topper e95cd8d5b8 Add missing 'override' keyword.
llvm-svn: 218961
2014-10-03 06:34:41 +00:00
Alexander Kornienko 8f7e7f73ea [clang-tidy] Add check misc-braces-around-statements.
This check looks for if statements and loops: for, range-for, while and
do-while, and verifies that the inside statements are inside braces '{}'.
If not, proposes to add braces around them.

Example:

  if (condition)
    action();

becomes

  if (condition) {
    action();
  }

This check ought to be used with the -format option, so that the braces be
well-formatted.


Patch by Marek Kurdej!

http://reviews.llvm.org/D5395

llvm-svn: 218898
2014-10-02 19:09:56 +00:00
Alexander Kornienko 97e8c3f6b5 [clang-tidy] Clarify a comment.
No functional changes.

llvm-svn: 218772
2014-10-01 15:50:31 +00:00
Alexander Kornienko 5091372331 [clang-tidy] Handle c-style casts from/to enums.
Summary: Convert c-style casts between integral end enum types to static_cast<>.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218760
2014-10-01 12:47:53 +00:00
Alexander Kornienko 04e9d9ce64 [clang-tidy] Updated documentation
Added an example of check-specific options.

llvm-svn: 218573
2014-09-27 21:47:01 +00:00
Alexander Kornienko 9d32634c61 [clang-tidy] Fix documentation.
Try using code-block: console for command-line usage examples.

llvm-svn: 218572
2014-09-27 21:33:33 +00:00
Alexander Kornienko 55d6274de1 [clang-tidy] Fix for the documentation.
llvm-svn: 218571
2014-09-27 21:27:05 +00:00
Alexander Kornienko e088a46a83 [clang-tidy] Updated documentation.
llvm-svn: 218570
2014-09-27 21:25:26 +00:00
Alexander Kornienko 88905b3909 Corrected a comment in check_clang_tidy_fix.sh
llvm-svn: 218516
2014-09-26 12:51:13 +00:00
Alexander Kornienko 761c25bc15 [clang-tidy] Test username substitution in TODO() check.
Summary:
This patch depends on D5501.
Check user name substitution more specifically by specifying it via the new
-config= option.
This also lets clang-tidy tests specify clang-tidy options before the '--'
when using check_clang_tidy_fix.sh.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218515
2014-09-26 12:44:30 +00:00
Alexander Kornienko 7165e89892 Fix a typo
llvm-svn: 218512
2014-09-26 11:48:53 +00:00
Alexander Kornienko eff4e9232a [clang-tidy] Add a -config={YAML} option.
Summary:
Add -config option to allow specifying configuration in YAML/JSON
format on the command line.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218511
2014-09-26 11:42:29 +00:00
Alexander Kornienko f5a57c9c24 Clang-tidy google-readability-function check: don't warn on gmock
testing::Unused parameters.

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218443
2014-09-25 08:16:24 +00:00
Alexander Kornienko e995154ac2 Provide user name in ClangTidyOptions.
Summary:
This adds the ClangTidyOptions::User field and fills it from the USER
or the USERNAME environment variable, if possible. The FileOptionsProvider now
takes "default" options instead of "fallback" options, as it now uses these when
an option is not set in the configuration file (one exception is the checks
list).

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 218402
2014-09-24 18:36:03 +00:00
Benjamin Kramer 39e40cccc6 Drop superfluous semicolon. GCC's -pedantic warns about this.
llvm-svn: 218310
2014-09-23 14:46:55 +00:00
NAKAMURA Takumi 9e0d592838 ClangTidyTests: Add dependency on clangTidyUtils.
I missed to add it since I suppressed checks on win32 in r215590.

llvm-svn: 218289
2014-09-23 00:53:38 +00:00
Benjamin Kramer d15514a8bd Try to pacify dash-using linux distros with a very old-school shell variable compare.
While there fix the cmake shared build.

llvm-svn: 218274
2014-09-22 21:01:04 +00:00
Alexander Kornienko 451567ac43 Add missing dependency.
llvm-svn: 218249
2014-09-22 14:56:43 +00:00
Alexander Kornienko 33fc3db9a1 Add NamespaceCommentCheck to the Google module.
Summary:
This uses a bit hacky way to set the defaults for the spaces before
comments, but it's also one of the simplest ways. Fixed a bug with how the
SpacesBeforeComments option was used.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 218240
2014-09-22 10:41:39 +00:00
NAKAMURA Takumi 52002ee5bb ClangRenameTests: Prune redundant libdeps.
llvm-svn: 218235
2014-09-22 05:45:11 +00:00
NAKAMURA Takumi 44a3731281 Add newline at eof.
llvm-svn: 218234
2014-09-22 05:45:01 +00:00
Alexander Kornienko f73fe3a04e run-clang-tidy.py: don't fail when running without -checks=.
llvm-svn: 218227
2014-09-22 00:07:07 +00:00
Alexander Kornienko 02bd018aeb Disable most of the google-readability-casting check for non-C++ files (only
leave the "redundant cast to the same type" part).

llvm-svn: 218225
2014-09-21 23:39:28 +00:00
Hans Wennborg dfd8c74a98 [clang-tidy] Don't leak the TodoCommentHandler object
Preprocessor:addCommentHandler() does not take ownership,
so we'd end up leaking the TodoCommentHandler.

This patch makes it owned by the Check object.

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

llvm-svn: 218068
2014-09-18 18:59:50 +00:00
Benjamin Kramer 6be414da26 [clang-tidy] Add a checker that warns on TODO comments without username.
It also suggests a fix-it, taking the name from $USER. This will be made
configurable eventually.

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

llvm-svn: 218049
2014-09-18 12:53:13 +00:00
Benjamin Kramer ebdf90ca00 Make a variable local so it's lifetime becomes more obvious.
NFC

llvm-svn: 217952
2014-09-17 13:12:51 +00:00
Benjamin Kramer ae8fc52237 [clang-tidy] Don't emit the same fixit multiple times.
If we had many header files we would attach the fix-it for all files to all
warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter
in some edge cases. Sadly I failed to create a small test case for this.

While there move fix-its instead of copying.

llvm-svn: 217951
2014-09-17 11:48:34 +00:00
Benjamin Kramer 31a1024b93 Rename unit test argument and add argument comments for clarity.
NFC

llvm-svn: 217947
2014-09-17 09:05:07 +00:00
Benjamin Kramer eb213cb1cd [clang-tidy] When emitting header guard fixes bundle all fix-its into one
warning.

Before we would emit two warnings if the header guard was wrong and the comment
on a trailing #endif also needed fixing.

llvm-svn: 217890
2014-09-16 17:41:19 +00:00
Benjamin Kramer 6e195426e7 [clang-tidy] Add a checker for long functions.
As this is very dependent on the code base it has some ways of configuration.
It's possible to pick between 3 modes of operation:

- Line counting: number of lines including whitespace and comments
- Statement counting: number of statements within compoundStmts.
- Branch counter

In addition a threshold can be picked, warnings are only emitted when it is met.
The thresholds can be configured via a .clang-tidy file.

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

llvm-svn: 217768
2014-09-15 12:48:25 +00:00
Alexander Kornienko 6e0cbc8947 Implemented clang-tidy-check-specific options.
Summary:
Each check can implement readOptions and storeOptions methods to read
and store custom options. Each check's options are stored in a local namespace
to avoid name collisions and provide some sort of context to the user.

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 217661
2014-09-12 08:53:36 +00:00
Alexander Kornienko c28c32ddc7 Moved main() to the clang::tidy namespace, no functional changes.
llvm-svn: 217493
2014-09-10 11:43:09 +00:00
Alexander Kornienko d3fdcf89ef std::function-ize ClangTidyCheckFactories.
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217492
2014-09-10 11:25:43 +00:00
Alexander Kornienko be8c143dd6 Unique-ptrify ClangTidyCheckFactories. Add a more convenient alternative to
addCheckFactory: registerCheck.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217489
2014-09-10 11:06:43 +00:00
Benjamin Kramer ad335cf690 [clang-tidy] Don't try to fix header guard #endif comments if there are escaped
newlines involved.

Getting that right is just not worth it.

llvm-svn: 217480
2014-09-10 08:48:30 +00:00
Craig Topper 775862a277 Unique_ptrify PPCallbacks ownership. Goes with clang r217474.
llvm-svn: 217475
2014-09-10 05:07:57 +00:00
Benjamin Kramer 91ea478d7c clang-apply-replacements: For-rangify.
No functionality change.

llvm-svn: 217442
2014-09-09 14:09:48 +00:00
Benjamin Kramer ab7cefc36b clang-apply-replacements: Deduplicate paths with FileManager.
Bucket replacements by FileEntry instead of path. The same file with
different paths is very common, relative #include paths and symlinks can
easily create them. When that occurs we would apply the fix twice.

llvm-svn: 217440
2014-09-09 13:53:51 +00:00
Alexander Kornienko 09d811c575 Fixed a typo.
llvm-svn: 217377
2014-09-08 15:04:35 +00:00
Benjamin Kramer 815dbadb16 run-clang-tidy: Make clang-tidy path configurable and don't fail as horribly
when it's not around.

llvm-svn: 217374
2014-09-08 14:56:40 +00:00
Benjamin Kramer 13460075b3 [clang-tidy] Add a couple of paragraphs on run-clang-tidy.py to the docs.
Happy tidying.

llvm-svn: 217373
2014-09-08 14:56:37 +00:00
Benjamin Kramer 044ade8549 Move clang-tools-extra docs 1.5 years into the future.
llvm-svn: 217369
2014-09-08 14:04:49 +00:00
Benjamin Kramer a9d9a4d55a [clang-tidy] Add a little python script that can run clang-tidy and apply fixes over an entire codebase.
Ever wanted to fix all the header guards in clang? Now it's easy.
  Make sure clang-tidy is in $PATH and a compilation database is available.
  $ ./run-clang-tidy.py -checks=-*,llvm-header-guard -fix
  ... get coffee (or more CPU cores) ...
  $ svn diff

Some may argue that this is just a glorified xargs -P, but it does a bit more ;)

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

llvm-svn: 217368
2014-09-08 14:01:31 +00:00
Hans Wennborg fece4c6cd5 Try to make VS 2012 happy after r217155
It was failing with:

C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\llvm\include\llvm/Support/ErrorOr.h(102) : error C3861: 'make_error_code': identifier not found

        C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang-tools-extra\clang-tidy\ClangTidyOptions.cpp(153) : see reference to function template instantiation 'llvm::ErrorOr<T>::ErrorOr<std::errc::errc>(E,void *)' being compiled

        with
        [
            T=clang::tidy::ClangTidyOptions,
            E=std::errc::errc
        ]

llvm-svn: 217201
2014-09-04 22:41:03 +00:00
Alexander Kornienko 4153da2264 Don't write files with no fixes.
llvm-svn: 217163
2014-09-04 15:19:49 +00:00
Benjamin Kramer 4e3f971f58 Plug a unit test memory leak.
MatchFinder.addMatcher doesn't take ownership.

llvm-svn: 217162
2014-09-04 15:15:27 +00:00
Alexander Kornienko d53d2686b3 Implemented clang-tidy configurability via .clang-tidy files.
Summary:
This adds a support for the .clang-tidy file reading using
FileOptionsProvider, -dump-config option, and changes tests to not depend on
default checks set.

Reviewers: klimek, bkramer, djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217155
2014-09-04 14:23:36 +00:00
Benjamin Kramer fb98b74f8e [clang-tidy] Add an option to export suggested fixes into a file.
Allows gathering fixes and applying them with clang-apply-fixes.

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

llvm-svn: 217139
2014-09-04 10:31:23 +00:00
Alexander Kornienko 805b44d124 ClangTidy misc-argument-comment check: don't check arguments to template
parameter packs.

Summary:
This disables this check for std::bind and similar functions that use
parameter packs to forward arguments to a different function. Name of the
parameter pack argument doesn't matter.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 217039
2014-09-03 14:56:30 +00:00
Benjamin Kramer 6bcbe6e04d [clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher.
llvm-svn: 217036
2014-09-03 13:30:28 +00:00
Benjamin Kramer b7f59d6bbd [clang-tidy] Use new ASTMatchers to identify template instantiations instead of copying it everywhere.
No intended functionality change.

llvm-svn: 217035
2014-09-03 13:21:51 +00:00
Benjamin Kramer 3500845f07 Remove unused AST matcher.
llvm-svn: 216901
2014-09-02 09:46:43 +00:00
Benjamin Kramer fec6705db0 [clang-tidy] Don't suggest naming the dummy argument of a post-inc operator overload.
llvm-svn: 216868
2014-09-01 09:11:48 +00:00
Benjamin Kramer 041c138ba5 Try to fix test on msvc and 32 bit hosts.
llvm-svn: 216727
2014-08-29 14:47:30 +00:00
Benjamin Kramer 06e323a6ee [clang-tidy] Add a checker that suggests replacing short/long/long long with fixed-size types.
Differential Revision: http://reviews.llvm.org/D5119

llvm-svn: 216726
2014-08-29 14:38:46 +00:00
Benjamin Kramer e59cd6e6ff [clang-tidy] Don't suggest naming unnamed parameters on deleted/defaulted functions.
llvm-svn: 216718
2014-08-29 08:58:35 +00:00
Craig Topper ae926ad24d Remove call to llvm::makeArrayRef. Implicit conversion is sufficient.
llvm-svn: 216711
2014-08-29 06:05:20 +00:00
David Blaikie 715c98aeec Update for Clang API change.
llvm-svn: 216615
2014-08-27 20:54:50 +00:00
Rafael Espindola 7fa030330c Update for LLVM api change.
llvm-svn: 216584
2014-08-27 20:03:22 +00:00
Ted Kremenek 4d1692f613 Adjust call 'CreateAnalysisConsumer' due to API tweak.
llvm-svn: 216551
2014-08-27 15:14:47 +00:00
Craig Topper 2f020e5497 Simplify creation of a couple ArrayRefs by using None and makeArrayRef.
llvm-svn: 216529
2014-08-27 06:29:07 +00:00
Benjamin Kramer d5fef8198b [clang-tidy] If we're going to change the header guard in the #endif comment
we can also fix the original header guard.

We still allow an _ at the end of a header guard since it's so common, but
remove it now when the #endif comment is changed.

llvm-svn: 216462
2014-08-26 16:28:35 +00:00
Rafael Espindola b14bd53e6d Update for LLVM api change
llvm-svn: 216396
2014-08-25 18:17:00 +00:00
Benjamin Kramer 208faaaa29 [clang-tidy] Allow /**/ comments on #endifs when checking header guards.
Turning block comments into line comments just creates unecessary churn.

llvm-svn: 216072
2014-08-20 16:01:42 +00:00
Manuel Klimek de23726dbd Revert rL215947: "[clang-rename] revert r215839"
Make tests not depend on grep supporting -bo.

llvm-svn: 216041
2014-08-20 01:39:05 +00:00
Gerolf Hoflehner 62bf7e83cb [clang-rename] revert r215839
The commit broke public build bots for more than 24 hours.

(view as text)
******************** TEST 'Clang Tools :: clang-rename/VarTest.cpp' FAILED ********************
Script:
--
cat /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/tools/extra/test/clang-rename/VarTest.cpp > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp
clang-rename -offset=$(grep -FUbo 'foo;' /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp | head -1 | cut -d: -f1) -new-name=hector /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp -i --
sed 's,//.*,,' /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp | FileCheck /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/tools/extra/test/clang-rename/VarTest.cpp
--
Exit Code: 1

Command Output (stderr):
--
clang-rename: could not find symbol at /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp:2:1 (offset 14).

llvm-svn: 215947
2014-08-18 23:03:30 +00:00
NAKAMURA Takumi 8fad914691 [CMake] clang-rename: Optimize libdeps.
llvm-svn: 215935
2014-08-18 20:49:18 +00:00
NAKAMURA Takumi d5a96a794e Add trailing linefeed.
llvm-svn: 215934
2014-08-18 20:49:09 +00:00
NAKAMURA Takumi b7b2e4cba0 Revert r215854 corresponding to r215857, "Suppress ClangRenameTests/USRLocFinding.FindsVarUSR on msc17 for now. Will fix later."
llvm-svn: 215859
2014-08-17 22:45:29 +00:00
Manuel Klimek 57ba55cbc3 Remove initializer list.
llvm-svn: 215857
2014-08-17 22:24:10 +00:00
NAKAMURA Takumi 976e3e8693 Suppress ClangRenameTests/USRLocFinding.FindsVarUSR on msc17 for now. Will fix later.
llvm-svn: 215854
2014-08-17 22:17:11 +00:00
Manuel Klimek 639557ae86 Fix link libraries for clang-rename.
llvm-svn: 215843
2014-08-17 18:33:24 +00:00
Manuel Klimek 52d23d4cee Remove mention of non-existent 'test' directory.
llvm-svn: 215840
2014-08-17 18:17:41 +00:00
Manuel Klimek ccf0d79724 First version of a clang-rename tool.
Summary:
Note that this code is still grossly under-tested - the next steps will
be to add significantly better test coverage.

Patch by Matthew Plant.

Test Plan:

Reviewers:

Subscribers:

llvm-svn: 215839
2014-08-17 18:00:59 +00:00
Alexander Kornienko 08cc55dbe9 AvoidCStyleCastsCheck: don't warn on casts in macros
llvm-svn: 215799
2014-08-16 00:53:20 +00:00
NAKAMURA Takumi 15fb86c4e6 ClangTidyTests: Suppress FixHeaderGuards on win32 for now.
FIXME: It seems this might be incompatible to dos path. Investigating.
llvm-svn: 215590
2014-08-13 22:12:38 +00:00
NAKAMURA Takumi c54e6e833e [CMake] Update libdeps in clangTidyLLVMModule.
llvm-svn: 215589
2014-08-13 22:12:28 +00:00
Benjamin Kramer cc5366c07a In ancient times build targets had to be sorted topologically. Sometimes this behavior can still be observed today.
llvm-svn: 215553
2014-08-13 14:41:24 +00:00
Benjamin Kramer 5eddaac17f Fix linking in the Makefile build.
llvm-svn: 215550
2014-08-13 14:14:38 +00:00
Benjamin Kramer 498cce575f [clang-tidy] Add a generic header guard checker + LLVM implementation.
The implementation is split into a generic part and a LLVM-specific part.
Other codebases can implement it with their own style. The specific features
supported are:

- Verification (and fixing) of header guards against a style based on the file path
- Automatic insertion of header guards for headers that are missing them
- A warning when the header guard doesn't enable our fancy header guard optimization
(e.g. when there's an include preceeding the guard)
- Automatic insertion of a comment with the guard name after #endif.

For the LLVM style we disable #endif comments for now, they're not very common
in the codebase. We also only flag headers in the include directories, there
doesn't seem to be a common style outside.

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

llvm-svn: 215548
2014-08-13 13:57:57 +00:00
Benjamin Kramer 87cc652651 Try to unbreak the Makefile build.
llvm-svn: 215545
2014-08-13 13:20:04 +00:00
Benjamin Kramer b4e7c9b211 Also run extra tools unit tests in shared library builds.
Took me way too long to figure out why they didn't run.

llvm-svn: 215543
2014-08-13 12:54:50 +00:00
Samuel Benzaquen d7349439d5 [clang-query] Use the new API for named values from the Parser.
Summary: This finishes the support for autocomplete for user defined values..

Reviewers: pcc

Subscribers: cfe-commits

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

llvm-svn: 215474
2014-08-12 21:22:58 +00:00
Rafael Espindola ee8155d01a Update for API change in clang.
llvm-svn: 215452
2014-08-12 16:01:34 +00:00
Benjamin Kramer 242b5b808b [clang-tidy] Disable the warning on implicit bool* to bool conversion in macros.
It's just too noisy and the warning isn't very helpful in those cases.

llvm-svn: 215439
2014-08-12 12:12:57 +00:00
Benjamin Kramer 6318f7614f Allow specifying file names and extra arguments when running clang-tidy unit tests.
Will become useful soon.

llvm-svn: 215438
2014-08-12 12:12:54 +00:00
David Blaikie dffd853716 Update for API change in r215391
llvm-svn: 215392
2014-08-11 22:11:02 +00:00
David Blaikie 680c4c898c Recommit 213308: unique_ptr-ify ownership of ASTConsumers (reverted in r213324)
After post-commit review and community discussion, this seems like a
reasonable direction to continue, making ownership semantics explicit in
the source using the type system.

llvm-svn: 215324
2014-08-10 19:56:59 +00:00
David Blaikie 590e5ff473 clang-modernize: Transform::createActionFactory return ownership by unique_ptr instead of raw pointer.
Follow up to r213851 to simplify code and reduce the chance of future
leaks.

llvm-svn: 215214
2014-08-08 16:06:07 +00:00
Benjamin Kramer b41c91c389 [clang-tidy] Don't index past the end of a vector.
We actually want the end iterator so just replace it with iterator arithmetic.

llvm-svn: 215195
2014-08-08 10:43:11 +00:00
Alexander Kornienko 05cb0bb55e Reverting to Rui's last version, as it actually works both in Darwin and in Linux
llvm-svn: 215192
2014-08-08 08:49:19 +00:00
Alexander Kornienko b0b08a0cca Closing the loop. Now this sed invocation is back to what it was before the attempts to 'improve' it.
llvm-svn: 215189
2014-08-08 08:20:55 +00:00
NAKAMURA Takumi 274a845e00 Suppress clang-tools-extra/test/clang-tidy/llvm-include-order.cpp for targeting msvc. Investigating.
FYI, I can see the order;

  #include "j.h"
  #include "i.h"
  #include "clang-c/c.h" // hi
  #include "clang/b.h"
  #include "llvm-c/d.h" // -c
  #include "llvm/a.h"
  #include "gtest/foo.h"
  #include <s.h>

llvm-svn: 215179
2014-08-08 02:01:42 +00:00
Rui Ueyama 161b7fd1e1 [clang-tidy] Fix sed flag, third try
llvm-svn: 215175
2014-08-08 00:19:22 +00:00
Rui Ueyama 9080920ded [clang-tidy] Fix sed flag again
Darwin's sed does not recognize -r to tell the tool that the
expression is the extended regexp. Seems we don't really need
the flag, as the expression is valid as the standard regexp.
Removing the flag.

llvm-svn: 215171
2014-08-07 23:33:38 +00:00
Rui Ueyama 76e8af88b8 [clang-tidy] Fix sed flag.
GNU sed does not recognize -E. Use -r that is supported by
both BSD and GNU instead.

llvm-svn: 215163
2014-08-07 22:55:39 +00:00
Benjamin Kramer d16a8c4898 [clang-tidy] Implement the include order checker for LLVM.
There are still a couple of rough edges in here but it is working fine
on LLVM and generates the same results as sort_includes.py if there are
no blank lines involved.

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

llvm-svn: 215152
2014-08-07 21:49:38 +00:00
Alexander Kornienko b3d331d18d Rename ChecksFilter to GlobList, as there's nothing specific to checks in it.
Summary:
Rename ChecksFilter to GlobList, as there's nothing specific to checks in it.
It's a rather generic way to represent sets of strings (or patterns), so it may
be used for something else in ClangTidy. The new name would not look strange
when used to filter other entities.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 214961
2014-08-06 11:49:10 +00:00
Alexander Kornienko bc9f9928b7 check_clang_tidy_fix.sh: added comments, use set -o errexit instead of '|| exit $?' on each command
llvm-svn: 214956
2014-08-06 10:17:55 +00:00
Benjamin Kramer 6fd227c9ad [clang-tidy] forward arguments of the testing script to clang-tidy.
llvm-svn: 214952
2014-08-06 08:19:30 +00:00
Benjamin Kramer a5d954b187 [clang-tidy] Simplify ast matcher.
Turns out there is a better way to do this. No functionality change.

llvm-svn: 214874
2014-08-05 15:33:46 +00:00
Benjamin Kramer f5847cf84c [clang-tidy] Rewrite a for-range loop in the old style.
Haven't thought that I ever needed to do this, but in this case comparing the
index using pointer arithmetic turns out to be really ugly. It also generates
nasty sign-compare warnings on 32 bit targets.

llvm-svn: 214705
2014-08-04 10:11:47 +00:00
Benjamin Kramer 78cd5465f7 [clang-tidy] Fix unnamed parameter comment insertion with multiple parameters.
llvm-svn: 214703
2014-08-04 09:42:18 +00:00
Benjamin Kramer 610ba533d0 [clang-tidy] Make the named parameter check only warn on declarations if a definition is visible.
Summary:
This allows us to copy the parameter name from the definition (as a comment)
or insert /*unused*/ in both places.

Reviewers: alexfh, klimek

Subscribers: cfe-commits

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

llvm-svn: 214701
2014-08-04 09:33:58 +00:00
Alexander Kornienko da2734d4d0 Changed tool-template to use CommonOptionsParser.
Reviewers: pcc, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 214621
2014-08-02 08:24:10 +00:00