Commit Graph

1999 Commits

Author SHA1 Message Date
Manuel Klimek 63c6989d70 include-fixer: Don't overwrite buffer changes
Raise a signal if the buffer has been modified before replacing it, to
avoid overwriting users' changes.

Patch by Philipp Stephani.

llvm-svn: 285060
2016-10-25 11:31:22 +00:00
Manuel Klimek 8e5f5ff4c1 Load clang-include-fixer.el from the unit test suite so that the unit tests can run in batch mode.
Patch by Philipp Stephani.

llvm-svn: 285059
2016-10-25 11:30:28 +00:00
Jason Henline 481e6aaa45 [clang-tidy] Fix identifier naming in macro args.
Summary:
clang-tidy should fix identifier naming even when the identifier is
referenced inside a macro expansion, provided that the identifier enters
the macro expansion completely within a macro argument.

For example, this will allow fixes to the naming of the identifier
'global' when it is declared and used as follows:

  int global;
  #define USE_IN_MACRO(m) auto use_##m = m
  USE_IN_MACRO(global);

Reviewers: alexfh

Subscribers: jlebar, cfe-commits

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

llvm-svn: 284992
2016-10-24 17:20:32 +00:00
Eugene Zelenko 566b34d9b7 [Release notes] Mention removed Clang-tidy misc-pointer-and-integral-operation check
llvm-svn: 284894
2016-10-21 22:35:58 +00:00
Richard Smith 00c03c5de7 Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only cases
it detects are ill-formed (some per C++ core issue 1512, others always have
been).

llvm-svn: 284888
2016-10-21 21:50:28 +00:00
Justin Lebar ae90ad2065 [clang-tidy] Don't use a SmallSetVector of an enum.
Summary:
This doesn't work after converting SmallSetVector to use DenseSet.

Instead we can just use a SmallVector.

Reviewers: timshen

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 284873
2016-10-21 20:13:39 +00:00
Haojian Wu 29c38f75a2 [clang-move] Support moving template class forward declarations.
llvm-svn: 284859
2016-10-21 19:26:43 +00:00
Malcolm Parsons 5c24a1148d [clang-tidy] Add check 'readability-redundant-member-init'
Summary: The check emits a warning if a member-initializer calls the member's default constructor with no arguments.

Reviewers: sbenza, alexfh, aaron.ballman

Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, cfe-commits, beanz

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

llvm-svn: 284742
2016-10-20 16:08:03 +00:00
Malcolm Parsons e9425b24b7 Use auto in for loop
llvm-svn: 284737
2016-10-20 15:40:34 +00:00
Malcolm Parsons c2da631c5a [clang-tidy] Simplify modernize-use-default
Summary:
clang-tidy now cleans up after replacements, so leave colon and comma
removal to that.

Reviewers: angelgarcia, alexfh, aaron.ballman, djasper, ioeric

Subscribers: djasper, cfe-commits

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

llvm-svn: 284735
2016-10-20 15:31:34 +00:00
Haojian Wu 7c870a7e54 [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.
Summary:
The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.

Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 284727
2016-10-20 13:15:40 +00:00
Haojian Wu 157e46dd45 [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.
The check is modernize-avoid-bind.

Consider the following:

  void bar(int x, int y);

  namespace N {
    void bar(int x, int y);
  }

  void foo(){
    auto Test = std::bind(N::bar,1,1);
  }

clang-tidy’s modernize-avoid-bind check suggests writing:

  void foo(){
    auto Test =[] {return bar(1,1);};
  }

instead of:

  void foo(){
    auto Test = [] {return N::bar(1,1);};
  }

So clang-tidy has proposed an incorrect Fix.

Patch by IdrissRio!

Reviewers: alexfh, hokein, aaron.ballman

Subscriber: cfe-commits
llvm-svn: 284719
2016-10-20 11:32:47 +00:00
Marek Kurdej 2cf1dc2add [clang-tidy] Add cert-err09-cpp check alias.
Summary: This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp.

Reviewers: alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 284596
2016-10-19 14:28:19 +00:00
Haojian Wu 67bb651ad1 [clang-move] Move using-decl in old cc.
Summary:
Another fix is to move the whole anonymous namespace declaration
completely instead of moving fun/var declarations only.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284592
2016-10-19 14:13:21 +00:00
Benjamin Kramer 089a39e859 Don't copy replacements in for-range loop. NFC.
llvm-svn: 284589
2016-10-19 13:50:17 +00:00
Simon Pilgrim 6b6291aa9b Fix signed/unsigned comparison warnings
llvm-svn: 284476
2016-10-18 13:15:31 +00:00
Alexander Kornienko 98d3391a59 [clang-tidy] Clean up code after applying replacements.
Summary:
Remove empty namespaces and initializer list commas / colons in
affected ranges. Initial patch: proper options for enabling the cleanup and
specifying the format style are needed.

Reviewers: hokein, ioeric

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284399
2016-10-17 17:25:02 +00:00
Haojian Wu ac97fc3902 [clang-move] Fix generating illegal header guard.
The filepath might contain some characters (i.e. '@') which are not
illegal in c identifiers. This patch changes all non-alphanumeric characters
to '_'.

llvm-svn: 284391
2016-10-17 15:26:34 +00:00
Haojian Wu bd31488083 Fix windows buildbot error.
llvm-svn: 284370
2016-10-17 10:05:25 +00:00
Haojian Wu ada286202e Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284368
2016-10-17 08:33:59 +00:00
NAKAMURA Takumi 0cfbbaeca3 ClangMoveTests.cpp: Appease msc18.
clang-tools-extra\unittests\clang-move\ClangMoveTests.cpp(216) : error C2593: 'operator =' is ambiguous
          llvm\include\llvm/ADT/SmallVector.h(898): could be 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)'
          llvm\include\llvm/ADT/SmallVector.h(893): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVectorImpl<T> &&)'
          with
          [
              T=std::string
          ]
          llvm\include\llvm/ADT/SmallVector.h(883): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVector<std::string,4> &&)'
          llvm\include\llvm/ADT/SmallVector.h(873): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(const llvm::SmallVector<std::string,4> &)'
          while trying to match the argument list '(llvm::SmallVector<std::string,4>, initializer-list)'

llvm-svn: 284360
2016-10-17 05:09:58 +00:00
NAKAMURA Takumi 7a6277a318 Reformat.
llvm-svn: 284359
2016-10-17 05:08:49 +00:00
Malcolm Parsons 778269dd78 [clang-tidy] Use ignoreImplicit in cert-err58-cpp check
Summary:
Fix a false negative in cert-err58-cpp check when calling a constructor
creates objects that require cleanup.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 284332
2016-10-16 09:47:10 +00:00
Alexander Shaposhnikov 5fe0678bd8 [clang-move] Use cl::list for the list of names
This diff replaces manual parsing of the comma-separated list of names with 
cl::list and cl::CommaSeparated.
Test plan: make -j8 check-clang-tools

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

llvm-svn: 284291
2016-10-14 23:16:25 +00:00
Haojian Wu 53eab1efcf [clang-move] Don't overuse Replacements::add.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284236
2016-10-14 13:43:49 +00:00
Martin Bohme 934743f8f8 [clang-tidy] Add additional diagnostic to misc-use-after-move
Summary:
This adds a diagnostic to the misc-use-after-move check that is output when the
use happens on a later loop iteration than the move, for example:

    A a;
    for (int i = 0; i < 10; ++i) {
      a.foo();
      std::move(a);
    }

This situation can be confusing to users because, in terms of source code
location, the use is above the move. This can make it look as if the warning
is a false positive, particularly if the loop is long but the use and move are
close together.

In cases like these, misc-use-after-move will now output an additional
diagnostic:

  a.cpp:393:7: note: the use happens in a later loop iteration than the move

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 284235
2016-10-14 13:23:39 +00:00
Haojian Wu 220c755dfc [clang-move] Add header guard for the new header.
Summary:
The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.

Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284233
2016-10-14 13:01:36 +00:00
Haojian Wu 7bd492c53a [clang-move] Matching static class member more correctly.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284221
2016-10-14 10:07:58 +00:00
Marek Kurdej 505434bd28 [clang-tidy] Fix readability-braces-around-statements false positive
Summary:
This fixes a false-positive e.g. when string literals are returned from if statement.

This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check.

Reviewers: alexfh, hokein

Subscribers: hokein

Tags: #clang-tools-extra

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

llvm-svn: 284212
2016-10-14 08:10:08 +00:00
Eric Liu 6ed762ce18 [clang-move] error out when fail to create new files.
llvm-svn: 284155
2016-10-13 19:49:19 +00:00
Eric Liu 92db01ebd7 Print stack trace for clang-move tool.
llvm-svn: 284148
2016-10-13 19:04:19 +00:00
Eric Liu 3db05219f7 Print stack trace for clang-change-namespace tool.
llvm-svn: 284147
2016-10-13 18:56:14 +00:00
Haojian Wu e77bcc7371 [clang-move] Better support enclosing class.
Summary:
* When moving an outermost enclosing class, all its nested classes should also
  be moved together.
* Add a test for not moving nested class.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284111
2016-10-13 10:31:00 +00:00
Haojian Wu 9df3ac1f56 Recommit r283538 "[clang-move] Support moving multiple classes in one run."
llvm-svn: 284109
2016-10-13 08:48:42 +00:00
Haojian Wu db72657774 [clang-move] Compare with real paths of symlinks
Summary: MakeAbsolutePath does wrong things with symlinks previously. When comparing with a symlink, we need to compare with the real path of it. This fixes issues when the build directory is a symlink.

Reviewers: ioeric

Subscribers: beanz, mgorny, cfe-commits, bkramer

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

llvm-svn: 284020
2016-10-12 15:50:30 +00:00
Eric Liu 73f49fd3f9 [change-namespace] don't miss comments in the beginning of a namespace block.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 284011
2016-10-12 12:34:18 +00:00
Marek Kurdej be07d1184b [clang-tidy-vs] Fix ClangTidy extension name in the manifest.
llvm-svn: 283986
2016-10-12 08:32:59 +00:00
Haojian Wu 4900c18d66 Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"
This reverts commit r283981. This patch breaks the buildbot.

llvm-svn: 283985
2016-10-12 08:19:44 +00:00
Haojian Wu 6c24d9345d [ClangTidy] Add UsingInserter and NamespaceAliaser
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 283981
2016-10-12 07:59:54 +00:00
Malcolm Parsons 66b7014092 [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init
Summary: Empty/incomplete variables/members/bases don't need to be initialized

Reviewers: mgehre, aaron.ballman, alexfh

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 283886
2016-10-11 14:49:24 +00:00
Haojian Wu 09c8d2e19f [clang-tidy] Fix template agrument false positives in unused-using-decls.
Summary:
* Fix a false postive when an using class is used in an explicit template instantiation.
* Fix a false postive when an using template class is used as template argument.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 283879
2016-10-11 13:50:34 +00:00
Malcolm Parsons 8cb9b02c7e [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix
Summary: Bugfix for 30398.  Don't warn for template instantiations

Reviewers: aaron.ballman, hokein, alexfh

Subscribers: omtcyfz, cfe-commits

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

llvm-svn: 283873
2016-10-11 12:02:16 +00:00
Malcolm Parsons 7a325537fb [clang-tidy] modernize-use-default default constructor bugfix
Summary:
Only member initializers that are written should prevent
using '= default' on a default constructor.

Reviewers: klimek, sbenza, aaron.ballman, alexfh

Subscribers: Eugene.Zelenko, alexfh, klimek, cfe-commits

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

llvm-svn: 283869
2016-10-11 10:47:06 +00:00
Malcolm Parsons f156079921 Fix typo in documentation
llvm-svn: 283865
2016-10-11 09:42:13 +00:00
Manuel Klimek 516a3df5cf clang-include-fixer.el: Don't prompt the user about killing clang-include-fixer processes
By default, Emacs prompts the user when killing processes on exit. This is useful for stateful processes such as interactive shells. However, clang-include-fixer processes are stateless; the only effect of killing them is to cancel a clang-include-fixer operation. Therefore prompting the user is just a nuisance.

Patch by Philipp Stephani.

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

llvm-svn: 283863
2016-10-11 09:21:20 +00:00
Manuel Klimek 750f6a780b Make Emacs libraries compatible with Emacs 24.
Emacs 24 doesn't have format-message, fall back to format in that case.

Patch by Philipp Stephani.

llvm-svn: 283861
2016-10-11 09:15:10 +00:00
Mehdi Amini 7ba59edbfb Fix clang-tools-extra build after r283815 (Store FileEntry::Filename as a StringRef instead of raw pointer)
llvm-svn: 283819
2016-10-10 23:24:16 +00:00
Haojian Wu eaf77911b2 [clang-tidy] Add a whitelist option in google-runtime-references.
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 283777
2016-10-10 16:38:11 +00:00
Haojian Wu ea99ff719b [include-fixer] query-mode should be false by default.
Makes it consistent with documentations.

llvm-svn: 283754
2016-10-10 14:21:55 +00:00
Manuel Klimek 5f85048385 Use `let' instead of `let*' in one place where `let*' isn't necessary
Differential Revision: https://reviews.llvm.org/D25395

Patch by Philipp Stephani.

llvm-svn: 283736
2016-10-10 10:22:40 +00:00