Commit Graph

389 Commits

Author SHA1 Message Date
Daniel Jasper ea223a7a6a misc-unused-parameters: Fix crasher with C forward declarations that
can leave out the parameter list.

llvm-svn: 245048
2015-08-14 13:39:57 +00:00
Alexander Kornienko fc650864ef [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!

llvm-svn: 245045
2015-08-14 13:17:11 +00:00
Alexander Kornienko 8cc024ee37 [clang-tidy] Fix IncludeInserter/IncludeSorter bug.
If there weren't any includes in the file, or all of them had 'IncludeKind'
greater than the desired one, then 'CreateIncludeInsertion' didn't work.

http://reviews.llvm.org/D12017

Patch by Angel Garcia!

llvm-svn: 245042
2015-08-14 12:33:25 +00:00
Alexander Kornienko b7029d05a1 [clang-tidy] Make FileOptionsProvider fields protected to make extending it easier
llvm-svn: 244793
2015-08-12 19:29:57 +00:00
Daniel Jasper 4d871f99c7 Lazily initialize HeaderFilter in ClangTidyDiagnosticConsumer. This
removes a corner case in tests that don't set the diagnostic consumer.
In tests, it is good, not to set the diagnostic consumer so that Clang's
parsing diagnostics are still displayed in the test output and only
ClangTidy's output is analyzed differently.

llvm-svn: 244745
2015-08-12 13:16:41 +00:00
Manuel Klimek 3d67c88506 Fix strict dependency uncovered by windows bot.
llvm-svn: 244598
2015-08-11 13:11:29 +00:00
Manuel Klimek 795daa2e8f Fix shadowing of type with variable.
llvm-svn: 244587
2015-08-11 12:02:28 +00:00
Manuel Klimek d00d6f1d43 Add an IncludeInserter to clang-tidy.
Will be used to allow checks to insert includes at the right position.

llvm-svn: 244586
2015-08-11 11:37:48 +00:00
Daniel Jasper b3a74c659b misc-unused-parameters: Don't touch K&R style functions.
We couldn't calculate the removal ranges properly at this point.

llvm-svn: 244454
2015-08-10 15:45:46 +00:00
Yaron Keren 43b7ca7b43 Silence gcc 5.1 unused variable warnings using LLVM_ATTRIBUTE_UNUSED.
llvm-svn: 244329
2015-08-07 16:37:34 +00:00
Alexander Kornienko 2644cae3d5 [clang-tidy] Improve the misc-unused-alias-decl message
"this namespace alias decl is unused" -> "namespace alias decl '...' is unused"

llvm-svn: 243906
2015-08-03 22:02:08 +00:00
Daniel Jasper cf452e5501 Replace callback-if with isExpansionInMainFile as suggested in post
commit review.

llvm-svn: 243871
2015-08-03 10:52:27 +00:00
Daniel Jasper 0aeed7c0b8 Add missing 'override'.
llvm-svn: 243773
2015-07-31 18:32:38 +00:00
Daniel Jasper bb42b03021 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.

llvm-svn: 243754
2015-07-31 16:08:10 +00:00
Alexander Kornienko b4fbb173f0 [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

llvm-svn: 243747
2015-07-31 13:34:58 +00:00
Daniel Jasper 542482e63d 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.

llvm-svn: 243414
2015-07-28 13:19:12 +00:00
Daniel Jasper 718029ba6b misc-unused-parameters: Properly handle static class members.
Not sure why I wrote what I wrote before.

llvm-svn: 243403
2015-07-28 10:39:25 +00:00
Daniel Jasper 9fe55a32b7 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.

llvm-svn: 243267
2015-07-27 13:46:37 +00:00
Aaron Ballman 5a4892b4fa Updating the documentation for clang-tidy. Removes some non-ASCII characters from the documentation, and removes shell-specific single quote characters as they cause issues for some shells (such as on Windows).
llvm-svn: 243266
2015-07-27 13:41:30 +00:00
Alexander Kornienko ae8f23efa8 [clang-tidy] Don't duplicate the leading slash.
llvm-svn: 243265
2015-07-27 13:07:50 +00:00
Daniel Jasper 1c6fc3b8f0 misc-unused-parameters: Fix bug where the check was looking at
ParmVarDecls of function types.

llvm-svn: 243026
2015-07-23 17:26:36 +00:00
Daniel Jasper 9b46e9c5de 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!

llvm-svn: 242912
2015-07-22 17:30:35 +00:00
Daniel Jasper 82efabbb27 Extend misc-unused-parameters to delete parameters of local functions.
Also see: llvm.org/PR24180.

llvm-svn: 242659
2015-07-20 03:42:38 +00:00
Daniel Jasper 9c6df889c4 Initial version of clang-tidy check to find and fix unused parameters.
Also see: llvm.org/PR24180.

llvm-svn: 242654
2015-07-20 01:06:44 +00:00
Daniel Marjamaki e0384e51b0 [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

llvm-svn: 241245
2015-07-02 07:49:55 +00:00
Daniel Marjamaki bf5e59c78b [clang-tidy] minor coding style tweak. make functions static.
llvm-svn: 241160
2015-07-01 13:29:27 +00:00
Alexander Kornienko 6ae400d122 [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!

llvm-svn: 241155
2015-07-01 12:39:40 +00:00
Daniel Marjamaki 4a38b0b493 [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

llvm-svn: 240938
2015-06-29 12:18:11 +00:00
Daniel Marjamaki 91d35a5e22 [clang-tidy] Fix false positives in misc-macro-parentheses checker
llvm-svn: 240399
2015-06-23 12:45:14 +00:00
Justin Bogner 7b92cac037 clang-tidy: Remove an unused private field. NFC
Clang was warning on this.

llvm-svn: 239988
2015-06-18 04:15:04 +00:00
Daniel Marjamaki 71c9257f07 clang-tidy: Add checker that warn when macro argument with side effects is repeated in the macro
llvm-svn: 239909
2015-06-17 14:19:35 +00:00
Alexander Kornienko 50d7f4617f [clang-tidy] Move user-defined matches to unnamed namespaces to prevent ODR violations.
llvm-svn: 239904
2015-06-17 13:11:37 +00:00
Daniel Marjamaki 302275a938 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

llvm-svn: 239820
2015-06-16 14:27:31 +00:00
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
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
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
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
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
Richard Smith 33de8566f0 Update to match clang r236404.
llvm-svn: 236405
2015-05-04 03:15:55 +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
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
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
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 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
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 57a5c6b56c Move remove-cstr-calls from a standalone executable to a clang-tidy check readability-redundant-string-cstr
http://reviews.llvm.org/D7318

Patch by Richard Thomson!

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

Also added corresponding test cases.

http://reviews.llvm.org/D8328

Patch by Szabolcs Sipos!

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

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

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

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

http://reviews.llvm.org/D8144

Patch by Richard Thomson!

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

http://reviews.llvm.org/D8145

Patch by Richard Thomson!

llvm-svn: 231648
2015-03-09 11:48:54 +00:00
Alexander Kornienko b2ddb8ac4d [clang-tidy] Fix assertion when a dependent expression is used in an assert.
llvm-svn: 231620
2015-03-09 02:27:57 +00:00
Daniel Jasper 08201e394e Use std::string instead of StringRef to prevent use-after-free.
Discovered by asan.

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

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

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

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

Patch by Alexey Sokolov!

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

Patch by Richard Thomson!

llvm-svn: 231364
2015-03-05 13:46:14 +00:00
Alexander Kornienko df0ab6acdf [clang-tidy] Fix namespace comments. NFC.
llvm-svn: 231267
2015-03-04 18:01:10 +00:00
Alexander Kornienko 0a6ce9f4e1 [clang-tidy] Refactor: Move llvm clang-tidy checks to namespace clang::tidy::llvm
clang-tidy checks are organized into modules. This refactoring moves the llvm
module checks to clang::tidy::llvm

http://reviews.llvm.org/D7995

Patch by Richard Thomson!

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

http://reviews.llvm.org/D7996

Patch by Richard Thomson!

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

http://reviews.llvm.org/D7997

Patch by Richard Thomson!

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

The checkers:

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

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

http://reviews.llvm.org/D7375

Patch by Szabolcs Sipos!

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

llvm-svn: 230765
2015-02-27 16:50:32 +00:00
Alexander Kornienko 4c0e4a12bd [clang-tidy] Use the new ArrayRef<FixItHint> inserter.
llvm-svn: 230497
2015-02-25 14:42:02 +00:00
Alexander Kornienko 8cef0752f5 [clang-tidy] Correct confusion between overwrite and override. NFC.
Patch by Richard Thomson!
http://reviews.llvm.org/D7604

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

llvm-svn: 230456
2015-02-25 02:46:37 +00:00
Adrian Prantl e95edbf5a9 Adapt clang-tools-extra to clang module format changes.
- add clangCodeGen.a to the tools that need it
- tweak pp-trace command line handling to not conflict with clang's.

llvm-svn: 230424
2015-02-25 01:32:04 +00:00
Adrian Prantl a22fd38174 Revert "Adapt Makefile dependencies for the clang module format change in r230089."
llvm-svn: 230104
2015-02-21 00:29:43 +00:00
Adrian Prantl 6897e3e456 Adapt Makefile dependencies for the clang module format change in r230089.
llvm-svn: 230090
2015-02-20 23:35:07 +00:00
Gabor Horvath 21b76badeb [clang-tidy] Fixed two wrong fix-it cases in misc-inefficient-algorithm checker.
llvm-svn: 229552
2015-02-17 21:45:38 +00:00
Chandler Carruth f766278204 Re-sort includes using the LLVM utils/sort_includes.py script.
llvm-svn: 229087
2015-02-13 09:07:58 +00:00
Gabor Horvath 0329519904 [clang-tidy] Fixed a false positive case in misc-inefficient-algorithm checker.
llvm-svn: 228945
2015-02-12 18:19:34 +00:00
Samuel Benzaquen 59c8aa92b8 Add clang-tidy check google-global-names-in-headers.
Summary:
google-global-names-in-headers flags global namespace pollution in header files.
Right now it only triggers on using declarations and directives.

Reviewers: alexfh

Subscribers: curdeius

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

llvm-svn: 228875
2015-02-11 21:21:05 +00:00
Gabor Horvath d4637fb433 [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

llvm-svn: 228679
2015-02-10 09:14:26 +00:00
Samuel Benzaquen b5cbe0100f 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

llvm-svn: 228583
2015-02-09 17:50:40 +00:00
Gabor Horvath 3880bee0ff [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

llvm-svn: 228505
2015-02-07 19:54:19 +00:00
Alexander Kornienko b6e1fde719 [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

llvm-svn: 228298
2015-02-05 14:50:17 +00:00
Alexander Kornienko dd2dad0d24 [clang-tidy] Detect dependent initializer_lists in google-explicit-constructor.
Summary:
Detect constructors taking a single std::initializer_list even when it
is instantiation-dependent.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 228289
2015-02-05 12:49:07 +00:00
Alexander Kornienko 78070fbae5 [clang-tidy] Fix some false positives in google-readability-casting
Summary:
Ignore C-style casts in extern "C" {} sections. Be more careful when
detecting redundant casts between typedefs to the same type - emit a more
specific warning and don't automatically fix them.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 227444
2015-01-29 15:17:13 +00:00
Alexander Kornienko e94b7c24c8 [clang-tidy] Use shrink_to_fit instead of copy and swap trick
The shrink_to_fit() method is more readable and more effective than
the copy and swap trick to reduce the capacity of a shrinkable container.
Note that, the shrink_to_fit() method is only available in C++11 and up.

Example:

std::vector<int>(v).swap(v); will be replaced with v.shrink_to_fit();

http://reviews.llvm.org/D7087

Patch by Gábor Horváth!

llvm-svn: 226912
2015-01-23 15:10:37 +00:00
Alexander Kornienko a6354cae56 [clang-tidy] Small readability-container-size-empty cleanup
Utilized the hasEitherOperand instead of explicit anyOf.

http://reviews.llvm.org/D7142

Patch by Gábor Horváth!

llvm-svn: 226911
2015-01-23 14:43:06 +00:00
Alexander Kornienko 96e7b8b0c9 [clang-tidy] Use actual LangOptions.
llvm-svn: 226812
2015-01-22 12:40:47 +00:00
Alexander Kornienko febfd3453e [clang-tidy] Minor cleanups in readability-container-size-empty checker
* Removed an unused header
  * Simplified the custom ast_matchers

http://reviews.llvm.org/D7088

Patch by Gábor Horváth!

llvm-svn: 226810
2015-01-22 12:27:09 +00:00
Alexander Kornienko 9115a3af02 [clang-tidy] Make ClangTidyOptionsProvider::getOptions return by value.
Returning by reference limits possible implementations and doesn't bring any
benefits as all callers make copies of the returned value anyway.

llvm-svn: 226553
2015-01-20 09:48:51 +00:00
Alexander Kornienko 4babd689f9 clang-tidy: 'size' call that could be replaced with 'empty' on STL containers
We are porting some of the checkers at a company we developed to the Clang Tidy
infrastructure. We would like to open source the checkers that may be useful
for the community as well. This patch is the first checker that is being ported
to Clang Tidy. We also added fix-it hints, and applied them to LLVM:
http://reviews.llvm.org/D6924

The code compiled and the unit tests are passed after the fixits was applied.

The documentation of the checker:

/// The emptiness of a container should be checked using the empty method
/// instead of the size method. It is not guaranteed that size is a
/// constant-time function, and it is generally more efficient and also shows
/// clearer intent to use empty. Furthermore some containers may implement the
/// empty method but not implement the size method. Using empty whenever
/// possible makes it easier to switch to another container in the future.

It also uses some custom ASTMatchers. In case you find them useful I can submit
them as separate patches to clang. I will apply your suggestions to this patch.

http://reviews.llvm.org/D6925

Patch by Gábor Horváth!

llvm-svn: 226172
2015-01-15 15:46:58 +00:00