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
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
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
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
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
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
Simplify boolean expressions using `true` and `false` with `clang-tidy`
Patch by Richard Thomson.
Differential Revision: http://reviews.llvm.org/D8534
llvm-svn: 233000
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
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
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
Classes are named WhateverCheck, files are WhateverCheck.cpp and`
WhateverCheck.h`
http://reviews.llvm.org/D8144
Patch by Richard Thomson!
llvm-svn: 231650
Classes are named WhateverCheck, files are named WhateverCheck.cpp and
WhateverCheck.h.
http://reviews.llvm.org/D8145
Patch by Richard Thomson!
llvm-svn: 231648
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
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
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
* 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
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
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
* 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