Commit Graph

38 Commits

Author SHA1 Message Date
Benjamin Kramer 8b55a2b76c [clang-tidy] Fix a functional change from r269656.
Instead of forming char ranges that patch made us form token ranges,
which behave subtly different. Sadly I'm only seeing this as part of a
larger test case that I haven't fully reduced yet.

llvm-svn: 269896
2016-05-18 09:48:46 +00:00
Etienne Bergeron e15ef2f609 [clang-tidy] Lift common matchers to utils namespace
Summary:
This patch is lifting matchers used by more than one checkers
to the common namespace.

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269804
2016-05-17 19:36:09 +00:00
Etienne Bergeron 8d73de9eac [clang-tidy] Cleanups utils files
Summary:
Cleanup some code by using appropriate APIs.
Some coding style cleanups.

There is no behavior changes.

 - Function `IncludeSorter::CreateFixIt` can be replaced by `FixItHint::CreateReplacement`.
 - Function `cleanPath` is a wrapper for `llvm::sys::path::remove_dots`.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269656
2016-05-16 14:34:20 +00:00
Felix Berger 9435f54167 [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
Reviewers: alexfh, sbenza

Subscribers: etienneb, aaron.ballman, cfe-commits

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

llvm-svn: 269581
2016-05-14 22:43:50 +00:00
Etienne Bergeron de1ec03779 [clang-tidy] Lift parsing of sequence of names functions to utils.
Summary:
Lift some common code used by multiple checkers.

This function is also used by checkers that are coming.
It is quite common for a checker to parse a list of names.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269065
2016-05-10 15:31:15 +00:00
Etienne Bergeron 2a4c00f243 [clang-tidy] Cleanup namespace in utils folder.
Summary:
This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268356
2016-05-03 02:54:05 +00:00
Etienne Bergeron 9d26599078 [clang-tidy] Cleanup some ast-matchers and lift some to utils.
Summary:
Little cleanup to lift-out and to remove some frequently used
ast-matchers.

Some of theses matchers are candidates to be lifted to ASTMatchers.h.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267003
2016-04-21 16:57:56 +00:00
Alexander Kornienko 855d97e30c Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.
Summary: Added the remaining features needed to satisfy C++ Core Guideline Type.6: Always initialize a member variable to cppcoreguidelines-pro-type-member-init. The check now flags all default-constructed uses of record types without user-provided default constructors that would leave their memory in an undefined state. The check suggests value initializing them instead.

Reviewers: flx, alexfh, aaron.ballman

Subscribers: klimek, aaron.ballman, LegalizeAdulthood, cfe-commits

Patch by Michael Miller!

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

llvm-svn: 266191
2016-04-13 11:35:47 +00:00
Felix Berger adfdc14832 [clang-tidy] Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.
Summary:
Move code shared between UnnecessaryCopyInitialization and ForRangeCopyCheck into utilities files.
Add more test cases for UnnecessaryCopyInitialization and disable fixes inside of macros.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 262781
2016-03-05 21:17:58 +00:00
Haojian Wu 7d08ba2749 [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when IncludeInserter handles macro header file.
Summary: Also Fixes PR24749.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 262484
2016-03-02 14:12:17 +00:00
Haojian Wu c2d7577cc5 [clang-tdiy] Add header file extension configuration support.
Summary: * Add a `HeaderFileExtensions` check option in misc-definitions-in-headers, google-build-namespaces and google-global-names-in-headers.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

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

llvm-svn: 259879
2016-02-05 11:23:59 +00:00
Chris Bieneman 2cc7fec76a Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"Now I am become Death, the destroyer of worlds."
-J. Robert Oppenheimer

Reviewers: chandlerc, grosbach, bob.wilson, echristo

Subscribers: cfe-commits, klimek

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

llvm-svn: 258864
2016-01-26 21:31:36 +00:00
Alexander Kornienko b959f4c338 [clang-tidy] Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy
Summary:
The patch adds a new ClangTidy check that detects when expensive-to-copy types are unnecessarily copy initialized from a const reference that has the same or are larger scope than the copy.

It currently only detects this when the copied variable is const qualified. But this will be extended to non const variables if they are only used in a const fashion.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by Felix Berger!

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

llvm-svn: 256632
2015-12-30 10:24:40 +00:00
Alexander Kornienko a396143a28 [clang-tidy] Sort includes case-sensitively.
The motivation is:
  1. consistency with clang-format, vim :sort etc.
  2. we don't want the tools to depend on the current locale to do the include
     sorting

llvm-svn: 255243
2015-12-10 12:24:19 +00:00
Aaron Ballman c5a6da0ed1 Replace the custom AST matcher for nothrow functions with the canonical AST matcher from r254516.
llvm-svn: 254517
2015-12-02 15:24:47 +00:00
Aaron Ballman 43aef4cb9b Add a new checker, cert-err58-cpp, that checks for static or thread_local objects that use a throwing constructor.
This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions

llvm-svn: 254415
2015-12-01 14:05:39 +00:00
Manuel Klimek 5fdd843d14 Make isExpensiveToCopy() tri-state.
This allows returning "don't know" for dependent types.

llvm-svn: 251103
2015-10-23 10:00:50 +00:00
David Blaikie e04a3da093 Revert "Apply modernize-use-default to clang-tools-extra."
Breaks the build in GCC 4.7.2 (see
http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3 for example)

This reverts commit r250824.

llvm-svn: 250862
2015-10-20 21:45:52 +00:00
Angel Garcia Gomez 3ca34bc870 Apply modernize-use-default to clang-tools-extra.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 250824
2015-10-20 12:56:27 +00:00
Aaron Ballman fc4e042bf5 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!

llvm-svn: 249429
2015-10-06 16:27:03 +00:00
Craig Topper 8f70a9f892 SourceRanges are small and trivially copyable, don't them by reference. NFC
llvm-svn: 249258
2015-10-04 04:53:37 +00:00
Alexander Kornienko f8ed0a8d35 [clang-tidy] Update docs for clang-tidy checks. NFC
Changes mostly address formatting and unification of the style. Use
MarkDown style for inline code snippets and lists. Added some text
for a few checks.

The idea is to move most of the documentation out to separate rST files and have
implementation files refer to the corresponding documentation files.

llvm-svn: 246169
2015-08-27 18:01:58 +00:00
Daniel Jasper d30dc3fc75 Fix IncludeInserter to allow for more than one added header per file.
Also adapt tests a bit to make it possible to test this. Removed
checking the number of errors reported per test. It was never actually
checked and doesn't seem particularly relevant to the test itself.

llvm-svn: 245500
2015-08-19 21:02:27 +00:00
Alexander Kornienko 5f252cac51 [clang-tidy] Move IncludeSorter.* and IncludeInserter.* to clang-tidy/utils/
This is better structurally and it also fixes a linker error in the configure
build.

llvm-svn: 245052
2015-08-14 14:31:31 +00:00
Alexander Kornienko ae8f23efa8 [clang-tidy] Don't duplicate the leading slash.
llvm-svn: 243265
2015-07-27 13:07:50 +00:00
Richard Smith 33de8566f0 Update to match clang r236404.
llvm-svn: 236405
2015-05-04 03:15:55 +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 4c0e4a12bd [clang-tidy] Use the new ArrayRef<FixItHint> inserter.
llvm-svn: 230497
2015-02-25 14:42:02 +00:00
Alexander Kornienko 81d4f939bc Fix llvm-header-guard check.
Summary:
This patch makes the check work better for LLVM code:
  * always fix existing #endif comments
  * use one space before the comment (+allow customization for other styles)

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 219789
2014-10-15 12:18:35 +00:00
Benjamin Kramer ebdf90ca00 Make a variable local so it's lifetime becomes more obvious.
NFC

llvm-svn: 217952
2014-09-17 13:12:51 +00:00
Benjamin Kramer ae8fc52237 [clang-tidy] Don't emit the same fixit multiple times.
If we had many header files we would attach the fix-it for all files to all
warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter
in some edge cases. Sadly I failed to create a small test case for this.

While there move fix-its instead of copying.

llvm-svn: 217951
2014-09-17 11:48:34 +00:00
Benjamin Kramer eb213cb1cd [clang-tidy] When emitting header guard fixes bundle all fix-its into one
warning.

Before we would emit two warnings if the header guard was wrong and the comment
on a trailing #endif also needed fixing.

llvm-svn: 217890
2014-09-16 17:41:19 +00:00
Alexander Kornienko 6e0cbc8947 Implemented clang-tidy-check-specific options.
Summary:
Each check can implement readOptions and storeOptions methods to read
and store custom options. Each check's options are stored in a local namespace
to avoid name collisions and provide some sort of context to the user.

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 217661
2014-09-12 08:53:36 +00:00
Benjamin Kramer ad335cf690 [clang-tidy] Don't try to fix header guard #endif comments if there are escaped
newlines involved.

Getting that right is just not worth it.

llvm-svn: 217480
2014-09-10 08:48:30 +00:00
Craig Topper 775862a277 Unique_ptrify PPCallbacks ownership. Goes with clang r217474.
llvm-svn: 217475
2014-09-10 05:07:57 +00:00
Benjamin Kramer d5fef8198b [clang-tidy] If we're going to change the header guard in the #endif comment
we can also fix the original header guard.

We still allow an _ at the end of a header guard since it's so common, but
remove it now when the #endif comment is changed.

llvm-svn: 216462
2014-08-26 16:28:35 +00:00
Benjamin Kramer 208faaaa29 [clang-tidy] Allow /**/ comments on #endifs when checking header guards.
Turning block comments into line comments just creates unecessary churn.

llvm-svn: 216072
2014-08-20 16:01:42 +00:00
Benjamin Kramer 498cce575f [clang-tidy] Add a generic header guard checker + LLVM implementation.
The implementation is split into a generic part and a LLVM-specific part.
Other codebases can implement it with their own style. The specific features
supported are:

- Verification (and fixing) of header guards against a style based on the file path
- Automatic insertion of header guards for headers that are missing them
- A warning when the header guard doesn't enable our fancy header guard optimization
(e.g. when there's an include preceeding the guard)
- Automatic insertion of a comment with the guard name after #endif.

For the LLVM style we disable #endif comments for now, they're not very common
in the codebase. We also only flag headers in the include directories, there
doesn't seem to be a common style outside.

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

llvm-svn: 215548
2014-08-13 13:57:57 +00:00