Commit Graph

1798 Commits

Author SHA1 Message Date
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
Haojian Wu 32afa383cb [clang-tidy] Add cppcoreguidelines-slicing entry to list.rst.
llvm-svn: 276861
2016-07-27 13:11:50 +00:00
Benjamin Kramer 57d070e6fd [clang-include-fixer] Added Emacs integration for clang-include-fixer.
Patch by Jens Massberg! Thanks a lot.

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

llvm-svn: 276853
2016-07-27 10:11:06 +00:00
Saleem Abdulrasool 8357ccf7fb test: simplify commands, NFC
Rather than copying the file and then doing an in-place edit, perform the
replacements to stdout and pass the output to FileCheck directly.  Avoids
unnecessary copying and seds.

llvm-svn: 276836
2016-07-27 04:43:15 +00:00
Haojian Wu 5644618049 [include-fixer] Don't add qualifiers in missing complete type cases.
Summary: In missing complete type cases, we don't know where to add the qualifiers.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 276761
2016-07-26 16:32:42 +00:00
Martin Bohme 9d01ef97ef Revert test commit
This reverts rL276746.

llvm-svn: 276752
2016-07-26 14:37:39 +00:00
Martin Bohme 5d18c427ed Test commit -- adding a newline
llvm-svn: 276746
2016-07-26 14:01:48 +00:00
Eugene Zelenko a4c2efb60d [Clang-rename] Remove custom version, fix extra space in error message.
Also fixed some Include What You Use Warnings.

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

llvm-svn: 276684
2016-07-25 20:30:13 +00:00
Alexander Kornienko df4b4a8fab Revert "MPITypeMismatchCheck for Clang-Tidy"
This reverts commit r276640. Breaks multiple buildbots.

llvm-svn: 276651
2016-07-25 17:08:18 +00:00
Alexander Kornienko c30b5698b6 Revert "Remove trailing spaces."
This reverts commit r276641. Breaks multiple buildbots.

llvm-svn: 276650
2016-07-25 17:08:10 +00:00
Alexander Kornienko 41d8ed7a5c Remove trailing spaces.
llvm-svn: 276641
2016-07-25 15:43:22 +00:00
Alexander Kornienko 651767dbc7 MPITypeMismatchCheck for Clang-Tidy
Summary:
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

Reviewers: alexfh

Subscribers: cfe-commits

Projects: #clang-tools-extra

Patch by Alexander Droste!

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

llvm-svn: 276640
2016-07-25 15:43:14 +00:00
Kirill Bobyrev c20d47751d [clang-rename] fix typos in tests
TemplateFunctionFindBy{Declaration|Use}.cpp contained typos and therefore were
failing. clang-rename passes these tests after typos are fixed.

llvm-svn: 276620
2016-07-25 08:56:11 +00:00
NAKAMURA Takumi 9faa0dc08e ClangRenameTests: Update libdeps.
llvm-svn: 276445
2016-07-22 17:33:04 +00:00
Clement Courbet 22c9e93147 Revert "Revert "[clang-tidy] new cppcoreguidelines-slicing""
Second try for r276408

llvm-svn: 276415
2016-07-22 13:45:00 +00:00
Kirill Bobyrev a3432fa91c [clang-rename] introduce better symbol finding
This patch introduces:

* TypeLoc visiting, which helps a lot in renaming types
* NestedNameSpecifierLoc visiting (through getting them via ASTMatcher at the moment, though, because RecursiveASTVisitor<T>::VisitNestedNameSpecifierLoc isn't implemented), which helps to treat nested names correctly
* better code formatting and refactoring
* bunch of tests

Reviewers: alexfh

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

llvm-svn: 276414
2016-07-22 13:41:09 +00:00
Clement Courbet bd7aa358f0 Revert "[clang-tidy] new cppcoreguidelines-slicing"
Tests fail on clang-x64-ninja-win7 due to too narrow expectation.

llvm-svn: 276413
2016-07-22 13:33:51 +00:00
Clement Courbet f67fbfaa8c [clang-tidy] new cppcoreguidelines-slicing
Flags slicing of member variables or vtable. See:

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references

Differential revision:
http://reviews.llvm.org/D21974

llvm-svn: 276408
2016-07-22 12:42:19 +00:00
Benjamin Kramer e0f35a57cd [include-fixer] Fix faulty sort predicate.
Note the == on the last line, this isn't a strict-weak ordering.

llvm-svn: 276400
2016-07-22 09:07:16 +00:00
Eugene Zelenko 0c5b92cae6 Restructure release notes.
Differential revision: https://reviews.llvm.org/D22605

llvm-svn: 276371
2016-07-22 00:34:42 +00:00
Benjamin Kramer 7035cbf8eb [clang-tidy] Avoid duplicated DenseMap lookup.
The std::string is still constructed on demand. No functionality change
intended.

llvm-svn: 276282
2016-07-21 14:13:45 +00:00
Haojian Wu 62aee528f6 [include-fixer] Add mising qualifiers to all instances of an unidentified symbol.
Reviewers: bkramer

Subscribers: ioeric, cfe-commits

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

llvm-svn: 276280
2016-07-21 13:47:09 +00:00
Kirill Bobyrev 08c588c73a [clang-rename] check whether -new-name is valid identifier in C++17
llvm-svn: 276259
2016-07-21 10:21:31 +00:00
Matthias Gehre 056237a457 clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)
Summary:
Previoly, the added test failed with the fillowing fixit:

     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

i.e. the variable 'value' changes from unsigned char to signed char. And
thus the following 'if' does not work anymore.

With this commit, the fixit is changed to:
     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(unsigned char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

Reviewers: alexfh, klimek

Subscribers: cfe-commits

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

llvm-svn: 276111
2016-07-20 12:32:06 +00:00