Commit Graph

1821 Commits

Author SHA1 Message Date
Miklos Vajna 3d71b51bc5 clang-rename rename-all: support reading old/newname pairs from a YAML file
This is handy in case by the time clang-rename is invoked, an external
tool already genereated a list of oldname -> newname pairs to handle.

Reviewers: omtcyfz

Differential Revision: https://reviews.llvm.org/D23198

llvm-svn: 278145
2016-08-09 18:20:41 +00:00
Kirill Bobyrev 7fa3395364 [clang-rename] cleanup: use isWritten
nit: use isWritten and const auto *Initializer in
NamedDeclFindingASTVisitor::VisitCXXConstructorDecl method.
Test plan: make -j8 check-clang-tools (passed)

Patch by Alexander Shaposhnikov!

Reviewers: omtcyfz

Differential Revision: https://reviews.llvm.org/D23298

llvm-svn: 278112
2016-08-09 10:03:33 +00:00
Simon Pilgrim 6cfad71fd7 Fix Wdocumentation unknown parameter warning
llvm-svn: 278111
2016-08-09 10:02:11 +00:00
Haojian Wu c99f72868d [include-fixer] Support processing multiple files in one run.
Summary:
Previously, if we pass multiple files or a file pattern (e.g. /path/to/*.cc) to
include-fixer, include-fixer will apply all replacements to the first argument,
which probably causes crashes.

With this patch, include-fixer can process multiple files now.

Vim and Emacs integration are tested manually.

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23266

llvm-svn: 278102
2016-08-09 08:26:19 +00:00
Eric Liu 7e5445267f Fix clang-tidy crash when a single fix is applied on multiple files.
Summary:
tooling::Replacements only holds replacements for a single file, so
this patch makes Fix a map from file paths to tooling::Replacements so that it
can be applied on multiple files.

Reviewers: hokein, alexfh

Subscribers: Prazek, cfe-commits

Differential Revision: https://reviews.llvm.org/D23257

llvm-svn: 278101
2016-08-09 07:54:49 +00:00
Kirill Bobyrev 31fd7fb5e6 [clang-rename] fix bug with initializer lists
Clang-rename is currently not able to find a symbol in initializer list. This
patch fixes described issue.

Reviewers: alexfh

Differential Revision: https://reviews.llvm.org/D23193

llvm-svn: 278099
2016-08-09 07:14:48 +00:00
Kirill Bobyrev 75de8968b6 [clang-tidy] enhance modernize-use-bool-literals to check ternary operator
modernize-use-bool-literals doesn't checks operands in ternary operator.

For example:

``` c++
static int Value = 1;

bool foo() {
  bool Result = Value == 1 ? 1 : 0;
  return Result;
}

bool boo() {
  return Value == 1 ? 1 : 0;
}
```

This issue was reported in bug 28854. The patch fixes it.

Reviewers: alexfh, aaron.ballman, Prazek

Subscribers: Prazek, Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D23243

llvm-svn: 278022
2016-08-08 17:11:56 +00:00
Haojian Wu dd14b18def [include-fixer] Correct some header mappings.
Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23199

llvm-svn: 277811
2016-08-05 11:54:34 +00:00
John Brawn 4d79ec7fe8 Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
This differs from the previous version by being more careful about template
instantiation/specialization in order to prevent errors when building with
clang -Werror. Specifically:
 * begin is not defined in the template and is instead instantiated when Head
   is. I think the warning when we don't do that is wrong (PR28815) but for now
   at least do it this way to avoid the warning.
 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
   instead provide a template definition then do explicit instantiation. No
   compiler I've tried has problems with doing it the other way, but strictly
   speaking it's not permitted by the C++ standard so better safe than sorry.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 277806
2016-08-05 11:01:08 +00:00
Alexander Kornienko 6b2a4d5e8f [clang-tidy] misc-argument-comment non-strict mode
Summary:
The misc-argument-comment check now ignores leading and trailing underscores and
case. The new `StrictMode` local/global option can be used to switch back to
strict checking.

Add getLocalOrGlobal version for integral types, minor cleanups.

Reviewers: hokein, aaron.ballman

Subscribers: aaron.ballman, Prazek, cfe-commits

Differential Revision: https://reviews.llvm.org/D23135

llvm-svn: 277729
2016-08-04 14:54:54 +00:00
Kirill Bobyrev 8100940b8b [clang-rename] add missing clang-format improvements
r277702 introduced clang-format changes so that later commits wouldn't introduce
non-functional changes while running clang-format before commiting. Though,
few changes by clang-format weren't in the patch.

llvm-svn: 277709
2016-08-04 09:23:30 +00:00
Miklos Vajna 0c07f0cb0b Run clang-format on clang-rename code
So that later commits don't introduce non-functional changes when
running clang-format before committing.

Reviewers: klimek

Differential Revision: https://reviews.llvm.org/D23153

llvm-svn: 277702
2016-08-04 07:43:29 +00:00
Alexander Kornienko dcbf57d198 [clang-tidy] Inefficient string operation
Patch by Bittner Barni!

Differential revision: https://reviews.llvm.org/D20196

llvm-svn: 277677
2016-08-03 23:06:03 +00:00
Kirill Bobyrev d6ab7d4508 [clang-rename] improve USRFindingAction
1. Improve templated class renaming, namely add capabilities of finding partial
and full specializations. Every class partial specialization has reference to
the specialized class. Thus, storing all partial specializations and
comparing specialized class decls to the FoundDecl solves this. All full class
specializations can be found by calling ClassTemplateDecl::specializations().

2. Fix virtual function and its overriding functions renaming. Renaming a
virtual function requires renaming every other function in its "overriding
graph".

3. Merge TemplateClassInstantiationFindBy{Declaration|TypeUse}.cpp tests into
one test by adding multiple invocations of clang-rename to one test, because
the only different thing across these tests is -offset passed to clang-rename.

Reviewers: alexfh

Differential Revision: https://reviews.llvm.org/D23058

llvm-svn: 277663
2016-08-03 23:00:32 +00:00
Kirill Bobyrev f9e2f4410e [docs] fix typo in clang-rename docs
clang-rename is a refactoring tool, not "linter" tool. Fix typo in docs.

llvm-svn: 277623
2016-08-03 18:15:07 +00:00
Etienne Bergeron 58728c6e9a [extra-tools] Fix extra tools build bot warnings due to incorrect doc
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/tools/extra/clang-tidy/mpi/TypeMismatchCheck.cpp:172:12: warning: parameter 'Complex' not found in the function declaration [-Wdocumentation]
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/tools/extra/clang-tidy/mpi/TypeMismatchCheck.cpp:206:12: warning: parameter 'Complex' not fo

llvm-svn: 277578
2016-08-03 06:59:46 +00:00
Kirill Bobyrev cf162a3031 [clang-tidy] address concerns with rL277340
alexfh raised a concern with https://reviews.llvm.org/rL277340

After retabbing indentation of .. code-block:: was increased to 8, 4 spaces
indentation should be enough.

Reviewers: alexfh
llvm-svn: 277577
2016-08-03 06:54:24 +00:00
Etienne Bergeron ee0627fd1b [clang-tidy] Fix missing dependency to static analyzer
Summary:
This patch is fixing the build bot broken for a missing dependency.

The missing dependency is breaking "shared" build.

```
./mpi/TypeMismatchCheck.cpp:
  #include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
```

I'm not a fan of that fix. It's brining a strange dependency.

Reviewers: alexfh

Subscribers: llvm-commits, chrisha

Differential Revision: https://reviews.llvm.org/D23093

llvm-svn: 277539
2016-08-02 22:51:46 +00:00
Jonathan Coe 77ec263e60 [clang-tidy] Fix segfault in cppcore-guidelines-special-member-functions check
Summary:
Use a set rather than a vector of defined special member functions so
that multiple declarations of the same function are only counted once.

Move some private static member functions into the cpp file.

Run clang-format on header.

Reviewers: ericLemanissier, Prazek, aaron.ballman

Subscribers: Prazek, cfe-commits, nemanjai

Projects: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D23008

llvm-svn: 277523
2016-08-02 21:18:37 +00:00
Alexander Kornienko 053826f146 [docs] Fix links format.
llvm-svn: 277517
2016-08-02 20:29:47 +00:00
Alexander Kornienko 5e0a50c2d7 [clang-tidy] MPITypeMismatchCheck
This check verifies if buffer type and MPI (Message Passing Interface)
datatype pairs match. All MPI datatypes defined by the MPI standard (3.1)
are verified by this check. User defined typedefs, custom MPI datatypes and
null pointer constants are skipped, in the course of verification.

Instructions on how to apply the check can be found at:
https://github.com/0ax1/MPI-Checker/tree/master/examples

Patch by Alexander Droste!

Differential revision: https://reviews.llvm.org/D21962

llvm-svn: 277516
2016-08-02 20:29:35 +00:00
Kirill Bobyrev ef2ee1fd67 [clang-rename] fix Emacs integration script
llvm-svn: 277491
2016-08-02 18:23:08 +00:00
Kirill Bobyrev cb2bac6e98 [clang-rename] fix Emacs script build failure
Clang-rename Emacs integration script sometimes doesn't work correctly.

llvm-svn: 277469
2016-08-02 15:10:17 +00:00
NAKAMURA Takumi b650462007 clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Appease targeting ms mode.
llvm-svn: 277452
2016-08-02 13:17:40 +00:00
NAKAMURA Takumi acf37a9234 clang-tools-extra/test/clang-rename/TemplateTypenameFindBy*.cpp: Move RUN: lines below not to be affected by tweaks of parameters.
llvm-svn: 277451
2016-08-02 13:17:36 +00:00
Haojian Wu da2a58dd0b [clang-tidy] Fix an unused-using-decl false positive about template arguments in
function call expression.

Summary:
The check doesn't mark the template argument as used when the template
argument is a template.

Reviewers: djasper, alexfh

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D22803

llvm-svn: 277444
2016-08-02 11:26:35 +00:00
Haojian Wu adedac68dc [include-fixer] Correct nested class search for identifiers with scoped information
Summary:
include-fixer will firstly try to use scoped namespace context information to
search identifier. However, in some cases, it's unsafe to do nested class
search, because it might treat the identifier as a nested class of scoped
namespace.

Given the following code, and the symbol database only has two classes: "foo" and
"b::Bar".

    namespace foo { Bar t; }

Before getting fixing, include-fixer will never search "Bar" symbol.
Because it firstly tries to search "foo::Bar", there is no "Bar" in foo namespace,
then it finds "foo" in database finally. So it treats "Bar" is a nested class
of "foo".

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23023

llvm-svn: 277442
2016-08-02 10:43:10 +00:00
Miklos Vajna aaec9b6cfc clang-rename: split existing options into two new subcommands
- rename-at is meant to be integrated with editors and works mainly off
  of a location in a file, and this is the default
- rename-all is optimized for one or more oldname->newname renames, and
  works with clang-apply-replacements

Reviewers: bkramer, klimek

Subscribers: omtcyfz

Differential Revision: https://reviews.llvm.org/D21814

llvm-svn: 277438
2016-08-02 09:51:31 +00:00
Kirill Bobyrev 9e0dab9352 [clang-rename] add support for template parameter renaming
Few simple tweaks allow template parameters to be renamed. See
TemplateTypenameFindBy{TemplateParam|TypeInside}.cpp

Reviewers: alexfh

Differential Revision: https://reviews.llvm.org/D22853

llvm-svn: 277437
2016-08-02 09:38:38 +00:00
Kirill Bobyrev aa4845004d [clang-rename] add basic Emacs integration
This patch aims to add very basic Emacs integration.

Reviewers: hokein, alexfh

Differential Revision: https://reviews.llvm.org/D23006

llvm-svn: 277433
2016-08-02 08:51:26 +00:00
Kirill Bobyrev 91053e0675 [clang-rename] handle overridden functions correctly
1. Renaming overridden functions only works for two levels of "overriding
   hierarchy". clang-rename should recursively add overridden methods.
2. Make use of forEachOverridden AST Matcher.
3. Fix two tests.

Reviewers: alexfh

Differential Revision: https://reviews.llvm.org/D23009

llvm-svn: 277356
2016-08-01 17:15:57 +00:00
Kirill Bobyrev 08c47b37d3 [clang-rename] revert r276836
Revert r276836, which resulted in tests passing regardless of the actual tool
replacements.

llvm-svn: 277354
2016-08-01 16:48:33 +00:00
Kirill Bobyrev 11cea45cce [clang-tidy] remove trailing whitespaces and retab
llvm-svn: 277340
2016-08-01 12:06:18 +00:00
Martin Bohme d10be62383 [clang-tidy] Prepare modernize-loop-convert for upcoming changes in D22566
Summary:
D22566 will change RecursiveASTVisitor so that it descends into the initialization expressions for lambda captures.

modernize-loop-convert needs to be prepared for this so that it does not interpret these initialization expressions as invalid uses of the loop variable. The change has no ill effects without D22566 in place, i.e. the change does not depend on D22566.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22903

llvm-svn: 277339
2016-08-01 11:29:17 +00:00
Eric Liu 267034ca9c Changes related to new implementation of tooling::Replacements as class.
Summary: See http://reviews.llvm.org/D21748 for details.

Reviewers: djasper, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D21749

llvm-svn: 277336
2016-08-01 10:16:39 +00:00
Jonathan Coe 5d304b2456 [clang-tidy] add check cppcoreguidelines-special-member-functions
Summary:
Check for classes that violate the rule of five and zero as specified in CppCoreGuidelines:

"If a class defines or deletes a default operation then it should define or delete them all."

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, cfe-commits, ericLemanissier, nemanjai

Projects: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D22513

llvm-svn: 277262
2016-07-30 08:58:54 +00:00
Aaron Ballman 2931002c8e Sorting includes; NFC.
llvm-svn: 277217
2016-07-29 21:41:18 +00:00
Kirill Bobyrev 83d5d5680f [clang-rename] speedup RenamingAction
The complexity of renaming a USR is O(N) [N stands for number of nodes in
Translation Unit]. In some cases there are more than one USR for a single symbol
(see overridden functions and ctor/dtor handling), which means that the
complexity of finding all of the corresponding USRs is O(N * M) [M stands for
number of USRs corresponding to the symbols, which may be not quite small]. With
a simple tweak we can make it O(N * log(M)) by passing whole list of USRs
corresponding to the symbol to USRLocFinder.

llvm-svn: 277131
2016-07-29 10:16:45 +00:00
Justin Lebar 41e9dad437 [Typo police] s/proccess/process/, s/auxiliary/auxilliary/.
llvm-svn: 277113
2016-07-29 05:26:58 +00:00
Piotr Padlewski 8f80229109 [clang-tidy] Fixes to modernize-use-emplace
Not everything is valid, but it should works for 99.8% cases

https://reviews.llvm.org/D22208

llvm-svn: 277097
2016-07-29 02:10:23 +00:00
John Brawn 2853269224 Revert r276973 "Adjust Registry interface to not require plugins to export a registry"
Buildbot failures when building with clang -Werror. Reverting while I try to
figure this out.

llvm-svn: 277008
2016-07-28 17:17:22 +00:00
John Brawn 778c3c6c61 Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"
This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 276973
2016-07-28 12:48:17 +00:00
Kirill Bobyrev 1081ccf855 [clang-rename] remove redundant *_cast<> traversal
llvm-svn: 276971
2016-07-28 10:31:16 +00:00
Kirill Bobyrev 1f0ea35ef9 [clang-rename] USRFinder.cpp cleanup
llvm-svn: 276967
2016-07-28 09:05:06 +00:00
Saleem Abdulrasool 6fbf18ca24 test: fix typo in file name (NFC)
llvm-svn: 276949
2016-07-28 00:43:14 +00:00
Saleem Abdulrasool c67dd95697 clang-rename: adjust NamedDeclFindingASTVisitor for RecordDecls
Ensure that Context is always properly initialised in the constructor.  It is
used for querying the LangOpts in VisitTypeLoc.  Prevent a null pointer
dereference in setResult by ensuring that a RecordDecl is being handled.

Patch by Alexander Shaposhnikov!

llvm-svn: 276948
2016-07-28 00:42:01 +00:00
Kirill Bobyrev 5c339ec830 fix typo in clang-rename and clang-tidy docs
llvm-svn: 276871
2016-07-27 14:26:03 +00:00
Kirill Bobyrev c4018e2db6 change Vim key binding for include-fixer and clang-rename
Change Vim key binding for include-fixer (`,cf` -> `<leader>cf`) and
clang-rename (`,cr` -> `<leader>cr`) to use `<leader>` instead of `,` like
cool Vim people (tm) do.

Reviewers: ioeric

Differential Revision: https://reviews.llvm.org/D22854

llvm-svn: 276870
2016-07-27 14:23:47 +00:00
Kirill Bobyrev 5b7f016f41 [clang-rename] skip CXXConversionDecl while searching for NamedDecl
llvm-svn: 276866
2016-07-27 13:37:22 +00:00
Haojian Wu 499375ceaa [include-fixer] Update document.
llvm-svn: 276862
2016-07-27 13:17:16 +00:00