Commit Graph

934 Commits

Author SHA1 Message Date
Samuel Benzaquen cfacf8ae9e [clang-tidy] Force braces around leaf 'else if' for consistency.
Summary:
Force braces around leaf 'else if' for consistency.
This complements r233697.

Reviewers: alexfh

Subscribers: curdeius, cfe-commits

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

llvm-svn: 239054
2015-06-04 16:36:58 +00:00
John Thompson 81cf1e8931 Fixed option description. '=' is required.
llvm-svn: 238998
2015-06-04 01:12:56 +00:00
John Thompson cf777e9f05 Fixed option comment. '=' is required.
llvm-svn: 238997
2015-06-04 01:10:19 +00:00
Rafael Espindola d218565c04 Update for clang API change.
Patch by Косов Евгений.

llvm-svn: 238775
2015-06-01 20:00:20 +00:00
Szabolcs Sipos 43a298cb36 [clang-tidy] Fix for llvm.org/PR23355
misc-static-assert and misc-assert-side-effect will handle __builtin_expect based asserts correctly.

llvm-svn: 238548
2015-05-29 09:49:59 +00:00
Alexander Kornienko 7ed89bcd3b [clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor
llvm-svn: 238326
2015-05-27 14:24:11 +00:00
Alexander Kornienko bf5bd94142 [clang-tidy] misc-noexcept-move-ctors should ignore implicit constructors and assignments.
llvm-svn: 238202
2015-05-26 14:35:09 +00:00
Alexander Kornienko 2b56649cd2 [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.

llvm-svn: 238193
2015-05-26 10:47:48 +00:00
Szabolcs Sipos 0acf19ed53 [clang-tidy] Fix for llvm.org/PR23572
misc-static-assert won't report asserts whose conditions contain calls to non constexpr functions.

llvm-svn: 238098
2015-05-23 14:21:01 +00:00
Alexander Kornienko 3396a8b8e6 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

llvm-svn: 238013
2015-05-22 10:31:17 +00:00
Alexander Kornienko 19bbeaf410 [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).

llvm-svn: 237905
2015-05-21 14:08:56 +00:00
Reid Kleckner 558850ac59 Copy lit shell changes from clang to clang-tools-extra, excluding some failing tests
llvm-svn: 237832
2015-05-20 20:33:18 +00:00
Justin Bogner e3acc8bc56 docs: Spell a couple of cmake options with =ON in the docs
Patch by Albert Astals Cid. Thanks!

llvm-svn: 237554
2015-05-18 05:05:49 +00:00
Alexander Kornienko fb3e2cd8cc [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!

llvm-svn: 237541
2015-05-17 12:31:12 +00:00
Richard Smith 9d5ae2174b Update to match clang r237508.
llvm-svn: 237509
2015-05-16 03:10:31 +00:00
Alexander Kornienko bdaa681fc6 [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.

llvm-svn: 237120
2015-05-12 12:17:20 +00:00
Nikola Smiljanic 90476a5d90 Fix misleading parameter name for PPCallbacks::FileSkipped.
Patch thanks to Vladimir Voskresensky.

llvm-svn: 237116
2015-05-12 11:48:21 +00:00
Daniel Marjamaki 89ec723468 Refactor MacroInfo so range for loops can be used to iterate its tokens.
Differential Revision: http://reviews.llvm.org/D9079

llvm-svn: 236976
2015-05-11 08:26:25 +00:00
Szabolcs Sipos 60ce8bb0be [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.

llvm-svn: 236812
2015-05-08 07:56:24 +00:00
John Thompson f9f62b116f Changed option processing to implicitly use -x c++ if no other -x option specified. Added implicit -w option to disable compilation warnings, in particular to avoid warning on pragma once.
llvm-svn: 236625
2015-05-06 18:43:01 +00:00
John Thompson fcf3f47d7a Fixed infinite recursion bug.
llvm-svn: 236624
2015-05-06 18:39:15 +00:00
Richard Smith 33de8566f0 Update to match clang r236404.
llvm-svn: 236405
2015-05-04 03:15:55 +00:00
NAKAMURA Takumi 22d8830813 Revert r236001, "Disable clang-tools-extra/test/pp-trace/pp-trace-modules.cpp on win32 for now. Investigating."
It has been resolved.

llvm-svn: 236309
2015-05-01 08:38:22 +00:00
NAKAMURA Takumi 6eb00faf9d Disable clang-tools-extra/test/pp-trace/pp-trace-modules.cpp on win32 for now. Investigating.
llvm-svn: 236001
2015-04-28 17:31:36 +00:00
Daniel Jasper a73aed0c9b 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.

llvm-svn: 235932
2015-04-27 22:42:20 +00:00
Richard Smith 76e66607a3 Fix clang-tools-extra build after clang r235614.
llvm-svn: 235642
2015-04-23 20:38:48 +00:00
Benjamin Kramer 73d2749a18 [clang-tidy] Remove static StringSet in favor of binary search.
The number of strings is so small that performance doesn't matter and adding
the thread safe static initialization and destruction overhead is just not
worth it. No functional change intended.

llvm-svn: 235192
2015-04-17 13:52:08 +00:00
Richard Trieu a60ca8104e Change range-based for-loop to be -Wrange-loop-analysis clean.
No functionality change.

llvm-svn: 234965
2015-04-15 01:21:57 +00:00
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