Commit Graph

1730 Commits

Author SHA1 Message Date
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