Commit Graph

566 Commits

Author SHA1 Message Date
Daniel Jasper 024ebf4a65 clang-tidy: [misc-use-override] Correctly handle defaulted destructors.
Also, minor implementation and test fixes.

llvm-svn: 211345
2014-06-20 09:12:46 +00:00
David Blaikie 92fc741998 Unbreak the build after r211244.
These operator overloads were unneeded (once the const correctness in
PooledStringPtr was corrected) and inefficient (since the strings are
pooled the pointers can just be compared for equality instead of doing
strcmp).

llvm-svn: 211245
2014-06-19 00:43:19 +00:00
Alexander Kornienko 72f1e754a7 Move google-explicit-constructor check to a separate source file.
Summary: No functional changes.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 211154
2014-06-18 09:33:46 +00:00
Rafael Espindola c7f0d23f56 Prefix error_code with std.
llvm-svn: 210840
2014-06-12 22:08:48 +00:00
Rafael Espindola 002840cf66 Quick build fix.
llvm-svn: 210838
2014-06-12 22:01:48 +00:00
Rafael Espindola fd85bb3424 include system_error directly.
llvm-svn: 210797
2014-06-12 16:53:02 +00:00
Rafael Espindola 15c5784d3c Replace llvm::error_code with std::error_code.
llvm-svn: 210776
2014-06-12 13:32:11 +00:00
Alexander Kornienko 3095b420f4 A follow-up to r210260: updated a comment. No functional changes.
llvm-svn: 210767
2014-06-12 11:25:45 +00:00
Alp Toker f77acce059 Track clang changes from r210758
llvm-svn: 210759
2014-06-12 10:16:11 +00:00
Rafael Espindola d9ba837bfd Use generic_category from the std namespace.
llvm-svn: 210735
2014-06-12 01:57:33 +00:00
Daniel Jasper 05bdb09da1 clang-tidy: [use-override] Remove 'override' if 'final' is also present.
Also, make warning more precise by distinguishing different cases.

llvm-svn: 210651
2014-06-11 12:18:24 +00:00
Alp Toker 9d63b5eb7f Prospective build fix following clang r210518
llvm-svn: 210521
2014-06-10 09:58:45 +00:00
Craig Topper 6014c49921 Simplify code. No functional change.
llvm-svn: 210508
2014-06-10 04:50:50 +00:00
Craig Topper f61be9c971 [C++11] Use 'nullptr'.
llvm-svn: 210447
2014-06-09 02:03:06 +00:00
Alexander Kornienko a46952221e Allow per-file clang-tidy options.
Summary:
This patch makes it possible for clang-tidy clients to provide
different options for different translation units. The option, which doesn't
make sense to be file-dependent, was moved to a separate ClangTidyGlobalOptions
struct. Added parsing of ClangTidyOptions.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 210260
2014-06-05 13:31:45 +00:00
Daniel Jasper c0a3fa977d clang-tidy: Make use-override tests stricter.
As per post review comment.

llvm-svn: 210173
2014-06-04 08:47:25 +00:00
Daniel Jasper 0ab7902755 clang-tidy use override: Don't generate incorrect warnings without fixes
Add basic testing for the emitted diagnostics.

llvm-svn: 210171
2014-06-04 08:26:02 +00:00
Alp Toker f88da971e5 Remove inclusions of LLVM's private config.h
llvm-svn: 210146
2014-06-04 03:34:26 +00:00
Rafael Espindola f145137516 Don't assume an implicit error_code -> bool operator.
llvm-svn: 210070
2014-06-03 04:40:55 +00:00
Alexander Kornienko 348cae8e2b Never filter-out compile errors in clang-tidy, display them as errors.
Summary:
No filters should affect the display of errors. Fixed a few tests,
which had compile errors.

We need to think what we should do with mapped errors (-Werror).

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 210044
2014-06-02 20:44:32 +00:00
Alexander Kornienko fbf9258582 Exit with error when no checks enabled.
Summary:
This seems like a more appropriate reaction to the user specifying a
single check with a wrong name, for example.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 210043
2014-06-02 20:32:06 +00:00
Daniel Jasper 88996755cb clang-tidy: Extend the use-override check to understand 'final'.
llvm-svn: 210031
2014-06-02 15:22:22 +00:00
Rafael Espindola 228166a4ca Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209953
2014-05-31 02:00:59 +00:00
Daniel Jasper a2332425c4 Revert "Remove redundant check discovered in post-commit review of r209505."
This breaks with MSVC.
With IsLateTemplateParsed, FunctionDecl::doesThisDeclarationHaveABody() returns true regardless of Body.

This reinstates what was fixed in r208985.

llvm-svn: 209896
2014-05-30 13:31:14 +00:00
Daniel Jasper 5070c18928 Remove redundant check discovered in post-commit review of r209505.
llvm-svn: 209882
2014-05-30 09:21:17 +00:00
Alexander Kornienko 1e1ad5cf9c Renamed runClangTidy argument Ranges to InputFiles, removed a TODO comment.
No functional changes.

llvm-svn: 209743
2014-05-28 15:21:14 +00:00
NAKAMURA Takumi 98247b3a75 ClangTidyOptionsTest.cpp: Rewrite literals. Raw string literals are unavailable on msc17.
llvm-svn: 209583
2014-05-24 17:22:01 +00:00
NAKAMURA Takumi f6a37d396c clang-tools-extra/test/clang-tidy/line-filter.cpp: Tweak line-filter.
On win32, %s is expanded to X:\path\to\test\line-filter.cpp. It was incompatible to yaml.
Although "%/s" could be available in Lit, ClangTidyDiagnosticConsumer::passesLineFilter() is unaware of comparision between '/' and '\\'.

llvm-svn: 209569
2014-05-24 08:42:12 +00:00
Daniel Jasper 39f9f726bc clang-tidy: Only add 'override' before inlined bodies.
llvm-svn: 209505
2014-05-23 08:52:10 +00:00
Alexander Kornienko e1f62eca2d Update the code according to the changes in r209468.
llvm-svn: 209470
2014-05-22 20:19:46 +00:00
Alexander Kornienko dad4acbc52 Add clang-tidy -line-filter option to filter findings by line ranges.
Summary:
This is going to be used for a clang-tidy-diff script to display
warnings in changed lines only. The option uses JSON, as its value is not
intended to be entered manually.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 209450
2014-05-22 16:07:11 +00:00
Manuel Klimek 5a1ef9c855 Fix clang-query on Windows: flush llvm::outs() after each command.
llvm-svn: 209313
2014-05-21 18:10:47 +00:00
Alexander Kornienko 16ff5c71ba Added a comment
llvm-svn: 209146
2014-05-19 17:46:28 +00:00
Alexander Kornienko bef51cdf05 Improved llvm-namespace-comment check.
Summary:
Handle various forms of existing namespace closing comments, fix
existing comments with wrong namespace name, ignore short namespaces.

The state of this check now seems to be enough to enable it by default to gather
user feedback ;)

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 209141
2014-05-19 16:39:08 +00:00
Daniel Jasper 993a906af3 Address review comments on r208954. No functional changes.
llvm-svn: 209111
2014-05-19 07:23:03 +00:00
Alp Toker 124084e238 Track clang changes from r209061
llvm-svn: 209062
2014-05-17 04:54:13 +00:00
NAKAMURA Takumi 81774baf4d Initializer list is unavailable. Use the constructor instead.
llvm-svn: 208986
2014-05-16 13:37:20 +00:00
NAKAMURA Takumi 2dd94635d4 clang-tidy/misc/UseOverride.cpp: Appease targeting msvc.
With IsLateTemplateParsed, FunctionDecl::doesThisDeclarationHaveABody() returns True regardless of Body.

llvm-svn: 208985
2014-05-16 13:37:08 +00:00
Alexander Kornienko 3ab3467cef Update clang-tidy documentation.
Summary:
Updated the help message, updated description of -checks=, removed
mentions of -disable-checks.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208979
2014-05-16 13:07:18 +00:00
Daniel Jasper 2378ebd537 Initial version of clang-tidy check to use override instead of virual.
Review: http://reviews.llvm.org/D3688
llvm-svn: 208954
2014-05-16 09:30:09 +00:00
Alexander Kornienko 6262d2349c Fixed incorrect StringRef::find usage.
llvm-svn: 208898
2014-05-15 15:56:58 +00:00
Alexander Kornienko 23fe95904c Change the behavior of clang-tidy -checks=, remove -disable-checks.
Summary:
Make checks filtering more intuitive and easy to use. Remove
-disable-checks and change the format of -checks= to a comma-separated list of
globs with optional '-' prefix to denote exclusion. The -checks= option is now
cumulative, so it modifies defaults, not overrides them. Each glob adds or
removes to the current set of checks, so the filter can be refined or overriden
by adding globs.

Example:
  The default value for -checks= is
  '*,-clang-analyzer-alpha*,-llvm-include-order,-llvm-namespace-comment,-google-*',
  which allows all checks except for the ones named clang-analyzer-alpha* and
  others specified with the leading '-'. To allow all google-* checks one can
  write:
    clang-tidy -checks=google-* ...
  If one needs only google-* checks, we first need to remove everything (-*):
    clang-tidy -checks=-*,google-*
  etc.

I'm not sure if we need to change something here, so I didn't touch the docs
yet.

Reviewers: klimek, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

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

llvm-svn: 208883
2014-05-15 14:27:36 +00:00
Benjamin Kramer 281f9d0e97 Update for Clang API change and move ClangTidyDiagnosticRenderer into an anonymous namespace while there.
llvm-svn: 208471
2014-05-10 16:32:07 +00:00
Alexander Kornienko c0093609b0 Allow ClangTidyDiagnosticConsumer to be reused.
llvm-svn: 208420
2014-05-09 15:50:15 +00:00
Alexander Kornienko 826b5adb6c Store Errors inside ClangTidyContext instead of just pointer to an external
array. This simplifies usage of ClangTidyContext a bit and seems to be more
consistent.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208407
2014-05-09 12:24:09 +00:00
Alexander Kornienko 5d174547a9 Print stats on displayed and ignored warnings.
Summary:
Also displays a hint to use -header-filter='.*' in case any warnings
are in non-user code. This will help discoverability of this option.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208174
2014-05-07 09:06:53 +00:00
Alexander Kornienko 238795e9c6 Fix a crash when diagnostic points to a macro definition on command line.
Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208068
2014-05-06 08:10:00 +00:00
Alexander Kornienko 4aab579d07 Fix assertion in google-explicit-constructor check when the constructor is
defined in a macro.

Summary:
We shouldn't suggest replacements in macros anyway, as we can't see all
usages of the macro and ensure the replacement is safe for all of them.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 207987
2014-05-05 18:49:31 +00:00
Alexander Kornienko 9ff5b6f3ca Add clang-tidy -header-filter option
Summary:
Add clang-tidy -header-filter option to specify from which headers we
want diagnostics to be printed. By default we don't print diagnostics from
headers. We always print diagnostics from the main file of each translation
unit.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 207970
2014-05-05 14:54:47 +00:00
Alex McCarthy 3b510bc43d Fix ClangTidyOptions constructor to initialize all members. Fixes bug introduced in r207652.
Reviewers: rsmith

Subscribers: cfe-commits, alexfh, klimek

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

llvm-svn: 207715
2014-04-30 22:32:51 +00:00