Commit Graph

1893 Commits

Author SHA1 Message Date
NAKAMURA Takumi 5541c8f4c2 ClangRenameTests: Update libdeps. r275958 introduced clangASTMatchers.
llvm-svn: 275985
2016-07-19 15:33:14 +00:00
Haojian Wu 9e4bd0c070 [include-fixer] A refactoring of IncludeFixerContext.
Summary:
No functional changes in this patch. It is a refactoring (pull out a
structure representing the symbol being queried).

This is a preparing step for inserting missing namespace qualifiers to all
instances of an unidentified symbol.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 275980
2016-07-19 14:49:04 +00:00
Kirill Bobyrev 953a97839f [clang-rename] add support for overridden functions
Reviewers: klimek

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

llvm-svn: 275958
2016-07-19 07:37:43 +00:00
Saleem Abdulrasool b12d27bdfa clang-rename: fix referenced variable in vim-script
llvm-svn: 275943
2016-07-19 02:13:08 +00:00
Benjamin Kramer 8ff8fdf4d4 Unbreak extra tools build post r275882.
llvm-svn: 275886
2016-07-18 19:21:22 +00:00
Hans Wennborg 4b4c90bf7a docs/conf.py: update version to 4.0
llvm-svn: 275849
2016-07-18 18:13:46 +00:00
Hans Wennborg 21669b4e49 Trunk release notes are now for 4.0.0
The 3.9 release are on the 3.9 branch.

llvm-svn: 275846
2016-07-18 18:08:59 +00:00
Haojian Wu fff3ad6e82 [include-fixer] Add an options allow moving the cursor to #include line in vim
after inserting a missing header.

Summary:

A small improvement: Don't print newline character at the end of message, so
that users don't have to type ENTER manually after running the python script.

Reviewers: bkramer

Subscribers: djasper, klimek, cfe-commits

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

llvm-svn: 275781
2016-07-18 10:04:45 +00:00
Kirill Bobyrev 1114048ac8 [clang-rename] remove obsolete tests and apply fixes to existing
Few tests introduced by previous patch had obsolete counterparts.

Applied fixes to {Dynamic|Static}CastExpr.cpp

llvm-svn: 275681
2016-07-16 08:55:01 +00:00
Kirill Bobyrev ee99fd13ae [clang-rename] fix testset
Make yet unsupported tests marked with FIXME pass so that buildbot doesn't fail.

llvm-svn: 275556
2016-07-15 12:22:38 +00:00
Kirill Bobyrev 32db76949c [clang-rename] apply stylistic fixes
llvm-svn: 275550
2016-07-15 11:29:16 +00:00
Kirill Bobyrev 713bdc01fb [clang-rename] add few tests
Thiis patch introduces few additional tests including one case the tool does not handle yet, which should be fixed in the future.

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

llvm-svn: 275545
2016-07-15 10:21:33 +00:00
Haojian Wu 39a718c48b [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 275542
2016-07-15 08:12:48 +00:00
Matthias Gehre 03fadabe47 cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode
Summary:
When the expression is value dependent,
isIntegerConstantExpr() crashes in C++03 mode with
 ../tools/clang/lib/AST/ExprConstant.cpp:9330: (anonymous namespace)::ICEDiag CheckICE(const clang::Expr *, const clang::ASTContext &):
  Assertion `!E->isValueDependent() && "Should not see value dependent exprs!"' failed.
In C++11 mode, that assert does not trigger.

This commit works around this in the check. We don't check
value-dependent indices and instead check their specialization.

Reviewers: alexfh, aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 275461
2016-07-14 20:00:48 +00:00
Benjamin Kramer 56a46bc680 Upgrade all the .arcconfigs to https.
llvm-svn: 275409
2016-07-14 13:15:37 +00:00
Benjamin Kramer b67e1e2dd7 [clang-rename] add documentation
clang-rename needs at least to have a minimum documentation to provide a
small introduction for new users

Patch by Kirill Bobyrev!

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

llvm-svn: 275388
2016-07-14 09:46:07 +00:00
Benjamin Kramer 1afefc0da3 [clang-rename] exit code-related bugfix and code cleanup
This patch does the following:

* enforces proper formatting for few files (i.e. deals with 80 linewidth violations and few other things)
* ensures '\n' chars are passed to the output streams instead of "\n" strings
* fixes a bug caused by calling cl::PrintHelpMessage(), which occasionally calls exit(0), so that exit(1) (which is right after cl::PrintHelpMessage line) becomes dead code

Patch by Kirill Bobyrev!

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

llvm-svn: 275387
2016-07-14 09:46:03 +00:00
Haojian Wu 0c05e2e4b6 [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.
Summary:
The judgement that checks whether the fully-qualified name has scoped qualifiers
prefix is incorrect. Should always check whether the first matched postion is the
beginning position.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 275386
2016-07-14 09:39:12 +00:00
Haojian Wu 68c34a083d [include-fixer] Implement adding missing namespace qualifiers in vim integration.
Summary:
The patch extends include-fixer's "-output-headers", and "-insert-headers"
command line options to make it dump more information (e.g. QualifiedSymbol),
so that vim-integration can add missing qualifiers.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 275279
2016-07-13 16:43:54 +00:00
Haojian Wu 0b067c1252 [clang-tidy] Fix misc-definitions-in-headers misplaced fixing to fully templated function.
Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 275263
2016-07-13 13:55:29 +00:00
Etienne Bergeron 238429bd1c fix missing newline in sphinx doc
llvm-svn: 275254
2016-07-13 06:06:48 +00:00
Eric Liu a452db4d0f Changes related to tooling::applyAllReplacements interface change in D21601.
Summary:
this patch contains changes related to the interface change from
http://reviews.llvm.org/D21601. Only submit this patch after D21601 is
submitted.

Reviewers: djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 275063
2016-07-11 13:53:21 +00:00
Haojian Wu d1218758e1 [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.
Summary:
Although there is no guarantee of getOptions/getRawOptions receiving an
absolute path, we try to make it if possible. So FileOptionProvider subclasses
don't have to convert the path to an absolute path.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 275051
2016-07-11 07:47:04 +00:00
Matthias Gehre a9e812b9cb clang-tidy/readability-identifier-naming: crash on DependentTemplateSpecializationType
Summary:
Previously, the added test cases crashed because the passed a null Decl
to addUsage().

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 274985
2016-07-09 20:09:28 +00:00
Haojian Wu 5d9482d887 [include-fixer] Don't add qualifiers to symbols which have global scope operator.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 274848
2016-07-08 14:28:43 +00:00
Haojian Wu 783d431ad1 [include-fixer] Pull out Context implementation code to a cpp file.
llvm-svn: 274845
2016-07-08 13:11:38 +00:00
Haojian Wu 68bb0b6b4b [clang-rename] fix typo in Python script for Vim integration
Patch by Kirill Bobyrev!

Reviewers: kimgr, alexfh, bkramer, ioeric, hokein

Subscribers: cfe-commits

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

llvm-svn: 274839
2016-07-08 12:05:06 +00:00
Haojian Wu 627ca96e4d [include-fixer] Add missing namespace qualifiers after inserting a missing header.
Summary:
This is an initial version of fixing namespace issues by adding missing
namespace qualifiers to an unidentified symbol.

This version only fixes the first discovered unidentified symbol.
In the long run, include-fixer should fix all unidentified symbols
with a same name at one run.

Currently, it works on command-line tool. The vim integration is not
implemented yet.

Reviewers: klimek, bkramer, djasper

Subscribers: bkramer, ioeric, cfe-commits

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

llvm-svn: 274832
2016-07-08 09:10:29 +00:00
Benjamin Kramer 3a12ca57ca [clang-rename] add basic vim integration
This patch introduces basic Vim integration for clang-rename tool.

For setup reference see clang-rename/tool/clang-rename.py

Patch by Kirill Bobyrev!

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

llvm-svn: 274759
2016-07-07 14:35:32 +00:00
Nico Weber 1e348b339c [clang-tidy] Add dependency on clang-headers
Currently, to be able to process a source file including e.g. stddef.h with
clang-tidy, one has to build both clang-tidy and the clang-headers target.
Since stddef.h is needed for virtually any source file, let clang-tidy depend
on clang-headers, so that it Just Works after it has been built.

http://reviews.llvm.org/D22046

llvm-svn: 274751
2016-07-07 13:19:45 +00:00
Etienne Bergeron 00639bc529 [clang-tidy] Enhance redundant-expression check
Summary: This patch is adding support to recognize more complex redundant expressions.

Reviewers: alexfh

Subscribers: aaron.ballman, cfe-commits, chrisha

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

llvm-svn: 274731
2016-07-07 04:03:05 +00:00
Felix Berger 17934da767 [clang-tidy] UnnecessaryValueParamCheck - only warn for virtual methods
Summary:

As changing virtual methods could break method overrides disable applying the fix and just warn.

Reviewers: alexfh, sbenza

Subscribers: cfe-commits

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

llvm-svn: 274552
2016-07-05 14:40:44 +00:00
Benjamin Kramer fdaed4c411 [clang-include-fixer] fix PEP8 warnings
This fixes PEP8 E231, E225, E226, E302 warnings.

Patch by Kirill Bobyrev!

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

llvm-svn: 274511
2016-07-04 16:47:17 +00:00
Eric Liu bb11252113 [include-fixer] reduce stack size by changing RegexHeaderMap to use const char * pair.
llvm-svn: 274501
2016-07-04 13:34:11 +00:00
Haojian Wu c1926075c3 [clang-tidy] Fix more enum declaration cases in misc-unused-using-decls check.
Summary: Fix PR28350.

Reviewers: alexfh

Subscribers: aaron.ballman, Eugene.Zelenko, cfe-commits

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

llvm-svn: 274496
2016-07-04 12:01:56 +00:00
Eric Liu c97b9bda76 Fix broken build caused by r274494.
llvm-svn: 274495
2016-07-04 11:42:37 +00:00
Eric Liu f33bc95f8f [include-fixer] make HeaderMapCollector maps from regex instead of postfix.
Summary:
this enables us to map a group of headers to one header name,
e.g. headers from one directory can be mapped to the same header.

Reviewers: bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 274494
2016-07-04 11:22:35 +00:00
Felix Berger 7f8827576c [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
Summary:

Make check more useful in the following two cases:

The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor.
The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator.
In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended.

Reviewers: alexfh, sbenza

Subscribers: cfe-commits, Prazek

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

llvm-svn: 274380
2016-07-01 20:12:15 +00:00
Samuel Benzaquen 25cd6139e3 [clang-tidy] Do not match on lambdas.
We match on the generated FunctionDecl of the lambda and try to fix it.
This causes a crash.
The right behavior is to ignore lambdas, because they are a definition.

llvm-svn: 274019
2016-06-28 14:19:41 +00:00
Piotr Padlewski b0869a7522 [clang-tidy] boost-use-to-string arg expr location bugfix
Summary: getExprLoc returns location after dot for member call.

Reviewers: alexfh, sbenza, hokein

Subscribers: cfe-commits

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

llvm-svn: 274001
2016-06-28 08:16:20 +00:00
NAKAMURA Takumi 79027efe76 clang-rename: Update libdeps corresponding to r273910.
llvm-svn: 273993
2016-06-28 06:08:10 +00:00
Miklos Vajna 44de0ad6a8 clang-rename: try to make ClassTestReplacements more reliable
As it failed on e.g.
<http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/7089/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Tools%3A%3AClassTestReplacements.cpp> with:

Trouble iterating over directory '/home/buildbots/ppc64be-clang-test/clang-ppc64be/stage1/tools/clang/tools/extra/test/clang-rename/Output': No such file or directory

A reliable way to trigger the problem locally is to run all clang-rename
tests in parallel in a loop:

for i in $(seq 1 100); do ~/git/llvm/workdir/bin/llvm-lit -v -j15 . || break; done

Change the test script to be more similar to test/Tooling/clang-check.cpp, that
way the above command doesn't fail for me anymore.

llvm-svn: 273941
2016-06-27 21:04:53 +00:00
Miklos Vajna a2ca3eda5d clang-rename: add a -export-fixes option
Use case: a class is declared in a header, and defined in two
translation units. clang-rename is asked to rename a class member that's
referenced in both translation units.

Using -i is not possible, as in case the first clang-rename invocation
touches the header, the second invocation will result in compilation
errors. Using -export-fixes handles this situation, each invocation can
work on the original source, and at the end the user can apply the
replacements with clang-apply-replacements.

Reviewers: klimek

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

llvm-svn: 273910
2016-06-27 19:34:47 +00:00
Haojian Wu eb646e0d9b [clang-tidy] Warning enum unused using declarations.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 273882
2016-06-27 14:47:39 +00:00
Haojian Wu e5d277923a [clang-tidy] Don't run misc-definitions-in-headers check in failing TUs.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 273849
2016-06-27 08:04:01 +00:00
NAKAMURA Takumi 819f3b95ae clang-tools-extra/test/clang-tidy/modernize-use-using.cpp: Satisfy thiscall.
llvm-svn: 273834
2016-06-26 23:56:07 +00:00
Krystyna Gajczyk c37933a12a [clang-tidy] Add modernize-use-using
http://reviews.llvm.org/D18919

llvm-svn: 273786
2016-06-25 18:37:53 +00:00
Cong Liu 998fb5c28b Remove ignoringImplicit from clang-tidy.
llvm-svn: 273660
2016-06-24 09:39:28 +00:00
Miklos Vajna b70539c317 Fix build of ClangRenameTests
Adapt the test to the code change introduced in r273304.

llvm-svn: 273314
2016-06-21 20:30:40 +00:00
Tim Shen 325c727480 Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
Summary: This is a fix for the new ExprWithCleanups introduced by clang's temporary variable lifetime marks change.

Reviewers: bkramer, sbenza, angelgarcia, alexth

Subscribers: rsmith, cfe-commits

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

llvm-svn: 273310
2016-06-21 20:11:20 +00:00
Miklos Vajna 47bd46395a clang-rename: add a -old-name option
This is similar to -offset with the following differences:

1) -offset can refer to local variables as well.

2) -old-name makes it easier to refer to e.g. ClassName::MemberName by
spelling out the fully qualified name, instead of having to use e.g.
grep to look up the exact offset.

In other words, -offset is great when clang-rename is invoked by e.g. an
IDE, but not really user-friendly when the tool is invoked by the user
from commandline.  That's the use case where -old-name is supposed to
improve the situation.

Reviewers: klimek

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

llvm-svn: 273304
2016-06-21 19:48:57 +00:00
Eric Liu de027f2791 [clang-apply-replacements] use Range::operator==() instead of self-defined operator.
llvm-svn: 273291
2016-06-21 17:59:57 +00:00
Piotr Padlewski 552d449482 [clang-tidy] Add modernize-use-emplace
Summary: Add check that replaces call of push_back to emplace_back

Reviewers: hokein

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

llvm-svn: 273275
2016-06-21 15:23:27 +00:00
Alexander Kornienko c732c61b6d [clang-tidy] More doc fixes. NFC.
llvm-svn: 272995
2016-06-17 12:01:15 +00:00
Alexander Kornienko c9c8290251 [clang-tidy] Fix doxygen errors. NFC.
llvm-svn: 272994
2016-06-17 11:43:33 +00:00
Alexander Kornienko 2150390a2a [clang-tidy] readability-identifier-naming - Support for Macros
Summary:
Added support for macro definitions.
--

1. Added a pre-processor callback to catch macro definitions
2. Changed the type of the failure map so that macros and declarations can share the same map
3. Added extra tests to ensure fix-ups work using the new map
4. Added fix-ups for type aliases in variable and function declarations as part of adding the new tests

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Patch by James Reynolds!

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

llvm-svn: 272993
2016-06-17 09:25:24 +00:00
Alexander Kornienko b0f613bfc8 [clang-tidy] misc-move-const-arg: Fix typos
Reviewers: alexfh

Subscribers: cfe-commits

Patch by Martin Boehme!

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

llvm-svn: 272897
2016-06-16 14:32:54 +00:00
Alexander Kornienko 28b34b043e [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument
Summary:
Conceptually, this is very close to the existing functionality of misc-move-const-arg, which is why I'm adding it here and not creating a new check. For example, for a type A that is both movable and copyable, this

  const A a1;
  A a2(std::move(a1));

is not only a case where a const argument is being passed to std::move(), but the result of std::move() is also being passed as a const reference (due to overload resolution).

The new check typically triggers (exclusively) in cases where people think they're dealing with a movable type, but in fact the type is not movable.

Reviewers: hokein, aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

Patch by Martin Boehme!

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

llvm-svn: 272896
2016-06-16 14:32:41 +00:00
Artem Belevich 0ccbe69d18 [clang-tools] mark TokenName as unused
Otherwise it produces compiler warning if asserts are disabled.

llvm-svn: 272852
2016-06-15 23:04:42 +00:00
Miklos Vajna 7712bf3f53 clang-rename: implement renaming of classes with a dtor
The declaration wasn't renamed. Also neither part of the declaration
wasn't renamed.

Reviewers: klimek

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

llvm-svn: 272816
2016-06-15 18:35:41 +00:00
Benjamin Kramer 6f90dcc609 [clang-tidy] Remove dead code. NFC.
llvm-svn: 272803
2016-06-15 16:51:04 +00:00
Benjamin Kramer 51a9cc9ce7 Apply performance-unnecessary-value-param to clang-tidy.
With minor manual tweaks. No functionality change intended.

llvm-svn: 272795
2016-06-15 15:46:10 +00:00
Haojian Wu d58dc298ef [include-fixer] Correct two wrong header mappings.
Reviewers: bkramer

Subscribers: ioeric, cfe-commits

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

llvm-svn: 272773
2016-06-15 11:15:12 +00:00
Eric Liu f9c111bd07 [include-fixer] remove redundant code.
llvm-svn: 272657
2016-06-14 12:14:36 +00:00
Eric Liu a4be83a302 [include-fixer] only deduplicate symbols after matching symbols with the undefined identifier.
Summary:
we should only deduplicate symbols after matching symbols with the
undefined identifier. This patch tries to fix the situation where matching
symbols are deleted when it has the same header as a non-matching symbol, which
can prevent finding the correct header even if there is a matched symbol.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 272576
2016-06-13 19:05:07 +00:00
Miklos Vajna 6ff8f25a51 clang-rename: implement handling of remaining named casts
const_cast<> and reinterpret_cast<>.

Reviewers: klimek

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

llvm-svn: 272574
2016-06-13 18:50:45 +00:00
Eric Liu f4a5710a80 [include-fixer] give users an option to show N more headers in case there are too many candidates.
Summary: give users an option to show N more headers in case there are too many candidates.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 272387
2016-06-10 12:09:33 +00:00
Miklos Vajna e9c756512b clang-rename: fix the DynamicCastExpr test on ps4
It has RTTI disabled by default, so need to enable it explicitly.

Reviewers: silvas

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

llvm-svn: 272381
2016-06-10 08:29:02 +00:00
Eric Liu 1899d54ed0 [include-fixer] do not index friend function declaration.
Summary:
we want to exclude friend declaration, but the `DeclContext` of a
friend function declaration is not the class in which it is declared, so we need
to explicitly check if the parent is a `friendDecl`.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 272261
2016-06-09 14:18:40 +00:00
Richard Smith 22252f9847 Update to match LLVM r272232.
llvm-svn: 272235
2016-06-09 00:54:42 +00:00
Miklos Vajna 85b7b1c06a clang-rename: implement renaming of classes inside dynamic_cast
Refactor to do the same as what is done already for static_cast.

Reviewers: klimek

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

llvm-svn: 272188
2016-06-08 18:38:23 +00:00
Alexander Kornienko 3971dbac57 [clang-tidy] misc-argument-comment: don't bail out when an argument is a macro expansion (e.g. NULL).
Add CHECK-FIX tests.

llvm-svn: 272155
2016-06-08 15:27:46 +00:00
Haojian Wu 13d3048ced [include-fixer] Keep dot dot in SymbolInfo file paths.
Summary:
Currently, removing dot dot in header's path doesn't make include-fixer
minimize path correctly in some cases, for example, specify a relative search
path based on the build directory("-I../include/").

Besides, removing dot dot can break symbolic link directories. So don't
removing it for now.

Reviewers: ioeric, bkramer

Subscribers: cfe-commits

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

llvm-svn: 272152
2016-06-08 15:10:18 +00:00
Eric Liu 81689dab6c [include-fixer] explicitly set minimize-paths in test.
llvm-svn: 272151
2016-06-08 14:57:43 +00:00
Alexander Kornienko fb90b51e63 [clang-tidy] correct clang-tidy-diff.py help message
Summary:
Looks like the original code was copied from clang-format-diff.py.
Update help message to make it clang-tidy specific.

Reviewers: klimek, alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Patch by Igor Sugak!

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

llvm-svn: 272144
2016-06-08 14:27:43 +00:00
Eric Liu 072ccfc997 [include-fixer] do not add enum forward declaration into symbol index table.
llvm-svn: 272132
2016-06-08 12:13:14 +00:00
Daniel Marjamaki 8ba0233e46 [clang-tidy] misc-macro-parentheses - avoid adding parentheses in variable declarations
Fixes bugzilla issues 26273 and 27399

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 272128
2016-06-08 10:30:24 +00:00
Eugene Zelenko 930e031d64 [Clang-tidy] Alphabetical checks order in release notes.
Highlight return statement in misc-unconventional-assign-operator documentation.

llvm-svn: 272042
2016-06-07 18:38:42 +00:00
Eugene Zelenko 04c14db108 [Clang-tidy] Documentation style consistency.
llvm-svn: 272038
2016-06-07 18:29:15 +00:00
Aaron Ballman 4c4bdba28a Fixing a build bot issue with duplicate explicit instantiations.
llvm-svn: 272027
2016-06-07 17:32:07 +00:00
Aaron Ballman d96ce2a94c Adding a release note for the misc-misplaced-const check added in r272025.
llvm-svn: 272026
2016-06-07 17:29:49 +00:00
Aaron Ballman cf6cefd88a Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type.
llvm-svn: 272025
2016-06-07 17:22:47 +00:00
Eric Liu f832eb7e9f [include-fixer] try to make vim header selection more friendly.
Summary: use 'input()' to get user's input so that we can support more options.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 272004
2016-06-07 12:21:43 +00:00
Alexander Kornienko 5ae76e09ad [clang-tidy] readability-identifier-naming - Support for Type Aliases
Summary: Added support for Type Alias declarations.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by James Reynolds!

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

llvm-svn: 271992
2016-06-07 09:11:19 +00:00
Haojian Wu ba992cf3de [clang-tidy] Ignore the deleted function in misc-definitions-in-headers.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271991
2016-06-07 08:55:38 +00:00
Haojian Wu e64cee81bf [include-fixer] Mention more details in the document.
Reviewers: bkramer

Subscribers: Eugene.Zelenko, cfe-commits, ioeric

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

llvm-svn: 271989
2016-06-07 07:50:48 +00:00
Miklos Vajna b54a26d19d clang-rename: implement renaming of classes inside static_cast
"Derived" in static_cast<Derived&>(...) wasn't renamed, nor in its
pointer equivalent.

Reviewers: klimek

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

llvm-svn: 271933
2016-06-06 19:40:12 +00:00
Samuel Benzaquen 79c76101ce [clang-tidy] Do not try to suggest a fix if the parameter is partially in a macro.
It is not easy to tell where to do the suggestion and whether the
suggestion will be correct.

llvm-svn: 271896
2016-06-06 14:21:11 +00:00
Alexander Kornienko c0308c451b [clang-tidy] modernize-use-auto: don't remove stars by default
Summary:
By default, modernize-use-auto check will retain stars when replacing an explicit type with `auto`: `MyType *t = new MyType;` will be changed to `auto *t = new MyType;`, thus resulting in more consistency with the recommendations to use `auto *` for iterating over pointers in range-based for loops: http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto

The new  `RemoveStars` option allows to revert to the old behavior: with the new option turned on the check will change `MyType *t = new MyType;` to `auto t = new MyType;`.

Reviewers: aaron.ballman, sbenza

Subscribers: Eugene.Zelenko, cfe-commits

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

llvm-svn: 271739
2016-06-03 21:22:58 +00:00
Benjamin Kramer b53452b2b1 [include-fixer] Be smarter about inserting symbols for a prefix.
If prefix search finds something where nothing can be nested under (e.g.
a variable or macro) don't add it to the result.

This is for cases like:
header.h:
  extern int a;

file.cc:
namespace a {
  SOME_MACRO
}

We will look up a::SOME_MACRO, which doesn't have any results. Then we
look up 'a' and find something before we ever look up just 'SOME_MACRO'.
With some basic filtering we can avoid this case.

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

llvm-svn: 271671
2016-06-03 14:07:38 +00:00
Haojian Wu 9c6cb035f3 [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.
Summary:
The further solution is to add the missing header to the file where the
symbol comes from.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271660
2016-06-03 11:26:02 +00:00
Eric Liu 5bc39ab592 [include-fixer] fixed a wrong header mapping.
llvm-svn: 271638
2016-06-03 09:33:22 +00:00
Eric Liu 1ebb7cf052 [include-fixer] added GNU symbols hardcoded header mapping.
Summary: [include-fixer] added GNU symbols hardcoded header mapping.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 271637
2016-06-03 09:25:03 +00:00
Haojian Wu d80c7c4808 [clang-tidy] Ignore function context in misc-unused-using-decls.
Summary: Make the check's behavior more correct when handling using-decls in multiple scopes.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271632
2016-06-03 08:05:11 +00:00
Miklos Vajna 617409f0c0 clang-rename: fix renaming heap allocations
The check failed, 'Cla *C = new Cla();' was renamed to 'D *C = new Cla();'.

Reviewers: klimek

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

llvm-svn: 271572
2016-06-02 20:00:22 +00:00
Samuel Benzaquen aa05ae91fb Fix uninitialized memory access when the token 'const' is not present in
the program.

If the token is not there, we still warn but we don't try to give a
fixit hint.

llvm-svn: 271426
2016-06-01 20:37:23 +00:00
Eric Liu 140b1fba91 [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.
Summary: added PathConfig.cpp and use includer of .inc header to be the file path of a symbol from .inc header.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271385
2016-06-01 12:01:06 +00:00
Haojian Wu 17a54e3618 [include-fixer] Use YAML format in -output-headers and -insert-header mode.
Summary:
And some improvements:
* Show better error messages on unfound symbols.
* Fix a typo.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271382
2016-06-01 11:43:10 +00:00
Eric Liu 74ccbd61af [include-fixer] disable path cleaning test for windows and mingw.
llvm-svn: 271321
2016-05-31 19:22:01 +00:00
Eric Liu 65cb39eb12 [find-all-symbols] remove dots in SymbolInfo file paths.
Summary: remove dots in SymbolInfo file paths.

Reviewers: bkramer, klimek

Subscribers: cfe-commits

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

llvm-svn: 271302
2016-05-31 17:37:38 +00:00
NAKAMURA Takumi e18fc2130d IncludeFixerTests: Update libdeps.
llvm-svn: 271295
2016-05-31 16:41:39 +00:00
Eric Liu 78985da8cc [include-fixer] removed unused forward declaration.
llvm-svn: 271294
2016-05-31 16:03:09 +00:00
Piotr Padlewski e93a73fb7a [ASTMatchers] Added ignoringParenImpCasts to has matchers
has matcher changed behaviour, and now it matches "as is" and
doesn't skip implicit and paren casts

http://reviews.llvm.org/D20801

llvm-svn: 271289
2016-05-31 15:26:56 +00:00
Eric Liu 516f18e515 [include-fixer] use clang-format cleaner to insert header.
Summary: clang-format's cleanupAroundReplacements() takes care of header insertions.

Reviewers: bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 271287
2016-05-31 14:48:45 +00:00
Benjamin Kramer a3f3a7bdd8 [include-fixer] Inline trivial methods.
Putting them into the .cpp file is both more verbose and slower than
having them in the header. No functional change intended.

llvm-svn: 271285
2016-05-31 14:40:10 +00:00
Benjamin Kramer 99985b864b [include-fixer] Use a DenseMap, order doesn't matter here.
llvm-svn: 271284
2016-05-31 14:37:10 +00:00
Benjamin Kramer 658d28014b [include-fixer] Rank symbols based on the number of occurrences we found while merging.
This sorts based on the popularity of the header, not the symbol. If
there are mutliple matching symbols in one header we take the maximum
popularity for that header and deduplicate. If we know nothing we sort
lexicographically based on the header path.

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

llvm-svn: 271283
2016-05-31 14:33:28 +00:00
Eric Liu f83187deb9 [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
Summary: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.

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

llvm-svn: 271279
2016-05-31 13:52:59 +00:00
Haojian Wu eb6ce0643d [include-fixer] Code cleanup.
Summary:
* Abstract the DB setting code to a function.
* Remove the unused FallbackStyle.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271273
2016-05-31 13:23:00 +00:00
Benjamin Kramer 03016b85b6 [find-all-symbols] Add a test to make sure merging actually works.
llvm-svn: 271270
2016-05-31 12:12:19 +00:00
Eric Liu c893070ff1 [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
Summary:
[include-fixer] collect the number of times a symbols is found in an
indexing run and use it for symbols popularity ranking.

Reviewers: bkramer

Subscribers: cfe-commits, hokein, djasper

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

llvm-svn: 271268
2016-05-31 12:01:48 +00:00
Benjamin Kramer 8f961aab25 Make the vim integration output a bit prettier and drop the -debug flag.
llvm-svn: 271266
2016-05-31 11:28:34 +00:00
Haojian Wu e3801b0023 [include-fixer] Add missing dependency.
llvm-svn: 271261
2016-05-31 10:06:12 +00:00
Haojian Wu 11e9bd2450 [include-fixer] Create a mode in vim integration to show multiple potential headers.
Summary:
Some changes in the patch:

* Add two commandline flags in clang-include-fixer.
* Introduce a IncludeFixerContext for the queried symbol.
* Pull out CreateReplacementsForHeader.

Reviewers: bkramer

Subscribers: klimek, cfe-commits, ioeric

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

llvm-svn: 271258
2016-05-31 09:31:51 +00:00
Felix Berger 98e4019a58 [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified.
Summary:

Also trigger the check in the following case:

void foo() {
  ExpensiveToCopy Obj;
  const auto UnnecessaryCopy = Obj.constReference();
  Obj.onlyUsedAsConst();
}

i.e. when the object the method is called on is not const but is never
modified.

Reviewers: alexfh, fowles

Subscribers: cfe-commits

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

llvm-svn: 271239
2016-05-31 00:25:57 +00:00
Etienne Bergeron 6885229cb8 [clang-tidy] Remove redundant quote in add_new_check script
Summary:
Remove redundant quote.
These quotes were added here: http://reviews.llvm.org/D20766

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271210
2016-05-30 15:42:08 +00:00
Etienne Bergeron 1c51a2d1d4 [clang-tidy] Fix script adding new clang-tidy check
Summary:
The `getName()` call is useless. It's better to show a better example
as tutorial.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271207
2016-05-30 15:05:10 +00:00
Haojian Wu 3b9f4cf462 Fix a wrong check in misc-unused-using-decls
Summary:
We should check whether a UsingDecl is defined in macros or in class
definition, not TargetDecls of the UsingDecl.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271199
2016-05-30 07:42:22 +00:00
Benjamin Kramer bc90075629 [include-fixer] Add a missing .h.
llvm-svn: 270989
2016-05-27 12:49:58 +00:00
NAKAMURA Takumi 201c955fbc clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp: Tweak for r270775.
llvm-svn: 270841
2016-05-26 11:20:54 +00:00
Samuel Benzaquen 7663d3be15 Speed up check by using a recursive visitor.
Summary:
Use a recursive visitor instead of forEachDescendant() matcher.
The latter requires several layers of virtual function calls for each node and
it is more expensive than the visitor.
Benchmark results show improvement of ~6% walltime in clang-tidy.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 270714
2016-05-25 16:19:23 +00:00
Eric Liu fff1335fce [include-fixer] /usr/include/xlocal.h to include/xlocal.h in hardcoded map.
llvm-svn: 270703
2016-05-25 14:17:09 +00:00
Benjamin Kramer 0e871f0b66 Include local header with quotes instead of angle brackets.
This works by accident because we pass '-I.'

llvm-svn: 270701
2016-05-25 14:14:52 +00:00
Haojian Wu 218febb8eb [include-fixer] Simplify the code since we won't handle multiple includes at once.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 270700
2016-05-25 14:06:12 +00:00
Eric Liu 748308ad35 [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.
Summary: [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 270696
2016-05-25 13:53:33 +00:00
Benjamin Kramer c85e14e0d6 [clang-tidy] Fix typo in test file name.
polo

llvm-svn: 270682
2016-05-25 09:44:35 +00:00
Miklos Vajna 10e25748b0 clang-rename: fix renaming non-members variables when referenced as macro arguments
The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).

Reviewers: klimek

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

llvm-svn: 270599
2016-05-24 19:08:53 +00:00
Benjamin Kramer e78ace55df [clang-tidy] Don't rely on <array> being available.
The STL isn't necessarily around when running tests. Make our own fake
std::array to test this.

llvm-svn: 270581
2016-05-24 16:54:26 +00:00
Eric Liu 54b68779b2 [include-fixer][find-all-symbols] added missing dependencies.
llvm-svn: 270578
2016-05-24 16:35:24 +00:00
Mads Ravn ef88dc8fe4 [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
Adding to revision 270567. The lit-style test was wrong. This is being fixed by this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270575
2016-05-24 16:09:24 +00:00
Eric Liu 0a28e680f7 [include-fixer][find-all-symbols] removed unused const member from YamlReporter to fix build bot failure.
llvm-svn: 270571
2016-05-24 15:34:37 +00:00
Mads Ravn 28cc243930 [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
Adding to revision 270565. The lit-style test was wrong. This is being fixed by this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270567
2016-05-24 15:13:44 +00:00
Eric Liu a7d19414da [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.
Summary: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 270566
2016-05-24 15:10:58 +00:00
Mads Ravn 7175c2ce4d [clang-tidy] modernize-pass-by-value bugfix
Modified the clang-tidy PassByValue check. It now stops adding std::move to type which is trivially copyable because that caused the clang-tidy MoveConstArg to complain and revert, thus creating a cycle.

I have also added a lit-style test to verify the bugfix.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270565
2016-05-24 15:00:16 +00:00
Mads Ravn 86d5f8ad4c Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270473
2016-05-23 18:27:05 +00:00
Mads Ravn dfa3b3d3ee Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270472
2016-05-23 18:15:40 +00:00
Mads Ravn d01743a3f7 Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270470
2016-05-23 18:06:29 +00:00
Alexander Kornienko 1c6d827015 Fix docs
llvm-svn: 270288
2016-05-20 22:42:03 +00:00
Alexander Kornienko 5d08bb72d9 [clang-tidy] Switch to a more common way of customizing check behavior.
This should have been done this way from the start, however I somehow missed
r257177.

llvm-svn: 270215
2016-05-20 13:42:40 +00:00
Haojian Wu cc0c10e300 [find-all-symbols] Some cleanups in unittest.
llvm-svn: 270211
2016-05-20 12:47:56 +00:00
Haojian Wu a23ac3d249 [find-all-symbol] Ignore inline namespace context.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270206
2016-05-20 12:04:56 +00:00
Miklos Vajna ed28d41b1a clang-rename: fix renaming members when referenced as macro arguments
The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y).

Reviewers: klimek

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

llvm-svn: 270204
2016-05-20 11:43:59 +00:00
Eric Liu 6c9472c57f [find-all-symbols] fix failing unittest for Windows build bot.
llvm-svn: 270202
2016-05-20 11:14:36 +00:00
Haojian Wu 20dec208e9 [find-all-symbol] Try to fix the failure windows unittest.
llvm-svn: 270199
2016-05-20 10:36:53 +00:00
Haojian Wu 17baf85e41 [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 270197
2016-05-20 09:38:25 +00:00
Eric Liu 81554e7257 [find-all-symbols] fixed FindAllMacros compilation error.
llvm-svn: 270196
2016-05-20 09:23:19 +00:00
Eric Liu 83a4d7fbba [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and FindAllMacros.
llvm-svn: 270193
2016-05-20 09:12:01 +00:00
Haojian Wu 1cea6e5531 [clang-tidy] Handle using-decls with more than one shadow decl.
Reviewers: alexfh

Subscribers: cfe-commits, djasper

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

llvm-svn: 270191
2016-05-20 08:34:32 +00:00
Haojian Wu 5e4f0255a1 [find-all-symbol] Add macro support.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270189
2016-05-20 08:04:36 +00:00
Benjamin Kramer ee4e522c26 [include-fixer] Fix unused variable warning in Release builds.
llvm-svn: 270082
2016-05-19 16:57:57 +00:00
Haojian Wu 0de7226236 [include-fixer] Remove an unused local variable ExistingHeaders.
llvm-svn: 270059
2016-05-19 13:23:27 +00:00
Benjamin Kramer 9b15b6f2d7 [include-fixer] Make search handle fully qualified names correctly.
If a search string starts with "::" we don't want to return any results
for suffixes of that string.

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

llvm-svn: 270055
2016-05-19 12:41:56 +00:00
Benjamin Kramer 04666a2d5d [include-fixer] Remove obsolete windows hack.
llvm-svn: 270045
2016-05-19 11:39:56 +00:00
Alexander Kornienko a20bab46cd [clang-tidy] Fix/add style guide links.
Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)!

llvm-svn: 270033
2016-05-19 09:31:30 +00:00
Alexander Kornienko 77c8b2ed9f [clang-tidy] Fix doc titles.
llvm-svn: 270032
2016-05-19 09:29:46 +00:00
Eric Liu 702cfd1b2b [include-fixer] Sort headers after inserting new headers.
Summary: [include-fixer] Sort headers after inserting new headers.

Reviewers: bkramer

Subscribers: klimek, djasper, hokein, cfe-commits

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

llvm-svn: 270031
2016-05-19 08:21:09 +00:00
Benjamin Kramer 5e6b35f4d1 [include-fixer] Also look up prefixes of queries.
This is used to find nested classes. For a nested name foo::bar::qux we
will first look up foo::bar::qux, then foo::bar, then foo unless we find
a result. This is used to support nested classes which are not part of
the index but can only be used if the header for the parent context is
included.

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

llvm-svn: 269956
2016-05-18 16:42:38 +00:00
Miklos Vajna 5a6d2985d7 clang-rename: handle non-inline ctor definitions when renaming classes
The result of the test was C::D(), not D::D().

Reviewers: cfe-commits, klimek

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

llvm-svn: 269952
2016-05-18 16:12:48 +00:00
Haojian Wu 1bc05a681e [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269928
2016-05-18 14:11:20 +00:00
Eric Liu c7f3b108e2 [clang-include-fixer] Added Vim integration for clang-include-fixer.
Summary: [clang-include-fixer] Added Vim integration for clang-include-fixer.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 269927
2016-05-18 14:10:16 +00:00
Benjamin Kramer 6b5160a369 [include-fixer] Don't insert #includes if a fatal error occurred.
This typically happens when the user didn't setup include paths correctly
and the fixer starts adding garbage includes. Avoid that. Disable the error
limit though, as we might hit that easily with missing includes and still
want to fix those cases.

llvm-svn: 269923
2016-05-18 13:32:38 +00:00
Haojian Wu 4405d5b2cc [clang-tidy] Fix misc-unused-using-decls test failure in windows
buildbot.

llvm-svn: 269918
2016-05-18 13:07:13 +00:00
Haojian Wu 47ea5424d2 [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.
Summary: Ignore warning uninstantiated template function usages.

Reviewers: djasper, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269906
2016-05-18 11:49:34 +00:00
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
Benjamin Kramer 2ecd0902c7 [include-fixer] Run tests with -fno-ms-compatibility.
Something behind that flag makes us get fewer typo correction callbacks,
unbreak the tests on windows for now.

llvm-svn: 269894
2016-05-18 09:28:45 +00:00
Haojian Wu ff6d195c2d [include-fixer] Ignore non-scoped enum declaration during search.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269890
2016-05-18 09:04:43 +00:00
NAKAMURA Takumi e1f0ed0a1f findAllSymbols: Prune unused libdeps.
llvm-svn: 269875
2016-05-18 00:53:31 +00:00
NAKAMURA Takumi ea46e8b674 FindAllSymbolsTests doesn't require clangToolingCore.
llvm-svn: 269874
2016-05-18 00:53:27 +00:00
NAKAMURA Takumi 37c64ee4ec include-fixer: They require clangLex.
llvm-svn: 269873
2016-05-18 00:49:16 +00:00
NAKAMURA Takumi 62e8ec5721 IncludeFixerTest.cpp: Add explicit triple for some tests. They are failing for targeting *-win32.
llvm-svn: 269870
2016-05-18 00:20: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
Miklos Vajna a7445f1b5e clang-rename: avoid StringRef members in USRLocFindingASTVisitor
Even if this is defined in the .cpp file and only used as part of the
function (so here it's safe), usually storing StringRefs in the class is
dangerous, so don't do so.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269796
2016-05-17 18:17:16 +00:00
Vedant Kumar 5119923cdd [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)
If a use of a macro argument is preceded by the `namespace` keyword, do
not warn that the use should be wrapped in parentheses.

Patch by Mads Ravn!

llvm-svn: 269786
2016-05-17 17:26:02 +00:00
Haojian Wu 2a6d78b820 [find-all-symbols] Add IWYU private pragma support.
Reviewers: djasper, klimek

Subscribers: kimgr, cfe-commits, bkramer, ioeric

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

llvm-svn: 269779
2016-05-17 16:48:49 +00:00
Haojian Wu 39170d70c0 [find-all-symbols] Ignore anonymous enum declarations.
llvm-svn: 269762
2016-05-17 13:38:18 +00:00
Benjamin Kramer af34e06c69 [include-fixer] Make the "extend to the right" hack support typos without nested names in the front.
This handles cases where the initial namespace is unknown.

llvm-svn: 269758
2016-05-17 12:35:18 +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
Eugene Zelenko 804e58d62e [Release notes] Mention Clang-tidy modernize-avoid-bind check.
Fix some problems in its documentation.

llvm-svn: 269517
2016-05-13 23:35:56 +00:00
Etienne Bergeron 8db5174395 [include-fixer] Fix broken dependency shared build
Summary:
The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o: In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o: In function `clang::include_fixer::(anonymous namespace)::runIncludeFixer(llvm::StringRef, std::vector<std::string, std::allocator<std::string> > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
```

Reviewers: bkramer, hokein

Subscribers: cfe-commits

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

llvm-svn: 269441
2016-05-13 17:38:22 +00:00
Haojian Wu 57cdcb07d6 [include-fixer] Use scope contexts information to improve query.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269430
2016-05-13 15:44:16 +00:00
Etienne Bergeron a4bc53afba [clang-rename] Fix broken dependency on shared build.
Summary:
The build is broken due to a missing dependency.

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Which produce this error:
```
tools/clang/tools/extra/clang-rename/CMakeFiles/clangRename.dir/USRLocFinder.cpp.o: In function `clang::RecursiveASTVisitor<clang::rename::(anonymous namespace)::USRLocFindingASTVisitor>::TraverseCXXConstructorDecl(clang::CXXConstructorDecl*)':
USRLocFinder.cpp:(.text._ZN5clang19RecursiveASTVisitorINS_6rename12_GLOBAL__N_123USRLocFindingASTVisitorEE26TraverseCXXConstructorDeclEPNS_18CXXConstructorDeclE+0x170): undefined reference to `clang::Lexer::getSourceText(clang::CharSourceRange, clang::SourceManager const&, clang::LangOptions const&, bool*)'
```

Reviewers: alexfh, yaron.keren

Subscribers: yaron.keren, cfe-commits

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

llvm-svn: 269429
2016-05-13 15:38:54 +00:00
Haojian Wu 631e5f23f9 [include-fixer] Simplify unittest code.
Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269427
2016-05-13 15:17:17 +00:00
Haojian Wu db98f1d9c9 [find-all-symbols] Add EnumDecl type in YAML traits.
llvm-svn: 269422
2016-05-13 14:53:10 +00:00
Benjamin Kramer a3d823336a [include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.

llvm-svn: 269403
2016-05-13 09:27:54 +00:00
Miklos Vajna 1d48e50159 clang-rename: check that the source location we find actually has the old name
This more general check could have prevented the specific problem
"getSourceOrder() == -1" guards.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269402
2016-05-13 09:17:32 +00:00
Haojian Wu 22014750b4 [find-all-symbols] Add enum type support.
Summary:
Also change enums defined in SymbolInfo to scoped enums to avoid
conflicts.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269401
2016-05-13 09:15:37 +00:00
Felix Berger 6d3d746ff5 [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.
Summary: This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269389
2016-05-13 02:47:56 +00:00
Jonathan Coe a30c69c9e4 [clang-tidy] Adds modernize-avoid-bind check
Summary:
This patch adds a check that replaces std::bind with a lambda.

Not yet working for member functions.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269341
2016-05-12 20:06:04 +00:00
Haojian Wu 7a4d510ccb [clang-tidy] Ignore using-declarations defined in marcro in misc-unused-using-decls checks.
Reviewers: djasper

Subscribers: cfe-commits

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

llvm-svn: 269278
2016-05-12 10:00:49 +00:00
Etienne Bergeron c87599f480 [clang-tidy] Improve misc-redundant-expression and decrease false-positive
Summary:
This patch is adding support for conditional expression and overloaded operators.

To decrease false-positive, this patch is adding a list of banned macro names that
has multiple variant with same integer value.

Also fixed support for template instantiation and added an unittest.

Reviewers: alexfh

Subscribers: klimek, Sarcasm, cfe-commits

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

llvm-svn: 269275
2016-05-12 04:32:47 +00:00
Etienne Bergeron 4bf0e62d5a [clang-tidy] Add missing dependency of libtooling to misc module
Summary:
The new API for fixit is in libtooling and the library misc in clang-tidy
didn't had the appropriate dependency.

This commit was breaking some build bots:
http://reviews.llvm.org/D19547

This commit tried (but failed) to fix it:
http://reviews.llvm.org/D20180

To repro, you can make a build with these flags:
```
cmake -DBUILD_SHARED_LIBS=ON
```

Thanks rnk@ for helping figuring out.

Reviewers: alexfh, rnk

Subscribers: cfe-commits

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

llvm-svn: 269240
2016-05-11 21:32:29 +00:00
Eugene Zelenko 1592d76d73 [Clang-tidy] modernize-use-bool-literals: documentation style.
Fix readability-redundant-control-flow warnings in regression test.

llvm-svn: 269229
2016-05-11 20:31:50 +00:00
Etienne Bergeron 8311c446fc [clang-tidy] Refactoring of FixHintUtils
Summary:
Refactor some checkers to use the tooling re-writing API.
see: http://reviews.llvm.org/D19941

Reviewers: klimek, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269210
2016-05-11 17:38:22 +00:00
Etienne Bergeron e646a833ab [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.
Summary:
Arguments can be swapped using fixit when they are not in macros.
This is the same implementation than SwappedArguments. Some code 
got lifted to be reused.

Others checks are not safe to be fixed as they tend to be bugs or errors.
It is better to let the user manually review them.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269208
2016-05-11 17:32:12 +00:00
Benjamin Kramer 79acc976ea [include-fixer] Always ignore SFINAE contexts.
This could lead to spurious includes being added for identifiers that
are supposed to be not available.

llvm-svn: 269195
2016-05-11 15:33:30 +00:00
Benjamin Kramer 3246fba975 [include-fixer] Also output the location where we found an unknown identifier.
For debugging only, makes it a bit easier when there are queries coming
out of headers.

llvm-svn: 269194
2016-05-11 15:33:28 +00:00
Haojian Wu 2d07ed4530 [include-fixer] Add lit-test for relative include path.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269177
2016-05-11 12:30:45 +00:00
Haojian Wu 075ba119b2 [find-all-symbols] Save relative file path for each symbol.
Summary:
The HeaderSearch::suggestPathToFileForDiagnostics used in include-fixer
doesn't work well with absolute file path, it assumes a relative file
path based on header searching path.

So saving relative file path to make include-fixer get the most
appropriate header path.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269173
2016-05-11 11:50:08 +00:00
Jakub Staron f7df72694a [clang-tidy] Adds modernize-use-bool-literals check.
Review link: http://reviews.llvm.org/D18745

llvm-svn: 269171
2016-05-11 11:33:16 +00:00