Commit Graph

83 Commits

Author SHA1 Message Date
Alexander Kornienko 9eb8c92b52 Output clang-tidy errors in a consistent order.
Summary: Sort errors by path, file offset and message.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 205759
2014-04-08 12:27:49 +00:00
Alexander Kornienko 3c598d39cd Removed unused include
llvm-svn: 204551
2014-03-23 00:32:18 +00:00
NAKAMURA Takumi f5cebd2f64 ClangTidyTest.h: Don't use initializer list. msc17 doesn't recognize one.
llvm-svn: 204332
2014-03-20 10:52:51 +00:00
Alexander Kornienko f65a549a82 clang-tidy explicit constructor check: don't warn on copy or move constructors.
Summary:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors
"The exception is copy constructors, which, in the rare cases when we allow
them, should probably not be explicit."

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3122

llvm-svn: 204322
2014-03-20 09:39:36 +00:00
Alexander Kornienko 09952d2d71 Post-filter clang-tidy diagnostic messages.
Summary:
This patch implements filtering of clang-tidy diagnostic messages by
the check name, so that "clang-tidy -checks=^llvm-" won't output any clang
warnings, for example. This is also helpful to run specific static-analyzer
checks: static analyzer always needs core checks to be enabled, but the user may
be interested only in the checks he asked for.

This patch also exposes warning option names for built-in diagnostics. We need
to have a namespace for these names to avoid collisions and to allow convenient
filtering, so I prefix them with "-W". I'm not sure it's the best thing to do,
and maybe "W" or "clang-diagnostic-" or something like this would be better.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3121

llvm-svn: 204321
2014-03-20 09:38:22 +00:00
Alexander Kornienko f9a7b46ec6 clang-tidy explicit constructors check: don't warn on deleted constructors.
Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3116

llvm-svn: 204226
2014-03-19 12:48:22 +00:00
Peter Collingbourne 35c3f61d74 Add an argument comment checker to clang-tidy.
This checks that parameters named in comments that appear before arguments in
function and constructor calls match the parameter name used in the callee's
declaration. For example:

void f(int x, int y);

void g() {
  f(/*y=*/0, /*z=*/0);
}

contains two violations of the policy, as the names 'x' and 'y' used in the
declaration do not match names 'y' and 'z' used at the call site.

I think there is significant value in being able to check/enforce this policy
as a way of guarding against accidental API misuse and silent breakages
caused by API changes.

Although this pattern appears somewhat frequently in the LLVM codebase,
this policy is not prescribed by the LLVM coding standards at the moment,
so it lives under 'misc'.

Differential Revision: http://llvm-reviews.chandlerc.com/D2914

llvm-svn: 204113
2014-03-18 04:46:45 +00:00
Ahmed Charles 6a2dc5c381 [C++11] Replace OwningPtr with std::unique_ptr.
This removes all references to OwningPtr, which should be fairly
undisruptive to out-of-tree projects since they are unlikely to use
clang-tools-extra as a library instead of a set of tools.

llvm-svn: 203382
2014-03-09 09:24:40 +00:00
Chandler Carruth edc9e38810 [cleanup] Re-sort headers with llvm/utils/sort_includes.py.
llvm-svn: 202809
2014-03-04 10:03:05 +00:00
Craig Topper a3dbe84166 [C++11] Replace LLVM_OVERRIDE with 'override'
llvm-svn: 202632
2014-03-02 10:20:11 +00:00
Alexander Kornienko 098871609f Made the ClangTidyTest helper class independent of the testing framework.
Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2895

llvm-svn: 202399
2014-02-27 14:28:02 +00:00
Alexander Kornienko 32eaa37b15 Fix ExplicitConstructorCheck to warn only on in-class declarations.
Summary:
I'm not absolutely sure this is 100% correct solution, but it seems to
do what I expect.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2756

llvm-svn: 201308
2014-02-13 10:11:48 +00:00
Peter Collingbourne d9a0f254bc Add completion to the query parser, and hook it up to clang-query.
Differential Revision: http://llvm-reviews.chandlerc.com/D2263

llvm-svn: 200604
2014-02-01 01:42:46 +00:00
Alexander Kornienko 0ba86b73aa Re-applied r198807, r198808 with an additional change to fix linking in configure Release+Asserts build.
llvm-svn: 198875
2014-01-09 16:31:25 +00:00
Chandler Carruth 85e6e87171 Run llvm/utils/sort_includes.py over the Clang tools code. This doesn't
always produce as pretty of results as it does in LLVM and Clang, but
I don't mind and the value of having a single canonical ordering is very
high IMO.

Let me know if you spot really serious problems here.

llvm-svn: 198703
2014-01-07 20:05:01 +00:00
NAKAMURA Takumi 78f534d689 [CMake] clang-tools-extra: Update dependencies.
llvm-svn: 196860
2013-12-10 01:41:10 +00:00
Manuel Klimek 814f9bd93a Make clang's static analyzer checks available through clang-tidy.
This is implemented in a way that the current static analyzer
architecture allows, in the future we might want to revisit this.

With this change static analyzer checks are available from clang-tidy
by specifying -checks=clang-analyzer-<name>.

This change also fixes the use of the compilation database to allow
clang-tidy to be used like any other clang tool.

llvm-svn: 194707
2013-11-14 15:49:44 +00:00
Peter Collingbourne 8b1265b353 Introduce clang-query tool.
This tool is for interactive exploration of the Clang AST using AST matchers.
It currently allows the user to enter a matcher at an interactive prompt
and view the resulting bindings as diagnostics, AST pretty prints or AST
dumps. Example session:

$ cat foo.c
void foo(void) {}
$ clang-query foo.c --
clang-query> match functionDecl()

Match #1:

foo.c:1:1: note: "root" binds here
void foo(void) {}
^~~~~~~~~~~~~~~~~
1 match.

Differential Revision: http://llvm-reviews.chandlerc.com/D2098

llvm-svn: 194227
2013-11-08 00:08:23 +00:00
Edwin Vane c0f00b79f7 clang-modernize: Apply replacements using clang-apply-replacements
Summary:
The clang-apply-replacements process is now invoked to apply
replacements between applying transforms. This resulted in a massive
simplification of the tool:
- FileOverrides class no longer needed.
- Change tracking and code formatting no longer needed.
- No more dependency on libclangApplyReplacements.
- Final syntax check is easier to do directly now than with a separate
  header/source pair.

Replacement handling stuff abstracted into a new header/source pair to
de-clutter ClangModernize.cpp somewhat.

Tests updated.

Differential Revision: http://llvm-reviews.chandlerc.com/D1836

llvm-svn: 192032
2013-10-05 12:15:58 +00:00
Edwin Vane 6afb68408d Fix build by adding dep on TransformUtils
clang-apply-replacements unittest Makefile wasn't linking in TransformUtils.

llvm-svn: 191669
2013-09-30 14:29:28 +00:00
Edwin Vane 59d93af4a5 clang-apply-replacements: Add code formatting functionality
The tool now supports a collection of arguments to turn on and provide settings
for the formatting of code affected by applying replacements:
* --format turns on formatting (default style is LLVM)
* --style controls code style settings
* --style-config allows one to explicitly indicate where a style config file
  lives.

The libclangApplyReplacements interface has a new function to turn Replacements
into Ranges to be used with tooling::reformat().

llvm-svn: 191667
2013-09-30 13:59:21 +00:00
Edwin Vane bdd8561dea clang-modernize: Fixing a few left over cpp11-migrate references
Build files for unit tests hadn't been updated yet.

llvm-svn: 191451
2013-09-26 19:26:58 +00:00
Ariel J. Bernal 583d095fa4 Transform files in a compilation database if no sources are provided.
Compile all files in a compilation database or a subset determined by a
sub-directory so you  don't have to specify them manually.

llvm-svn: 190630
2013-09-12 20:10:59 +00:00
Edwin Vane 5f002639e4 clang-modernize: Remove -headers option
clang-modernize can now transform headers properly and the experimental
-headers option is no longer necessary.

Remember, at least -include is necessary for indicating which headers
are allowed to be changed.

Differential Revision: http://llvm-reviews.chandlerc.com/D1610

llvm-svn: 190158
2013-09-06 14:23:56 +00:00
Chandler Carruth 8e8db654be Update the header guards for clang-modernize's unittests.
llvm-svn: 189974
2013-09-04 19:15:54 +00:00
Chandler Carruth e160627d7b Fix up a few straggling bits of the build system. This should fix the
build of the clang-modernize unittest which is for some reason not being
built by default on my system (sorry about that).

llvm-svn: 189966
2013-09-04 18:03:44 +00:00
Chandler Carruth d9063c46f5 Rename cpp11-migrate to clang-modernize.
There is no reason to expect this tool to be limited to C++11, it seems
very likely to be of on-going interest. It seems likely to be useful for
modernizing even as new libraries come out in TSes and other formats
than a complete standard. Fundamentally, we need something a bit more
general. After some discussion on the list, going with
'clang-modernize'.

I've tried to do a reasonably comprehensive job of fixing up the names,
but I may still have missed some. Feel free to poke me if you spot any
fallout here. Things I've tried reasonably hard to find and fix:

- cpp11-migrate -> clang-modernize
- Migrator -> Modernizer
- Clean up the introductory documentation that was C++11 specific.

I'll also point out that this tool continues to delight me. =] Also,
a huge thanks to those who have so carefully, thoroughly documented the
tool. The docs here are simply phenomenal. Every tool should be this
well documented. I hope I have updated the documentation reasonably
well, but I'm not very good at documentation, so review much
appreciated.

llvm-svn: 189960
2013-09-04 17:35:07 +00:00
Edwin Vane b225be2729 Rename clang-replace -> clang-apply-replacements
Made changes throughout clang-tools-extra for the renaming of
clang-replace to clang-apply-replacements as per feedback from
community.

llvm-svn: 189832
2013-09-03 17:58:19 +00:00
Edwin Vane 147984a8ad cpp11-migrate: Refactor for driver model of operation
Re-commit of r189691 and r189689 now with a proper autoconf fix.

Massive simplification of how replacements and file overrides are
handled by the migrator:
* Sources and headers are all treated the same.
* All replacements for a given translation unit are stored in the same
  TranslationUnitReplacements structure.
* Change tracking is updated only from main file; no need for
  propagating "is tracking" flag around.
* Transform base class no longer responsible for applying replacements.
  They are simply stored and main() looks after deduplication and
  application.
* Renamed -yaml-only to -serialize-replacements. Same restrictions apply:
  Can only request one transform. New restriction: formatting cannot also
  be turned on since it's basically a transform.
* If -serialize-replacements is requested, changes to files will not be
  applied on disk.
* Changed behaviour of function generating names for serialized
  replacements: Only the main source file goes into the name of the file
  since a file may contain changes for multiple different files.
* Updated HeaderReplacements LIT test for new serialization behaviour.
  * Replaced old test that ensures replacements are not serialized if
    -serialize-replacements is not provided. New version ensures changes
    are made directly to all files in the translation unit.
* Updated unit tests.
  * Due to major simplification of structures in FileOverrides.h, the
    FileOverridesTest is quite a bit simpler now.

llvm-svn: 189798
2013-09-03 13:16:02 +00:00
Michael Gottesman 92d9cb4dd1 Revert "cpp11-migrate: Fixing autoconf build after adding libclangReplace dependency"
Revert "cpp11-migrate: Refactor for driver model of operation"

This reverts commit r189691.
This reverts commit r189689.

This was breaking the phase 1 OS X build for ~2 hours.

https://smooshbase.apple.com/buildbot-internal/builders/phase1%20-%20sanity/builds/9559

I reverted the latter commit since I think the latter depended on the former.

llvm-svn: 189700
2013-08-30 22:09:03 +00:00
Edwin Vane 848c5dc7aa cpp11-migrate: Fixing autoconf build after adding libclangReplace dependency
llvm-svn: 189691
2013-08-30 19:45:49 +00:00
Edwin Vane 0acd502afe cpp11-migrate: Refactor for driver model of operation
Massive simplification of how replacements and file overrides are handled by
the migrator:
* Sources and headers are all treated the same.
* All replacements for a given translation unit are stored in the same
  TranslationUnitReplacements structure.
* Change tracking is updated only from main file; no need for
  propagating "is tracking" flag around.
* Transform base class no longer responsible for applying replacements.
  They are simply stored and main() looks after deduplication and
  application.
* Renamed -yaml-only to -serialize-replacements. Same restrictions apply:
  Can only request one transform. New restriction: formatting cannot also
  be turned on since it's basically a transform.
* If -serialize-replacements is requested, changes to files will not be
  applied on disk.
* Changed behaviour of function generating names for serialized
  replacements: Only the main source file goes into the name of the file
  since a file may contain changes for multiple different files.
* Updated HeaderReplacements LIT test for new serialization behaviour.
  * Replaced old test that ensures replacements are not serialized if
    -serialize-replacements is not provided. New version ensures changes
    are made directly to all files in the translation unit.
* Updated unit tests.
  * Due to major simplification of structures in FileOverrides.h, the
    FileOverridesTest is quite a bit simpler now.

Differential Revision: http://llvm-reviews.chandlerc.com/D1545

llvm-svn: 189689
2013-08-30 19:28:59 +00:00
Guillaume Papin 64feb39b1b cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r189037 (buildbot failures on Windows).

llvm-svn: 189354
2013-08-27 14:50:26 +00:00
Guillaume Papin 883a2b2427 Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r189017.

It broke the windows bots:
- http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/4176
- http://bb.pgr.jp/builders/cmake-clang-i686-mingw32/builds/3837

llvm-svn: 189037
2013-08-22 18:20:03 +00:00
Guillaume Papin effabf9691 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r188791 (buildbot failures on Windows).

llvm-svn: 189017
2013-08-22 14:49:07 +00:00
Edwin Vane d2cd2a4e1e cpp11-migrate: Use Replacement serialization from clang::tooling
Serialization of replacements has been moved to clang::tooling.

Differential Revision: http://llvm-reviews.chandlerc.com/D1423

llvm-svn: 188820
2013-08-20 19:20:52 +00:00
NAKAMURA Takumi 166b874696 UniqueHeaderNameTest.cpp: Appease valgrind.
llvm::sys::path::native(dst, dst) might be overridden-safe in most cases, though.

llvm-svn: 188800
2013-08-20 14:02:38 +00:00
Guillaume Papin 1593c7b20a Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r188791.

The Windows bots are still broken.

llvm-svn: 188795
2013-08-20 13:05:57 +00:00
Guillaume Papin f240481b99 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

This should fix the reverted commit r188610 (buildbot failures on Windows).

llvm-svn: 188791
2013-08-20 12:30:26 +00:00
Alexey Samsonov f656e1783b Add dependencies on TransformUtils library in preparation for re-applying r188666
llvm-svn: 188674
2013-08-19 13:58:56 +00:00
Guillaume Papin 8d951fbc18 Revert "cpp11-migrate: Add a class to support include directives modifications"
This reverts commit r188610.

Issue with the absolute include paths not found in the unit tests on the Windows
bots. Needs investigation.

llvm-svn: 188611
2013-08-17 19:04:56 +00:00
Guillaume Papin 114d035521 cpp11-migrate: Add a class to support include directives modifications
The IncludeDirectives class helps with detecting and modifying #include
directives. For now it allows the users to add angled-includes in a source file.
This is a start for this class that will evolve in the future to add more
functionality.

llvm-svn: 188610
2013-08-17 18:48:31 +00:00
Edwin Vane 169eec3620 cpp11-migrate: Remove mention of 'headers' from serialization code
* HeaderChangeDocument -> MigratorDocument
* HeaderFileName -> TargetFile
* SourceFileName -> MainSourceFile
* Removed TransformID
* Comments updated, at least with respect to serialization
* Unit tests updated.

Differential Revision: http://llvm-reviews.chandlerc.com/D1403

llvm-svn: 188404
2013-08-14 19:02:28 +00:00
Tareq A. Siraj 3baabf3968 cpp11-migrate: Write header replacements to disk
Another attempt to commit r187204 after windows related problems has
been fixed. Note that changes to this patch reflect the current behavior
of cpp11-migrate.

Header replacements are now written to disk in YAML format for an external tool
to merge. A unique file will be created in the same directory as the header
with all replacements that came from a source file that included the header
file. The YAML file will have:
- Name of the header file
- Name of the source file that included the header file
- Transform ID that generated the replacement
- Offset
- Length
- Replacement text

Any tool reading these replacements should read them using the
HeaderChangeDocument struct.

Differential Revision: http://llvm-reviews.chandlerc.com/D1369

llvm-svn: 188274
2013-08-13 14:58:50 +00:00
Tareq A. Siraj 9111258ad7 cpp11-migrate: Fixed path problem with include/exclude paths
This fixes a problem when the path separator in the include/exclude
directory is different (e.g. "\" vs. "/") from the path separator in
the file path we are modifying.

Differential Revision: http://llvm-reviews.chandlerc.com/D1326

llvm-svn: 188094
2013-08-09 19:24:05 +00:00
Daniel Jasper 89bbab09dd Fix clang-tidy dependencies and bad file comment.
This addresses comments in post-commit review of r187345.

llvm-svn: 187707
2013-08-04 15:56:30 +00:00
Ariel J. Bernal dec84e1139 Fixed path differences when using include/exclude headers
Added function for removing relative operators from input paths.

llvm-svn: 187481
2013-07-31 04:00:28 +00:00
Rafael Espindola 0ff671b3be Revert "cpp11-migrate: Write header replacements to disk"
This reverts commit 187428. It broke the windows bots.
http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/3450

llvm-svn: 187447
2013-07-30 21:05:56 +00:00
Tareq A. Siraj 67fa4114a6 cpp11-migrate: Write header replacements to disk
Committing r187204 with fixes for darwin. Note that one of the lit tests are
disabled on windows due to a bug in writing header replacements to file.

Header replacements are now written to disk in YAML format for an external tool
to merge. A unique file will be created in the same directory as the header
with all replacements that came from a source file that included the header
file. The YAML file will have:
 - Name of the file
 - Transform ID that generated the replacement
 - Offset
 - Length
 - Replacement text

Any tool reading these replacements should read them using the
TransformDocument struct.

llvm-svn: 187428
2013-07-30 18:18:02 +00:00
Guillaume Papin a3eede2cc2 cpp11-migrate: Add -for-compilers command line switch.
This change add a new option command line option -for-compilers that allows the
user to enable multiple transforms automatically.

Another difference is that now all transforms are enabled by default.

llvm-svn: 187360
2013-07-29 15:58:47 +00:00