Граф коммитов

679 Коммитов

Автор SHA1 Сообщение Дата
Angel Garcia Gomez b18f7db7bc Make the modernize-loop-convert's const-detection smarter.
Summary:
Now, it detects that several kinds of usages are can't modify the elements. Examples:
-When an usage is a call to a const member function or operator of the element.
-If the element is used as an argument to a function or constructor that takes a const-reference or a value.
-LValue to RValue conversion, if the element is a fundamental type (which allows the use of most of the builtin operators).

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251808 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 17:02:52 +00:00
Angel Garcia Gomez 17ad46c81e Fix another crash in the redundant-void-arg check.
Summary: The check was assuming that a definition of a function always has a body, but a declaration that explicitly defaults or deletes a function is a definition too.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251807 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 16:18:23 +00:00
Angel Garcia Gomez ec0b777860 Remove unreachable that was reached in modernize-use-nullptr.
Summary: When traversing the parent map, the check assumed that all the nodes would be either Stmt or Decl. After r251101, this is no longer true: there can be TypeLoc and NestedNameSpecifierLoc nodes.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251803 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 15:28:06 +00:00
Angel Garcia Gomez 823f52c6c3 Fix crash in redundant-void-arg check.
Summary:
When applying this check to the unit tests, it would hit an assertion:
llvm/tools/clang/lib/Lex/Lexer.cpp:1056: clang::SourceLocation clang::Lexer::getSourceLocation(const char*, unsigned int) const: Assertion `PP && "This doesn't work on raw lexers"' failed.

Reviewers: klimek, LegalizeAdulthood, alexfh

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251792 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 11:39:17 +00:00
Angel Garcia Gomez 08712a88a9 Try to fix buildbots failure.
Summary: Add -fexceptions flag to enable exceptions.

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251790 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 10:54:50 +00:00
Angel Garcia Gomez 5de4992056 modernize-use-default supports copy constructor and copy-assignment operator.
Summary: the check will now warn when the user provided definitions of this functions is equivalent to the explicitly defaulted ones.

Reviewers: klimek

Subscribers: klimek, cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251788 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02 10:34:19 +00:00
Angel Garcia Gomez 7274710da2 Only copy small types in modernize-loop-convert.
Summary: If the size of the type is above a certain bound, we'll take a const reference. This bound can be set as an option. For now, the default value is 16 bytes.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251694 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-30 09:37:57 +00:00
Daniel Jasper c9e531b7e5 Change test to just define NULL instead of #including stddef.h. In some
test environments, even that builtin header isn't available. Also, this
makes it more consistent with the C++ version of this test.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251520 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 14:51:09 +00:00
NAKAMURA Takumi 248c34c5d8 clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.c: Use <stddef.h> provided by clang, instead of <stdio.h>.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251503 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 09:22:21 +00:00
Benjamin Kramer 2ec654d830 [tidy] Remove stray iostream include from test.
It is unused and we cannot rely on standard headers being present while
executing tests.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251499 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 05:16:37 +00:00
Alexander Kornienko 3a15aab833 Add modernize-redundant-void-arg check to clang-tidy
This check for clang-tidy looks for function with zero arguments declared as (void) and removes the unnecessary void token.

  int foo(void);

becomes

  int foo();

The check performs no formatting of the surrounding context but uses the lexer to look for the token sequence "(", "void", ")" in the prototype text. If this sequence of tokens is found, a removal is issued for the void token only.


Patch by Richard Thomson!

(+fixed tests, moved the check to the modernize module)

Differential revision: http://reviews.llvm.org/D7639


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251475 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 01:36:20 +00:00
Matthias Gehre 40fe18c79e [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay
Summary:
This check flags all array to pointer decays.

Pointers should not be used as arrays. array_view is a bounds-checked,
safe alternative to using pointers to access arrays.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251358 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-26 21:56:02 +00:00
Piotr Dziwinski 33986728ce [clang-tidy] Another fix for failing buildbots regarding signedness of char
I totally forgot that char can be defined as unsigned on some platforms.
Now I made explicit mention of signed type where necessary in tests.

Also fixed '//RUN: ' header of cxx98 test to correct format.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251244 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-25 17:11:13 +00:00
Piotr Dziwinski a1858d23a8 [clang-tidy] Fix for build bots not liking #include <cstddef>
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251239 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-25 15:47:21 +00:00
Piotr Dziwinski 98e9c93c33 [clang-tidy] Add check readability-implicit-bool-cast
Summary:
This is another check that I ported to clang-tidy from colobot-lint tool.

As previously discussed on cfe-dev mailing list, this is one of those
checks that I think is general and useful enough for contribution to
clang-tidy.

This patch contains implementation of check taken from colobot-lint, but
it is extended a great deal, including FixIt hints for automated
refactoring, exhaustive testcases, and user documentation.

Reviewers: sbenza, aaron.ballman, alexfh

Subscribers: Eugene.Zelenko

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-25 15:31:25 +00:00
Manuel Klimek debf80be84 Make isExpensiveToCopy() tri-state.
This allows returning "don't know" for dependent types.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251103 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-23 10:00:50 +00:00
Manuel Klimek 9a9a457fcb Switch check_clang_tidy to argparse and add a -resource-dir argument.
-resource-dir can be used to inject non-standard resource dirs via the
lit site config.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251021 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 14:54:50 +00:00
Angel Garcia Gomez bccbb3ead7 Don't use "auto" on loops over fundamental types in modernize-loop-convert.
Summary: using "auto" on a loop that iterates over ints is kind of an overkill. Use the real type name instead.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251015 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 13:23:46 +00:00
Angel Garcia Gomez eb2ff2705a Correctly print the type in modernize-make-unique.
Summary: Take into account the current LangOptions the check has to add back the template argument.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251013 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 13:20:49 +00:00
Manuel Klimek 82aa9cf440 Add %check_clang_tidy and %clang_tidy_diff.
With this, site specific lit configs can inject parameters into the
test scripts if they need site specific parameters.

Next up: enable check_clang_tidy to take a resource dir to enable
non-standard locations for builtin includes.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@251010 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 11:31:44 +00:00
NAKAMURA Takumi 4f2fb9c439 clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp: Tweak not to depend on out-of-tree header <cstdarg>.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250986 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 04:51:47 +00:00
NAKAMURA Takumi 5b0326ae44 clang-tools-extra/test/clang-tidy/modernize-use-default.cpp: Appease MS mode.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250983 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 04:32:21 +00:00
Matthias Gehre d8975af281 [clang-tidy] add check cppcoreguidelines-pro-type-vararg
Summary:
This check flags all calls to c-style vararg functions and all use
of va_list, va_start and va_arg.

Passing to varargs assumes the correct type will be read. This is
fragile because it cannot generally be enforced to be safe in the
language and so relies on programmer discipline to get it right.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead

This commits also reverts
  "[clang-tidy] add cert's VariadicFunctionDefCheck as cppcoreguidelines-pro-type-vararg-def"
because that check makes the SFINAE use of vararg functions impossible.

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250939 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 20:09:02 +00:00
Angel Garcia Gomez 550e301864 Add modernize-use-default check to clang-tidy.
Summary:
Add a check that replaces empty bodies of special member functions with '= default;'.
For now, it is only implemented for the default constructor and the destructor, which are the easier cases.
The copy-constructor and the copy-assignment operator cases will be implemented later.

I applied this check to the llvm code base and found 627 warnings (385 in llvm, 9 in compiler-rt, 220 in clang and 13 in clang-tools-extra).
Applying the fixes didn't break any build or test, it only caused a -Wpedantic warning in lib/Target/Mips/MipsOptionRecord.h:33 becaused it replaced
virtual ~MipsOptionRecord(){}; to virtual ~MipsOptionRecord()= default;;

Reviewers: klimek

Subscribers: george.burgess.iv, Eugene.Zelenko, alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250897 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 12:58:15 +00:00
Samuel Benzaquen ed971c0759 Added check uniqueptr-delete-release to replace "delete x.release()" with "x = nullptr"
Reviewers: alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250742 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-19 21:49:51 +00:00
Matthias Gehre 776233f9a3 [clang-tidy] add check cppcoreguidelines-pro-type-union-access
Summary:
This check flags all access to members of unions. Passing unions as a
whole is not flagged.

Reading from a union member assumes that member was the last one
written, and writing to a union member assumes another member with a
nontrivial destructor had its destructor called. This is fragile because
it cannot generally be enforced to be safe in the language and so relies
on programmer discipline to get it right.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type7-avoid-accessing-members-of-raw-unions-prefer-variant-instead

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250537 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16 18:46:30 +00:00
Angel Garcia Gomez 40928b2725 Replacements in different files do not overlap.
Summary: Prevent clang-tidy from discarding fixes that are in different files but happen to have the same file offset.

Reviewers: klimek, bkramer

Subscribers: bkramer, alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250523 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16 16:15:27 +00:00
Angel Garcia Gomez 26123d013c Use __SIZE_TYPE__ to fix buildbot failures.
Summary: Use __SIZE_TYPE__ to fix buildbot failures.

Reviewers: klimek

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250288 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 10:30:32 +00:00
Angel Garcia Gomez c3f968272f Prevent modernize-use-auto from emitting a warning when 'auto' was already being used.
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=25082 .

Reviewers: bkramer, klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250284 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 09:29:55 +00:00
Angel Garcia Gomez 5b943fc586 Support every kind of initialization.
Summary: modernize-make-unique now correctly supports the different kinds of list initialization.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250283 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 09:22:32 +00:00
Aaron Ballman f535df4313 Expose the clang-tidy misc-assign-operator-signature checker as cppcoreguidelines-c-copy-assignment-signature.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 15:24:33 +00:00
Matthias Gehre 3105766d1d [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic
Summary:
This check flags all usage of pointer arithmetic, because it could lead
to an
invalid pointer.
Subtraction of two pointers is not flagged by this check.

Pointers should only refer to single objects, and pointer arithmetic is
fragile and easy to get wrong. array_view is a bounds-checked, safe type
for accessing arrays of data.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds1-dont-use-pointer-arithmetic-use-array_view-instead

Depends on D13313

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12 21:53:19 +00:00
Matthias Gehre d07f76b209 [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast
Summary:
This check flags all usages of static_cast, where a base class is casted
to a derived class.
In those cases, a fixit is provided to convert the cast to a
dynamic_cast.

Use of these casts can violate type safety and cause the program to
access a variable that is actually of type X to be accessed as if it
were of an unrelated type Z.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type2-dont-use-static_cast-downcasts-use-dynamic_cast-instead

Depends on D13313

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250098 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12 20:46:53 +00:00
Aaron Ballman bfae702f9f Explicitly enable -fcxx-exceptions for this test to appease Windows build bots.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249905 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 21:15:00 +00:00
Aaron Ballman 7819030d5a Add a new checker that tests whether a throw expression throws by value, and whether a catch statement catches by reference.
Patch by Tobias Langner!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 20:42:44 +00:00
Aaron Ballman 52781d8060 Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249727 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 19:54:43 +00:00
Aaron Ballman e815e70c6a Fixing links and reformatting code; NFC.
Patch by Marek Kurdej!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 20:33:36 +00:00
Aaron Ballman 08ae890c8b Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 15:14:10 +00:00
Aaron Ballman fa0bfc95a3 Add checker for the C++ Core Guidelines: cppcoreguidelines-pro-type-const-cast.
Patch by Matthias Gehre!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249540 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 12:24:57 +00:00
Aaron Ballman 5c40d3f5af Improved the misc-move-constructor-init check to identify arguments that are passed by value but copy assigned to class data members when the non-deleted move constructor is a better fit.
Patch by Felix Berger!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249429 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 16:27:03 +00:00
Aaron Ballman d2ec07d917 Add a new module for the C++ Core Guidelines, and the first checker for those guidelines: cppcoreguidelines-pro-type-reinterpret-cast.
Patch by Matthias Gehre!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249399 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 13:31:00 +00:00
Aaron Ballman fcf78a42ad Adding a checker (cert-dcl50-cpp) that detects the definition of a C-style variadic function in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249343 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 20:08:59 +00:00
Angel Garcia Gomez bc522ba6ce Use better mocks in modernize-make-unique, and fix matcher.
Summary: Add the second template argument to the unique_ptr mock, and update the matcher so that it only matches against cases where the second argument is the default.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249305 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 12:20:17 +00:00
Angel Garcia Gomez c820163ebb Document a bug in loop-convert and fix one of its subcases.
Summary: Now that we prioritize copying trivial types over using const-references where possible, I found some cases where, after the transformation, the loop was using the address of the local copy instead of the original object.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 11:15:39 +00:00
Angel Garcia Gomez e294083dce Fix bug in modernize-use-nullptr.
Summary:
https://llvm.org/bugs/show_bug.cgi?id=24960

modernize-use-nullptr would hit an assertion in some cases involving macros and initializer lists, due to finding a node with more than one parent (the two forms of the initializer list).

However, this doesn't mean that the replacement is incorrect, so instead of just rejecting this case I tried to find a way to make it work. Looking at the semantic form of the InitListExpr made sense to me (looking at both forms results in false negatives) but I am not sure of the things that we can miss by skipping the syntactic form.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 08:40:13 +00:00
Angel Garcia Gomez 2c5fed3800 Handle trailing underscores on modernize-loop-convert variable namer.
Summary: https://llvm.org/bugs/show_bug.cgi?id=24961.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249127 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 13:20:11 +00:00
Angel Garcia Gomez 914d6af0ea Prevent loop-convert from leaving empty lines after removing an alias declaration.
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=17716.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249006 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 13:08:21 +00:00
Alexander Kornienko da72ce1a7a [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck
This diff requires http://reviews.llvm.org/D13079 to be applied first. I wasn't sure about how to make patch series in Phabricator, and I wanted to keep the two separate for clarity.

It looks like that most cases can be supported with this patch. I'm not totally sure about the actual coverage though. I think that the matchers are very generic, but I'm still not totally fluent with the AST.

Patch by Beren Minor!

Differential revision: http://reviews.llvm.org/D13081


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248996 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 09:19:40 +00:00
Angel Garcia Gomez 4c33686a42 Add support for 'cbegin()' and 'cend()' on modernize-loop-convert.
Summary:
This fixes https://llvm.org/bugs/show_bug.cgi?id=22196 .

Also add a non-trivially copyable type to fix some tests that were meant to be about using const-refs, but were changed in r248438.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248994 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 08:57:11 +00:00
Aaron Ballman 31ab7f0dc9 Adding a checker (misc-non-copyable-objects) that detects situations where a non-copyable C type is being dereferenced, such as FILE or pthread_mutex_t. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248907 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 14:09:38 +00:00
Alexander Kornienko 3534791046 [clang-tidy] Added missing check lines, made the checking stricter.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 13:32:42 +00:00
Alexander Kornienko 5726ddb8af [clang-tidy] Fix an assertion in the readability-braces-around-statements check.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248895 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 12:48:42 +00:00
Alexander Kornienko 8a772cdfc8 [clang-tidy] Better diagnostic in tests when clang-tidy fails.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248886 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 10:41:53 +00:00
Aaron Ballman 8c7e0deeae Some of the build bots are unhappy about the overload of the global operator new() because it was accidentally marked noexcept instead of noexcept(false). This should correct those bots.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248797 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 14:26:00 +00:00
Aaron Ballman cb1ea4a031 Silencing bot failures a more creative and definitive way.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248794 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:38:00 +00:00
Aaron Ballman 91c3260b19 Hopefully silencing some built bot warnings. Note, this should be unsigned long instead of unsigned int, but then *other* builds start to fail because of duplicate redefinitions of size_t.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248792 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:20:26 +00:00
Aaron Ballman 2c2b89e115 Adding a checker (misc-new-delete-overloads) that detects mismatched overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248791 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:12:21 +00:00
Angel Garcia Gomez cb57731fb0 Create modernize-make-unique check.
Summary: create a check that replaces 'std::unique_ptr<type>(new type(args...))' with 'std::make_unique<type>(args...)'. It was on the list of "Ideas for new Tools". It needs to be tested more carefully, but first I wanted to know if you think it is worth the effort.

Reviewers: klimek

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248785 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 09:36:41 +00:00
Alexander Kornienko a13378c76a [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck
This is to level the ground a little bit, in preparation for the changes in http://reviews.llvm.org/D13081.

Code factorization replaces all insertions to NamingCheckFailures map with a unique addUsage function that does the job.
There is also no more difference between the declaration and the references to a given identifier, both cases are treated as ranges in the Usage vector. There is also a check to avoid duplicated ranges to be inserted, which sometimes triggered erroneous replacements.

References can now also be added before the declaration of the identifier is actually found; this looks to be the case for example when a templated class uses its parameters to specialize its templated base class.

Patch by Beren Minor!

Differential revision: http://reviews.llvm.org/D13079


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248700 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-28 08:59:12 +00:00
Angel Garcia Gomez b9d0ad92be Add NamingStyle option to modernize-loop-convert.
Summary: Add an option to specify wich style must be followed when choosing the new index name.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248517 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-24 17:02:19 +00:00
Angel Garcia Gomez 6dc0fe72fc Remove dangling parenthesis.
Summary: Remove parenthesis surrounding the new loop index.

Reviewers: klimek

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248507 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-24 15:29:46 +00:00
Manuel Klimek 2833619755 Fix loop-convert for trivially copyable types.
Previously, we would rewrite:
void f(const vector<int> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
to
  for (const auto &elem : v) {

Now we rewrite it to:
  for (auto elem : v) {
(and similarly for iterator based loops).

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248438 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-23 22:28:14 +00:00
Manuel Klimek 93e55f7911 Fix loop-convert for const references to containers.
Previously we would use a non-const loop variable in the range-based
loop for:
void f(const std::vector<int> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
Now we use const auto&.

Note that we'll also want to use a copy at least for simple types.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248418 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-23 18:40:47 +00:00
Daniel Jasper 50a5da46a1 misc-unused-parameter: Ignore lambda static invokers.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248252 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 09:20:20 +00:00
Angel Garcia Gomez 2d2353f8dc Refactor LoopConvertCheck.
Summary: Reorder the code in a more logical and understandable way.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248144 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-21 09:32:59 +00:00
Angel Garcia Gomez 4787a0a59f Add a test to modernize-loop-convert.
Summary: Add the test about replacements in several arguments of the same macro call, now that the problem has been fixed.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247889 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-17 14:25:39 +00:00
Alexander Kornienko 1f8962c296 [clang-tidy] google-runtime-int: made the matcher more restricting, added a test for a false positive
This should be NFC.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-16 15:08:46 +00:00
Alexander Kornienko c81a70f948 [clang-tidy] Make google-runtime-int configurable.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247803 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-16 14:36:22 +00:00
NAKAMURA Takumi 0a9677f8fe Remove garbage. The issue was fixed in r246856.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-15 14:01:09 +00:00
Alexander Kornienko d54f17ae1d [clang-tidy] misc-sizeof-container: remove fix-it hints
This turned out to be a rather noisy check, so automated fixes will only do
harm. Remove them completely.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247578 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-14 16:51:52 +00:00
Alexander Kornienko fed112bf67 [clang-tidy] misc-sizeof-container: whitelist std::array
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247559 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-14 13:55:29 +00:00
Alexander Kornienko da6de9b254 [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.
It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247489 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11 22:54:44 +00:00
Alexander Kornienko cb58bfcb4d [clang-tidy] Fix minor issues in the testing script.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11 22:38:26 +00:00
Angel Garcia Gomez aeb5f8d72b Another patch for modernize-loop-convert.
Summary:
1. Avoid converting loops that iterate over the size of a container and don't use its elements, as this would result in an unused-result warning.
2. Never capture the elements by value on lambdas, thus avoiding doing unnecessary copies and errors with non-copyable types.
3. The 'const auto &' instead of 'auto &' substitution on const containers now works on arrays and pseudoarrays as well.
4. The error about multiple replacements in the same macro call is now documented in the tests (not solved though).
5. Due to [1], I had to add a dummy usage of the range element (like "(void) *It;" or similars) on the tests that had empty loops.
6. I removed the braces from the CHECK comments. I think that there is no need for them, and they confuse vim.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247399 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11 10:02:07 +00:00
NAKAMURA Takumi cd06a523c6 clang-tidy/misc-sizeof-container.cpp: Add explicit triple.
For targeting LLP64, like Windows x86, size_t is not unsigned long.

  tools/clang/tools/extra/test/clang-tidy/Output/misc-sizeof-container.cpp.tmp.cpp:33:12: error: target of using declaration conflicts with declaration already in scope [clang-diagnostic-error]
  using std::size_t;
             ^

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247394 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11 08:16:30 +00:00
NAKAMURA Takumi 29e1c4474f clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247393 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-11 08:16:22 +00:00
Alexander Kornienko 5140308939 [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stl
containers.

Summary:
sizeof(some_std_string) is likely to be an error. This check finds this
pattern and suggests using .size() instead.

Reviewers: djasper, klimek, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247297 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 16:37:46 +00:00
Alexander Kornienko 16b40d6514 [clang-tidy] Renamed tests files to be closer to the check names.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247266 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 10:58:38 +00:00
Alexander Kornienko 340f73f358 [clang-tidy] Add inconsistent declaration parameter name check
This is first of series of patches, porting code from my project colobot-lint,
as I mentioned recently in cfe-dev mailing list.

This patch adds a new check in readability module:
readability-inconsistent-declaration-parameter-name. I also added appropriate
testcases and documentation.

I chose readability module, as it seems it is the best place for it.

I think I followed the rules of LLVM coding guideline, but I may have missed
something, as I usually use other code formatting style.

http://reviews.llvm.org/D12462

Patch by Piotr Dziwinski!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 10:07:11 +00:00
Alexander Kornienko 47416811ac [clang-tidy] Fix PR22785.
Fix http://llvm.org/PR22785. Bug 22785 - readability-braces-around-statements
doesn't work well with macros.

http://reviews.llvm.org/D12729

Patch by Marek Kurdej!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@247163 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-09 17:06:09 +00:00
Angel Garcia Gomez 915a754db5 Avoid using rvalue references with trivially copyable types.
Summary:
When the dereference operator returns a value that is trivially
copyable (like a pointer), copy it. After this change, modernize-loop-convert
check can be applied to the whole llvm source code without breaking any build
or test.

Reviewers: alexfh, klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246989 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 09:01:21 +00:00
Angel Garcia Gomez 77ada21fd5 Avoid repeated replacements on loop-convert check.
Summary: The InitListExpr subtree is visited twice, this caused the check to do multiple replacements. Added a set to avoid it.

Reviewers: klimek, alexfh

Subscribers: cfe-commits, alexfh

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246879 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-04 21:37:05 +00:00
Alexander Kornienko 344639aa33 [clang-tidy] Fix llvm-include-order check on Windows.
IncludeDirectives struct used a StringRef that pointed to a stack variable
(SmallString<128> FilenameBuffer from PPDirectives.cpp:1513).

http://reviews.llvm.org/D12632

Patch by Marek Kurdej!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246856 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-04 15:46:51 +00:00
Angel Garcia Gomez f791a2b443 Two more fixes to loop convert.
Summary: Ensure that the alias has the same type than the loop variable. Now it works with lambda captures.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246762 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-03 12:28:11 +00:00
Angel Garcia Gomez 4497fda2f3 Fix loop-convert crash.
Summary: loop-convert no longer crashes when calling a member function using a member pointer which is a member of another record.

Reviewers: alexfh, klimek

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246655 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-02 14:25:08 +00:00
Angel Garcia Gomez 473ac6e964 Fix use-auto-check.
Summary: Fix a bug where use-auto check would crash when the definition of a type is in the same statement than its instantiation with new.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246638 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-02 10:20:00 +00:00
Angel Garcia Gomez 8a16759017 Fix several corner cases for loop-convert check.
Summary: Reduced the amount of wrong conversions of this check.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246550 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-01 15:05:15 +00:00
Aaron Ballman e401b5a840 Allow the static assert clang-tidy checker to run over C code.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246495 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 21:54:42 +00:00
Aaron Ballman 3711dea499 Help the clang-tidy helper script to understand C files better.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246494 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 21:53:55 +00:00
Alexander Kornienko a430467d0e [clang-tidy] misc-assert-side-effect: support assert macros defined through other macros
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246446 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 14:47:14 +00:00
Alexander Kornienko d356642296 [clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"
These checks are focusing on migrating the code from C++98/03 to C++11, so they
belong to the modernize module.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246437 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 13:17:43 +00:00
Aaron Ballman fbf0ffc607 Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the checkers do not require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246318 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 19:27:19 +00:00
Aaron Ballman c9bb1cff21 Disable several more clang-tidy modernize checkers when not compiling in C++ mode. Loop conversion would make recommendations for C code, so added a test to ensure that does not happen. The pass by value, use auto and replace auto_ptr checkers would not make recommendations for C code, and are disabled for performance reasons, but do not require an extra test.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246310 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 17:58:10 +00:00
Aaron Ballman 56c3af312b Reapplying r246209, which exposed language options to the checkers. This time disable UseNullptrCheck when not compiling in C++ mode, but still allow in C++11 mode since it's likely the user wishes to modernize their code.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246298 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 13:20:46 +00:00
Alexander Kornienko 8e50bd634a [clang-tidy] Documented the reason to run the test in C++98 mode.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246238 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 23:43:39 +00:00
Aaron Ballman 38d515203f Reverting r246209 while I investigate a build bot failure: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/30516
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246224 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 22:19:50 +00:00
Aaron Ballman c95659f8a2 Expose language options to the checkers; disable UseNullptrCheck when not compiling in C++11 mode.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246209 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 21:17:47 +00:00
Alexander Kornienko 21940bf5bc [clang-tidy] Renamed a test file to <check-name>.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246170 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 18:03:37 +00:00
Angel Garcia Gomez 1789309d16 Fix another LoopConvert fail.
Summary: Prevent LoopConvert from taking as alias anything that comes from a random member function call.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246039 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26 17:08:24 +00:00
Angel Garcia Gomez c186910441 LoopConvert no longer take as alias references to other containers.
Summary: Fix a bug where modernize-loop-convert check would take as alias a reference to other containers. Add the pertinent test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@246034 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26 14:51:11 +00:00
Angel Garcia Gomez 3035fc1706 Avoid LoopConvertCheck replacements in template instantiations.
Summary: Prevent LoopConvertCheck from doing replacements in template instantiations, and add a test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245942 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-25 15:44:00 +00:00
Angel Garcia Gomez 43cfbf1a98 Add replace-auto_ptr check.
Summary: Migrate replace-auto_ptr check from clang-modernize to modernize module in clang-tidy.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245933 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-25 13:03:43 +00:00
Angel Garcia Gomez 4ec41cc403 [clang-tidy] Migrate UseAuto from clang-modernize to clang-tidy.
http://reviews.llvm.org/D12231


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245703 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21 15:08:51 +00:00
Alexander Kornienko 46bb912039 [clang-tidy] Remove check_clang_tidy.sh that has been replaced with check_clang_tidy.py.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245699 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21 12:41:14 +00:00
Yaron Keren ddcf421d05 Make test EOL tolerant by moving the symbol ot the first line
before any EOL changes the byte offset count and enable it on Windows.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245688 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21 10:46:46 +00:00
Aaron Ballman a696c7fa1e Change the test to use the new python script instead of the more verbose RUN line.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245600 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 19:21:07 +00:00
Alexander Kornienko 5fd9bc99b2 [clang-tidy] Use a python script instead of a shell script to run clang-tidy tests.
Summary:
Add check_clang_tidy.py script that is functionally identical to the
check_clang_tidy.py, but should also be functional on windows.

I've verified that the script works on linux. Would be nice if folks using
Windows could test the patch before I break windows bots ;)

Reviewers: chapuni, aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245583 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 17:58:07 +00:00
Aaron Ballman 9116e194f2 Add a new clang-tidy check (misc-move-constructor-init) that diagnoses move constructor initializations that call copy constructors instead of move constructors.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245571 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 15:52:52 +00:00
NAKAMURA Takumi a729532225 Tweak clang-tidy-diff.py to pass JSON argument correctly to clang-tidy on win32 arg parser.
- Single quotation is not recognized.
  - Use """ to pass a double quotation.

It also reverts r211831.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245567 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 15:04:46 +00:00
NAKAMURA Takumi e63c1357d5 Tweak clang-tools-extra/test/clang-tidy/file-filter.cpp to pass on win32.
FIXME: "-I %S/Inputs/file-filter/system/.." must be redundant.
On Win32, file-filter/system\system-header1.h precedes file-filter\header*.h due to code order between '/' and '\\'.

We should remove such a tweak to introduce the *right* path canonicalization.

Posix:
  file-filter/header*.h
  file-filter/system/system-header1.h

Win32:
  file-filter/system\system-header1.h
  file-filter\header*.h

Win32, tweaked:
  file-filter/system/..\header*.h
  file-filter/system\system-header1.h

It had been disabled since r220837.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 15:04:39 +00:00
NAKAMURA Takumi 53a6d908da clang-tools-extra/test/lit.cfg: Prune an obsolete feature, python27. Now we requires python>=2.7.
clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp was the only user.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245565 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 15:04:32 +00:00
Alexander Kornienko 0411b8b91e [clang-tidy] Fix bug in modernize-loop-convert check.
http://reviews.llvm.org/D12186

Patch by Angel Garcia!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245561 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 13:18:23 +00:00
Alexander Kornienko e6927b28f5 [clang-tidy] Add back a test with a custom NULL macro. Remove redundant default.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245533 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20 01:44:14 +00:00
Alexander Kornienko 6e9233e3d6 [clang-tidy] Add modernize-use-nullptr check, attempt 2.
This patch re-applies r245434 and r245471 reverted in r245493, and changes the
way custom null macros are configured. The test for custom null macros is
temporarily excluded and will be committed separately to reduce chances of
breakages.

Initial patches by Angel Garcia.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245511 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 22:21:37 +00:00
Justin Bogner 95bfe5b6b8 Revert "[clang-tidy] Add use-nullptr check to clang-tidy."
The new test is failing on darwin:

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/10339/

This reverts r245434 and its follow up r245471.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245493 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 20:30:07 +00:00
NAKAMURA Takumi e8b6bc07f8 clang-tools-extra/test/clang-tidy/readability-identifier-naming.cpp: Appease targeting msvc.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245435 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 13:22:58 +00:00
Alexander Kornienko 3d0e75d69e [clang-tidy] Add use-nullptr check to clang-tidy.
Move UseNullptr from clang-modernize to modernize module in clang-tidy.

http://reviews.llvm.org/D12081

Patch by Angel Garcia!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245434 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 13:13:12 +00:00
Alexander Kornienko 89b8288d86 [clang-tidy] Add new IdentifierNaming check
This check will try to enforce coding guidelines on the identifiers naming.
It supports lower_case, UPPER_CASE, camelBack and CamelCase casing and
tries to convert from one to another if a mismatch is detected.

It also supports a fixed prefix and suffix that will be prepended or appended
to the identifiers, regardless of the casing.

Many configuration options are available, in order to be able to create
different rules for different kind of identifier. In general, the
rules are falling back to a more generic rule if the specific case is not
configured.

http://reviews.llvm.org/D10933

Patch by Beren Minor!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245429 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 11:15:36 +00:00
Alexander Kornienko f95ab50039 [clang-tidy] Add loop-convert check to clang-tidy.
Move LoopConvert from clang-modernize to modernize module in clang-tidy.

http://reviews.llvm.org/D12076

Patch by Angel Garcia!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245427 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 09:11:46 +00:00
Ehsan Akhgari 443f869aae Insert override at the same line as the end of the function declaration
Summary:
The existing check converts the code pattern below:

  void f()
  {
  }

to:

  void f()
  override {
  }

which is fairly sub-optimal.  This patch fixes this by inserting the
override keyword on the same line as the function declaration if
possible, so that we instead get:

  void f() override
  {
  }

We do this by looking for the last token before the start of the body
and inserting the override keyword at the end of its location.  Note
that we handle const, volatile and ref-qualifiers correctly.

Test Plan: Includes an automated test.

Reviewers: alexfh

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245401 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 02:05:37 +00:00
Alexander Kornienko deefe2ca66 [clang-tidy] Allow use of -list-checks option without need to pass source files.
Initialize CommonOptionsParser with ZeroOrOne NumOccurrenceFlag so callers can
pass -list-checks without the need to pass additional positional parameters,
then add dummy file if none were supplied.

http://reviews.llvm.org/D12070

Patch by Don Hinton!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245205 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-17 10:03:27 +00:00
NAKAMURA Takumi 9d6774143e clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp: Tweak not to override -std=c++11.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245147 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-15 02:27:22 +00:00
NAKAMURA Takumi a34cc6e6af clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp: Appease targeting MS to give -fno-delayed-template-parsing.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245146 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-15 02:05:49 +00:00
Daniel Jasper 3b7db21bf4 misc-unused-parameters: Fix crasher with C forward declarations that
can leave out the parameter list.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245048 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-14 13:39:57 +00:00
Alexander Kornienko 78f15552b8 [clang-tidy] Create clang-tidy module modernize. Add pass-by-value check.
This is the first step for migrating cppmodernize to clang-tidy.

http://reviews.llvm.org/D11946

Patch by Angel Garcia!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@245045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-14 13:17:11 +00:00
Daniel Jasper f73aa43db7 misc-unused-parameters: Don't touch K&R style functions.
We couldn't calculate the removal ranges properly at this point.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@244454 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-10 15:45:46 +00:00
Alexander Kornienko 15e984cf7c [clang-tidy] Improve the misc-unused-alias-decl message
"this namespace alias decl is unused" -> "namespace alias decl '...' is unused"


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243906 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-03 22:02:08 +00:00
Daniel Jasper 9bd642b01f Add misc-unused-alias-decls check that currently finds unused namespace
alias declarations. In the future, we might want to reuse it to also
fine unsed using declarations and such.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243754 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31 16:08:10 +00:00
Alexander Kornienko f2465110fd [clang-tidy] Support replacements in macro arguments in misc-inefficient-algorithm
Summary:
Support replacements in macro arguments in the
misc-inefficient-algorithm check.

Reviewers: klimek

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243747 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31 13:34:58 +00:00
NAKAMURA Takumi 8bece3e60d Move an extra switch to clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp from check_clang_tidy.sh.
It also rolls back r242984 and r242985.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 22:41:04 +00:00
Daniel Jasper a79ece6c03 misc-unused-parameters: Only remove parameters in the main source file.
In headers, they might always be pulled in to different TUs, even if
they are declared static or nested in an unnamed namespace.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243414 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 13:19:12 +00:00
Daniel Jasper dffd1a4b60 misc-unused-parameters: Properly handle static class members.
Not sure why I wrote what I wrote before.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243403 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 10:39:25 +00:00
Aaron Ballman c87458d456 Trying again to a failing test the bots found with r243266.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243269 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 13:59:24 +00:00
Aaron Ballman 4ac25ac173 Fixing a failing test the bots found with r243266.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243268 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 13:47:35 +00:00
Daniel Jasper 09ebdf95ad misc-unused-parameters: Don't warn on ParmVarDecls in the return type.
As there don't seem to be a good way of formulating a matcher that
finds all pairs of functions and their ParmVarDecls, just match on
functionDecls and iterate over their parameters. This should also be
more efficient as some checks are only performed once per function.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 13:46:37 +00:00
Daniel Jasper 6e44d3b7e5 misc-unused-parameters: Fix bug where the check was looking at
ParmVarDecls of function types.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@243026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 17:26:36 +00:00
NAKAMURA Takumi 5740081a2e Fix the shell script check_clang_tidy.sh in r242984.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@242985 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 06:03:40 +00:00
NAKAMURA Takumi 44409b7dcc Appease test/clang-tidy/misc-unused-parameters.cpp for targeting *-win32, to add -fno-delayed-template-parsing.
Note, clang-tidy tests wouldn't run on Windows hosts since they are disabled with REQUIRES:shell.
The failure would be raised with cross building.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@242984 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 05:52:02 +00:00
Daniel Jasper e5e1975ff4 misc-unused-parameters: Fix handling of parameters in template functions.
The parameters of the function templates were being marked as
incorrectly be marked as unused. Added a test for this and changed the
check to use the same

  isReferenced() || !getDeclName()

logic as Sema::DiagnoseUnusedParameters.
Patch Scott Wallace, thank you!

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@242912 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 17:30:35 +00:00
Daniel Jasper e6f41b8dce Extend misc-unused-parameters to delete parameters of local functions.
Also see: llvm.org/PR24180.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@242659 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:42:38 +00:00
Daniel Jasper ad683268d8 Initial version of clang-tidy check to find and fix unused parameters.
Also see: llvm.org/PR24180.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@242654 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 01:06:44 +00:00
John Thompson 1109a22b65 Added mechanism to modularize for doing a compilation precheck
to determine files that have comnpilation or dependency problems.
A new -display-file-lists option use this to display lists of good files
(no compile errors), problem files, and a combined list with
problem files preceded by a '#'.  The problem files list can be
used in the module map generation assistant mode to exclude
problem files.  The combined files list can be used during module
map development.  See added docs.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@241880 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 00:37:25 +00:00
John Thompson f2c69a9438 Fixed line-endings.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@241744 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 22:00:56 +00:00
Daniel Marjamaki d947af800e [clang-tidy] Enhance clang-tidy misc-macro-repeated-side-effects...
Enhance clang-tidy misc-macro-repeated-side-effects to handle ? and : better.

When ? is used in a macro, there are 2 possible control flow paths through the macro.
These paths are tracked separately so problems can be detected properly.

http://reviews.llvm.org/D10653



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@241245 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02 07:49:55 +00:00
Alexander Kornienko ddc0d245d5 [clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr...
Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return
true; return false;' and improve replacement expressions.

This changeset extends the simplify boolean expression check in clang-tidy to
simplify if (e) return true; return false; to return e; (note the lack of an
else clause on the if statement.) By default, chained conditional assignment is
left unchanged, unless a configuration parameter is set to non-zero to override
this behavior.

It also improves the handling of replacement expressions to apply
static_cast<bool>(expr) when expr is not of type bool.

http://reviews.llvm.org/D9810

Patch by Richard Thomson!



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@241155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-01 12:39:40 +00:00
Daniel Marjamaki 05592be802 [clang-tidy] Fix false positives in the macro parentheses checker
Summary:
There were false positives in C++ code where macro argument was a type.

Reviewers: alexfh

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



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@240938 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-29 12:18:11 +00:00
Daniel Marjamaki b13d08f986 [clang-tidy] Fix false positives in misc-macro-parentheses checker
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@240399 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-23 12:45:14 +00:00
Daniel Marjamaki b797d494fb clang-tidy: Add checker that warn when macro argument with side effects is repeated in the macro
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@239909 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-17 14:19:35 +00:00
Daniel Marjamaki 0866fd184d clang-tidy: Add checker that warns about missing parentheses in macros
* calculations in the replacement list should be inside parentheses
* macro arguments should be inside parentheses



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@239820 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-16 14:27:31 +00:00
John Thompson 769f1da062 Fixed modularize to warn about missing headers referenced in a module map.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@239122 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 23:35:19 +00:00
Szabolcs Sipos 060433ce22 [clang-tidy] Fix for llvm.org/PR23355
misc-static-assert and misc-assert-side-effect will handle __builtin_expect based asserts correctly.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 09:49:59 +00:00
Alexander Kornienko 83140c0926 [clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238326 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 14:24:11 +00:00
Alexander Kornienko a599a4dccc [clang-tidy] misc-noexcept-move-ctors should ignore implicit constructors and assignments.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238202 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 14:35:09 +00:00
Alexander Kornienko 048422ba2c [clang-tidy] Don't issue most google-readability-casting warnings on .c files included in other files.
This is done sometimes for testing purposes, and the check needs to handle this
consistently.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238193 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 10:47:48 +00:00
Szabolcs Sipos 796a0a9994 [clang-tidy] Fix for llvm.org/PR23572
misc-static-assert won't report asserts whose conditions contain calls to non constexpr functions.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238098 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-23 14:21:01 +00:00
Alexander Kornienko 1fbea31870 Add a clang-tidy check for move constructors/assignment ops without noexcept.
Summary:
Add a clang-tidy check (misc-noexcept-move-ctors) for move constructors
and assignment operators not using noexcept.

http://llvm.org/PR23519

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@238013 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 10:31:17 +00:00
Alexander Kornienko 24d00fedd5 [clang-tidy] Disable google-readability-casting for .c files and their headers.
Some people have reasons to compile their .c files as C++ in some configurations
(e.g. for testing purposes), so just looking at LangOptions is not enough. This
patch disables the check on all .c files (and also for the headers included from
.c files).



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@237905 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 14:08:56 +00:00
Reid Kleckner e536262053 Copy lit shell changes from clang to clang-tools-extra, excluding some failing tests
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@237832 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 20:33:18 +00:00
Alexander Kornienko c436d50fda [clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr check...
Enhance clang-tidy readability-simplify-boolean-expr check to handle chained
conditional assignment and chained conditional return.

Based on feedback from applying this tool to the clang/LLVM codebase, this
changeset improves the readability-simplify-boolean-expr check so that
conditional assignment or return statements at the end of a chain of if/else if
statements are left unchanged unless a configuration option is supplied.

http://reviews.llvm.org/D8996

Patch by Richard Thomson!



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@237541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-17 12:31:12 +00:00
Alexander Kornienko ebb8b3dfb2 [clang-tidy] Treat all types with non-trivial destructors as RAII.
This solves some false negatives at a cost of adding some false positives that
can be fixed easily and (almost) automatically.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@237120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-12 12:17:20 +00:00
Szabolcs Sipos 0781039879 [clang-tidy] Fix for llvm.org/PR23161
The misc-static-assert check will not warn on the followings:
    assert(NULL == "shouldn't warn");
    assert(__null == "shouldn't warn");

Where NULL is a macro defined as __null.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@236812 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08 07:56:24 +00:00
Richard Smith 4b29f42edd Update to match clang r236404.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@236405 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-04 03:15:55 +00:00
NAKAMURA Takumi 6a5bbb2a02 Revert r236001, "Disable clang-tools-extra/test/pp-trace/pp-trace-modules.cpp on win32 for now. Investigating."
It has been resolved.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@236309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-01 08:38:22 +00:00
NAKAMURA Takumi c31eeb40d3 Disable clang-tools-extra/test/pp-trace/pp-trace-modules.cpp on win32 for now. Investigating.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@236001 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 17:31:36 +00:00
Daniel Jasper 85c5ed3066 clang-tidy: [readability-else-after-return] Fix false positive. This
might be a little too strict now, but better be too strict than do the
wrong thing.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@235932 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-27 22:42:20 +00:00
Alexander Kornienko 11f43a2e50 [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!



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234626 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10 19:26:43 +00:00
Szabolcs Sipos 232c3fec42 [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");

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234596 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10 13:55:39 +00:00
Samuel Benzaquen e72b682805 [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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234512 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 17:51:01 +00:00
Alexander Kornienko 03618ee155 [clang-tidy] Fix for http://llvm.org/PR23130
NamespaceCommentCheck: Don't remove the token placed immediately after the
namespace closing brace.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234403 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08 12:54:57 +00:00
Alexander Kornienko a788029f4f [clang-tidy] Added a couple of tests for misc-static-assert.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234094 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-04 14:54:53 +00:00
Alexander Kornienko 4a469965c7 [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.


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@233702 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 16:24:44 +00:00
Alexander Kornienko aefa8e6214 [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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@232431 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 22:31:16 +00:00
Alexander Kornienko 8f1357216e 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!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@232338 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 00:32:25 +00:00
Alexander Kornienko beb293a950 [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!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@232306 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 02:19:37 +00:00
Gabor Horvath 545c21e5de [clang-tidy] Static Analyzer checker configuration options pass-through.
Reviewed by: Alexander Kornienko

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


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@231941 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11 17:25:22 +00:00
Alexander Kornienko 5fd56929c9 [clang-tidy] Fix assertion when a dependent expression is used in an assert.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@231620 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-09 02:27:57 +00:00
Alexander Kornienko 2fdb55e05a [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!


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@231365 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 13:53:21 +00:00
Alexander Kornienko a48da6ed1d [clang-tidy] Output more diagnostics in check_clang_tidy.sh
Print clang-tidy output and fixes applied.



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@231236 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 12:07:50 +00:00
Filipe Cabecinhas 12abebdfa9 Add -fexceptions for targets which need it
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230994 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02 19:12:51 +00:00
Alexander Kornienko 374d8dfb56 [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!



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230943 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02 10:46:43 +00:00
Alexander Kornienko 2a82d482df [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).



git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230765 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 16:50:32 +00:00
Alexander Kornienko 91b3e5c616 [clang-tidy] Correct spelling error in test file name. NFC.
Patch by Richard Thomson!
http://reviews.llvm.org/D7603


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 13:17:14 +00:00
Gabor Horvath af8e0ac52c [clang-tidy] Fixed a false positive case in misc-inaccurate-erase checker.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230483 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 12:17:03 +00:00
Adrian Prantl ad503884e4 Revert "Add a missing target requirement."
This reverts commit 230430.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230455 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 02:46:29 +00:00
Adrian Prantl 257a063dae Add a missing target requirement.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230430 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 01:52:10 +00:00
John Thompson 2e97d7f2dc Deleted module-map-checker, as it's been folded into modularize.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@230014 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-20 14:28:10 +00:00
John Thompson b8c316a567 Added module map coverage support, extracted from module-map-checker.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@229869 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-19 16:47:27 +00:00
John Thompson c9ab0dfd9f Fixed missing checkins.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@229699 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 17:08:00 +00:00
John Thompson 6ef1a52208 Added support for extracting headers from module maps as a source for the header list.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@229692 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 16:14:32 +00:00
Gabor Horvath 5edfeeb4cf [clang-tidy] Fixed two wrong fix-it cases in misc-inefficient-algorithm checker.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@229552 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17 21:45:38 +00:00
NAKAMURA Takumi 48fdd353e9 clang-tools-extra/test/modularize/NoProblemsList.modularize: Unbreak test.
Don't expect the list were on the current directory.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228991 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 00:28:21 +00:00
Gabor Horvath 65380fcf54 [clang-tidy] Fixed a false positive case in misc-inefficient-algorithm checker.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228945 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12 18:19:34 +00:00
John Thompson df2a5a5c88 Fix broken test in separate build tree.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228941 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12 17:52:28 +00:00
John Thompson 17a4e51012 Added support for multiple header list files, as a precursor for when we need to load multiple module maps.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228935 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12 16:22:09 +00:00
John Thompson 8518eac5d7 Added -block-check-header-list-only option. This is a work-around for private includes that purposefully get included inside blocks.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228846 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 16:58:36 +00:00
John Thompson 4d5079ee09 Renamed module.map to module.modulemap.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228692 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 14:29:16 +00:00
Gabor Horvath 21c4fbd92c [clang-tidy] Checker for inaccurate use of erase() method.
Algorithms like remove() does not actually remove any element from the
container but returns an iterator to the first redundant element at the end
of the container. These redundant elements must be removed using the
erase() method. This check warns when not all of the elements will be
removed due to using an inappropriate overload.

Reviewer: alexfh

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


git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228679 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 09:14:26 +00:00
Samuel Benzaquen 757c937602 Verify assign operator signatures.
Summary: Warn when the return type of assign operators is not Class&.

Reviewers: alexfh

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228583 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-09 17:50:40 +00:00
Gabor Horvath e49296a438 [clang-tidy] Checker for inefficient use of algorithms on associative containers
Summary:
Associative containers implements some of the algorithms as methods which
should be preferred to the algorithms in the algorithm header. The methods
can take advantage of the order of the elements.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228505 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-07 19:54:19 +00:00
Alexander Kornienko 6efe62518a [clang-tidy] Don't ignore default set of checks when a config file is found.
Summary:
This makes clang-tidy merge the default set of checks with the one
provided in the configuration file instead of just using the checks from the
config file. This adds a way to modify the default set of checks while the
previous behavior required to always define the set of checks completely.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@228298 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-05 14:50:17 +00:00