Commit Graph

906 Commits

Author SHA1 Message Date
Alexander Kornienko 87638f6345 Use 'override/final' instead of 'virtual' for overridden methods
Summary:
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
      -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix

  svn diff | clang-format-diff -i

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: cfe-commits

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

llvm-svn: 234681
2015-04-11 07:59:33 +00:00
Alexander Kornienko f5e72b0448 [clang-tidy] Add readability-simplify-boolean-expr check to clang-tidy
This check looks for comparisons between boolean expressions and boolean
constants and simplifies them to just use the appropriate boolean expression
directly.

if (b == true) becomes if (b)
if (b == false) becomes if (!b)
if (b && true) becomes if (b)
if (b && false) becomes if (false)
if (b || true) becomes if (true)
if (b || false) becomes if (b)
e ? true : false becomes e
e ? false : true becomes !e
if (true) t(); else f(); becomes t();
if (false) t(); else f(); becomes f();
if (e) return true; else return false; becomes return (e);
if (e) return false; else return true; becomes return !(e);
if (e) b = true; else b = false; becomes b = e;
if (e) b = false; else b = true; becomes b = !(e);

http://reviews.llvm.org/D7648

Patch by Richard Thomson!

llvm-svn: 234626
2015-04-10 19:26:43 +00:00
Szabolcs Sipos 8429681d57 [clang-tidy] Fix for llvm.org/PR23161
The misc-static-assert check will not warn on the followings:
  assert("Some message" == NULL);
  assert(NULL == "Some message");

llvm-svn: 234596
2015-04-10 13:55:39 +00:00
Samuel Benzaquen 91d85dc6bc [clang-tidy] Ignore expressions with incompatible deleters.
Summary:
Do not warn on .reset(.release()) expressions if the deleters are not
compatible.
Using plain assignment will probably not work.

Reviewers: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 234512
2015-04-09 17:51:01 +00:00
David Blaikie 67240892a2 Remove redundant virtual from member functions marked 'override'.
llvm-svn: 234416
2015-04-08 17:00:56 +00:00
Alexander Kornienko 66d7e30b3c [clang-tidy] Fix for http://llvm.org/PR23130
NamespaceCommentCheck: Don't remove the token placed immediately after the
namespace closing brace.

llvm-svn: 234403
2015-04-08 12:54:57 +00:00
Alexander Kornienko 61753ae327 [clang-tidy] Added a couple of tests for misc-static-assert.
llvm-svn: 234094
2015-04-04 14:54:53 +00:00
Alexander Kornienko 0b024619df [clang-tidy] Clarify message for the google-explicit-constructor check
Use "constructors that are callable with a single argument" instead of
"single-argument constructors" when referring to constructors using default
arguments or parameter packs.

llvm-svn: 233702
2015-03-31 16:24:44 +00:00
Samuel Benzaquen 462501ee7e Force braces on the else branch if they are being added to the if branch.
Summary:
Force braces on the else branch if they are being added to the if branch.
This ensures consistency in the transformed code.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 233697
2015-03-31 13:53:03 +00:00
Samuel Benzaquen 3199b9a8b5 Fix false positive on anonymous namespaces in headers.
Summary:
Anynoumous namespaces inject a using directive into the AST to import
the names into the containing namespace.
We should not have them in headers, but there is another warning for
that.

Reviewers: djasper

Subscribers: cfe-commits

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

llvm-svn: 233087
2015-03-24 15:21:45 +00:00
Eli Bendersky 735e87ea75 Fix clang-tidy to not assume wrong source locations for defaulted members.
Followup to http://reviews.llvm.org/D8465, which would break a test in
clang-tidy. clang-tidy previously assumes that source locations of
defaulted/deleted members are (incorrectly) not including the '= ...' part.

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

llvm-svn: 233032
2015-03-23 22:14:08 +00:00
David Blaikie 4754aa80e5 Refactor: Simplify boolean expression in modularize
Simplify boolean expressions using `true` and `false` with `clang-tidy`

Patch by Richard Thomson.

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

llvm-svn: 233000
2015-03-23 19:40:59 +00:00
Benjamin Kramer e71037123b Make helpers static. clang-tools edition.
Also purge dead code found by it. NFC.

llvm-svn: 232948
2015-03-23 12:49:15 +00:00
Alexander Kornienko c5bc68e7ab [clang-tidy] Move google-readability-function check to readability-named-parameter.
Summary: The relevant style rule is going to be removed, thus the check is no longer needed in the Google module. Leaving the check in readability/ in case someone needs it.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 232431
2015-03-16 22:31:16 +00:00
Alexander Kornienko 4ab63a8c32 Fix ./configure build after r232338.
llvm-svn: 232340
2015-03-16 00:43:57 +00:00
Alexander Kornienko 57a5c6b56c Move remove-cstr-calls from a standalone executable to a clang-tidy check readability-redundant-string-cstr
http://reviews.llvm.org/D7318

Patch by Richard Thomson!

llvm-svn: 232338
2015-03-16 00:32:25 +00:00
Alexander Kornienko 1c4af5edf4 [clang-tidy] Fix false positives in the misc-static-assert check http://llvm.org/PR22880
The misc-static-assert check will not warn on assert(false), assert(False),
assert(FALSE); where false / False / FALSE are macros expanding to the false or
0 literals.

Also added corresponding test cases.

http://reviews.llvm.org/D8328

Patch by Szabolcs Sipos!

llvm-svn: 232306
2015-03-15 02:19:37 +00:00
NAKAMURA Takumi 0c1e8452cc Add clangBasic to libdeps according to r232051 since the interface of ASTMatchers was changed.
llvm-svn: 232138
2015-03-13 03:47:43 +00:00
Alexander Kornienko 8d6c3571b4 [clang-tidy] Remove an empty destructor.
llvm-svn: 232031
2015-03-12 12:30:10 +00:00
Gabor Horvath 343832181b [clang-tidy] Static Analyzer checker configuration options pass-through.
Reviewed by: Alexander Kornienko

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

llvm-svn: 231941
2015-03-11 17:25:22 +00:00
Alexander Kornienko 4fa0305b72 [clang-tidy] Clean up misc-use-override warning. NFC
llvm-svn: 231938
2015-03-11 16:47:27 +00:00
Alexander Kornienko 6658055488 [clang-tidy] Fixed header guards using clang-tidy llvm-header-guard check. NFC.
The patch was generated using this command:
$ clang-tidy/tool/run-clang-tidy.py -header-filter=.*clang-tidy.* -fix \
    -checks=-*,llvm-header-guard clang-tidy.*
$ svn revert --recursive clangt-tidy/llvm/
(to revert a few buggy fixes)

llvm-svn: 231669
2015-03-09 16:52:33 +00:00
Alexander Kornienko 1b677dbd44 [clang-tidy] Refactor: Rename clang-tidy readability check files and classes to follow naming conventions
Classes are named WhateverCheck, files are WhateverCheck.cpp and`
WhateverCheck.h`

http://reviews.llvm.org/D8144

Patch by Richard Thomson!

llvm-svn: 231650
2015-03-09 12:18:39 +00:00
Alexander Kornienko 5b982e539d [clang-tidy] Refactor: Rename clang-tidy misc check files and classes to follow naming conventions
Classes are named WhateverCheck, files are named WhateverCheck.cpp and
WhateverCheck.h.

http://reviews.llvm.org/D8145

Patch by Richard Thomson!

llvm-svn: 231648
2015-03-09 11:48:54 +00:00
Alexander Kornienko b2ddb8ac4d [clang-tidy] Fix assertion when a dependent expression is used in an assert.
llvm-svn: 231620
2015-03-09 02:27:57 +00:00
John Thompson 84ced5c1af Renamed function to avoid confusion about purpose.
llvm-svn: 231440
2015-03-06 00:39:42 +00:00
Daniel Jasper 08201e394e Use std::string instead of StringRef to prevent use-after-free.
Discovered by asan.

llvm-svn: 231421
2015-03-05 23:17:32 +00:00
Alexander Kornienko 333d81121d [clang-tidy] Slighly clarified a comment.
llvm-svn: 231370
2015-03-05 14:58:03 +00:00
Alexander Kornienko da4ebb219b [clang-tidy] Replace unrecognized namespace ending comments.
Summary:
Replace unrecognized namespace ending comments. This will help in particular when a namespace ending comment is mistyped or doesn't fit the regexp for other reason, e.g.:

  namespace a {
  namespace b {
  namespace {
  } // anoynmous namespace
  } // b
  } // namesapce a

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 231369
2015-03-05 14:56:11 +00:00
Alexander Kornienko ed07a255da [clang-tidy] Fix diag message in clang-tidy misc-uniqueptr-reset-release if right side is rvalue
http://reviews.llvm.org/D8071

Patch by Alexey Sokolov!

llvm-svn: 231365
2015-03-05 13:53:21 +00:00
Alexander Kornienko ed824e0e4b [clang-tidy] Refactor: Move google clang-tidy checks to namespace clang::tidy::google
http://reviews.llvm.org/D7994

Patch by Richard Thomson!

llvm-svn: 231364
2015-03-05 13:46:14 +00:00
Alexander Kornienko df0ab6acdf [clang-tidy] Fix namespace comments. NFC.
llvm-svn: 231267
2015-03-04 18:01:10 +00:00
Alexander Kornienko ad53695a09 [clang-tidy] Output more diagnostics in check_clang_tidy.sh
Print clang-tidy output and fixes applied.

llvm-svn: 231236
2015-03-04 12:07:50 +00:00
Filipe Cabecinhas 3be5b7fb43 Add -fexceptions for targets which need it
llvm-svn: 230994
2015-03-02 19:12:51 +00:00
Daniel Jasper 136f4b3439 clang-tidy: Update test as underlying problem apparently was fixed.
llvm-svn: 230982
2015-03-02 18:07:00 +00:00
Alexander Kornienko 0a6ce9f4e1 [clang-tidy] Refactor: Move llvm clang-tidy checks to namespace clang::tidy::llvm
clang-tidy checks are organized into modules. This refactoring moves the llvm
module checks to clang::tidy::llvm

http://reviews.llvm.org/D7995

Patch by Richard Thomson!

llvm-svn: 230952
2015-03-02 12:39:18 +00:00
Alexander Kornienko 2b312420aa [clang-tidy] Refactor: Move misc clang-tidy checks to namespace clang::tidy::misc
clang-tidy checks are organized into modules. This refactoring moves the misc
module checks into the namespace clang::tidy::misc

http://reviews.llvm.org/D7996

Patch by Richard Thomson!

llvm-svn: 230950
2015-03-02 12:25:03 +00:00
Alexander Kornienko 37f80456ce [clang-tidy] Organized clang-tidy unit tests. NFC.
* Moved unit tests for BracesAroundStatementsCheck to
    ReadabilityModuleTest.cpp.
  * Moved EXPECT_NO_CHANGES macro to ClangTidyTest.h to avoid defining it three
    times.

llvm-svn: 230947
2015-03-02 11:55:04 +00:00
Alexander Kornienko 8384d491d8 [clang-tidy] Refactor: Move readability checks to namespace clang::tidy::readability
clang-tidy checks are organized into modules. This refactoring moves the
readability module checks into the namespace clang::tidy::readability

http://reviews.llvm.org/D7997

Patch by Richard Thomson!

llvm-svn: 230946
2015-03-02 11:43:00 +00:00
Alexander Kornienko 1ca3b83255 [clang-tidy] Assert related checkers
This patch contains two assert related checkers. These checkers are the part of
those that is being open sourced by Ericsson
(http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-December/040520.html).

The checkers:

AssertSideEffect:
/// \brief Finds \c assert() with side effect.
///
/// The conition of \c assert() is evaluated only in debug builds so a condition
/// with side effect can cause different behaviour in debug / relesase builds.

StaticAssert:
/// \brief Replaces \c assert() with \c static_assert() if the condition is 
/// evaluatable at compile time.
///
/// The condition of \c static_assert() is evaluated at compile time which is
/// safer and more efficient.

http://reviews.llvm.org/D7375

Patch by Szabolcs Sipos!

llvm-svn: 230943
2015-03-02 10:46:43 +00:00
Samuel Benzaquen e39269e790 Add 'let' to the help message.
Summary: Add 'let' to the help message.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 230768
2015-02-27 17:53:23 +00:00
Alexander Kornienko dd836f238d [clang-tidy] Various improvements in misc-use-override
* Better error message when more than one of 'virtual', 'override' and 'final'
    is present ("X is/are redundant since the function is already declared Y").
  * Convert the messages to the style used in Clang diagnostics: lower case
    initial letter, no trailing period.
  * Don't run the check for files compiled in pre-C++11 mode
    (http://llvm.org/PR22638).

llvm-svn: 230765
2015-02-27 16:50:32 +00:00
John Thompson b70ecf6eef Fixed canonical path function.
llvm-svn: 230665
2015-02-26 19:31:10 +00:00
David Majnemer d264827229 Update for clang r230512
llvm-svn: 230513
2015-02-25 17:36:49 +00:00
Alexander Kornienko 4c0e4a12bd [clang-tidy] Use the new ArrayRef<FixItHint> inserter.
llvm-svn: 230497
2015-02-25 14:42:02 +00:00
Alexander Kornienko 6d02cc8d65 [clang-tidy] Correct spelling error in test file name. NFC.
Patch by Richard Thomson!
http://reviews.llvm.org/D7603

llvm-svn: 230491
2015-02-25 13:17:14 +00:00
Alexander Kornienko 8cef0752f5 [clang-tidy] Correct confusion between overwrite and override. NFC.
Patch by Richard Thomson!
http://reviews.llvm.org/D7604

llvm-svn: 230490
2015-02-25 13:05:33 +00:00
Gabor Horvath ca0bbff3a7 [clang-tidy] Fixed a false positive case in misc-inaccurate-erase checker.
llvm-svn: 230483
2015-02-25 12:17:03 +00:00
Adrian Prantl b97f5c1eb2 Revert "Adapt clang-tools-extra to clang module format changes."
This reverts commit 230424.

llvm-svn: 230456
2015-02-25 02:46:37 +00:00
Adrian Prantl 2be16291ff Revert "Add a missing target requirement."
This reverts commit 230430.

llvm-svn: 230455
2015-02-25 02:46:29 +00:00