Commit Graph

2068 Commits

Author SHA1 Message Date
Haojian Wu b15c8da089 [clang-move] Enable dump all declarations in old header.
Summary:
* Add -dump_dels option to dump all declarations from old header. It
  will allow clang-move used as a frontend to get declarations from
  header. Further more, this will make debugging stuff easier. Currently only
  class/function types are supported.
* Refactoring code a little bit by creating a ClangMoveContext which
  holds all options for ClangMoveTool, which can simplify the code in
  some degree.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287863
2016-11-24 10:17:17 +00:00
Benjamin Kramer 1eba23b308 [clang-rename] Add test case for r287758.
llvm-svn: 287759
2016-11-23 13:14:19 +00:00
Benjamin Kramer 66039d39e1 [clang-rename] Fix non-functional offset check.
Adding something to a SourceLocation will only produce an invalid
SourceLocation in edge cases (overflow or adding 0 to an invalid one).
Check that the offset is inside the file instead and add a test case to
verify that the error message works.

llvm-svn: 287758
2016-11-23 13:10:07 +00:00
Haojian Wu 48ac304c8e [clang-move] Add some options allowing to add old/new.h to new/old.h respectively.
Summary:
* --new_depend_on_old: new header will include old header
* --old_depend_on_new: old header will include new header.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287752
2016-11-23 10:04:19 +00:00
Benjamin Kramer b568d99dd7 [clang-rename] Prune away AST nodes more correctly and effectively when looking for a point
Due to the way the preprocessor works nodes can be half in a macro or a
different file. This means checking the file name of the start location
of a Decl is not a correct way of checking if the entire Decl is in that
file. Remove that flawed assumption and replace it with a more effective
check: If the point we're looking for is *inside* of the begin and end
location of a Decl, look inside.

This should make clang-rename more reliable (for example macro'd namespaces
threw it off before, as seen in the test case) and maybe a little faster
by pruning off more stuff that the RecursiveASTVisitor doesn't have to
drill into.

llvm-svn: 287649
2016-11-22 17:29:45 +00:00
Daniel Marjamaki 13e45e135f clang-tidy: improve my test for readability-redundant-declaration
llvm-svn: 287550
2016-11-21 16:08:17 +00:00
Daniel Marjamaki d752c44612 clang-tidy: Attempt to fix build bot failure with mismatching size_t platform type.
llvm-svn: 287546
2016-11-21 15:46:40 +00:00
Benjamin Kramer 87eb9667bf [include-fixer plugin] Make the plugin emit proper fixits in case multiple errors are found.
The standalone tool only fixes the first one and we managed to bake that
assumption into the code :(

Also fix a crash when no header is found at all.

llvm-svn: 287544
2016-11-21 15:28:50 +00:00
Daniel Marjamaki ae66045705 readability-redundant-declaration: Fix crash
Differential Revision: https://reviews.llvm.org/D26911

llvm-svn: 287540
2016-11-21 14:29:53 +00:00
Haojian Wu 50a45d9371 [clang-move] Fix not moving using-decls in global namespace in old.cc
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287330
2016-11-18 10:51:16 +00:00
Benjamin Kramer 99eaf84589 [include-fixer] Add a test for the full round trip through libclang and the plugin.
llvm-svn: 287230
2016-11-17 15:23:06 +00:00
Benjamin Kramer cd2494e93f [include-fixer] Refactor include fixer to be usable as a plugin
- Refactor the external sema source into a visible class
- Add support for emitting FixIts
- Wrap up include fixer as a plugin as I did with clang-tidy

Test case will follow as soon as I wire this up in libclang.

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

llvm-svn: 287228
2016-11-17 15:16:05 +00:00
Malcolm Parsons 5831a00634 [docs] Remove doubled spaces
Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 287226
2016-11-17 14:26:45 +00:00
Malcolm Parsons d549e3a23c [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check
Summary: Template instantiations were causing misplaced fixits.

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: hokein, cfe-commits

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

llvm-svn: 287221
2016-11-17 11:40:02 +00:00
Malcolm Parsons 5be5092c49 [clang-tidy] Changes to modernize-use-default check
Summary:
Warn about special member functions that only contain a comment.
Report the location of the special member function, unless it is
defined in a macro.  Reporting the location of the body in a macro is
more helpful as it causes the macro expansion location to be reported too.

Fixes PR30920.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287215
2016-11-17 09:14:04 +00:00
Eric Fiselier 732a3e0dd1 [clang-tidy] Fix identifier naming for initializer list member initializers.
Summary:
This patch adds handling for member initializers in a constructors initializer list. Previously we only handled base-class and delegating initializers, which are transformed by the `TypeLoc` matcher. For Example:

```
// Style options: All identifiers should start with an upper case letter.
struct base { ...  }; 
struct der :  base {
  int field;  // FIXES: int Field;
  der() : der(42) {} // FIXES: Der() : Der(42) {}
  der(int X) : base(), field(X) {} // FIXES: Der(int X) : Base(), field(X)
  // Note that `field` doesn't get replaced
};
```

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287153
2016-11-16 21:15:58 +00:00
Eric Liu ff51f011d1 [change-namespace] handle constructor initializer: Derived : Base::Base() {} and added conflict detections
Summary:
namespace nx { namespace ny { class Base { public: Base(i) {}} } }
namespace na {
namespace nb {
class X : public nx::ny {
public:
  X() : Base::Base(1) {}
};
}
}

When changing from na::nb to x::y, "Base::Base" will be changed to "nx::ny::Base" and
 "Base::" in "Base::Base" will be replaced with "nx::ny::Base" too, which causes
conflict. This conflict should've been detected when adding replacements but was hidden by `addOrMergeReplacement`. We now also detect conflict when adding replacements where conflict must not happen.

The namespace lookup is tricky here, we simply replace "Base::Base()" with "nx::ny::Base()" as a workaround, which compiles but not perfect.

Reviewers: hokein

Subscribers: bkramer, cfe-commits

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

llvm-svn: 287118
2016-11-16 16:54:53 +00:00
Gabor Horvath 678dd8fc62 [clang-tidy] New check to prefer transparent functors to non-transparent ones.
llvm-svn: 287107
2016-11-16 14:42:10 +00:00
Haojian Wu 4543feceb3 [clang-move] Support moving function.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287101
2016-11-16 13:05:19 +00:00
Malcolm Parsons 31055c6ace [clang-tidy] Handle template instantiations in modenize-use-default check
Summary:
Duplicate fixes were being created for explicit template instantiations
of out-of-line constructors or destructors.

Fixes PR30921.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287091
2016-11-16 09:51:40 +00:00
Malcolm Parsons 49fe4037a1 [clang-tidy] Change readability-redundant-member-init to get base type from constructor
Summary: Fixes PR30835

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: Prazek, cfe-commits

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

llvm-svn: 286990
2016-11-15 17:49:00 +00:00
Haojian Wu 53315a7b98 [clang-move] Make the output code look more pretty.
Summary:
Add decent blank lines between declarations:
* Add extra blank line after #define or #includes.
* Add extra blank line between declarations.
* Add extra blank line in front of #endif.

Previously, the new generated code is quite tight:

```
#ifndef FOO_H
#define FOO_H
namespace a {
class A { public: int f(); };
int A::f() { return 0; }
} // namespace a
#endif // FOO_H
```

After this patch, the code looks like:

```
#ifndef FOO_H
#define FOO_H

namespace a {
class A { public: int f(); };

int A::f() { return 0; }
} // namespace a

#endif // FOO_H
```

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286943
2016-11-15 09:06:59 +00:00
Eric Liu 3215886b7a [change-namespace] consider typedef/using alias decls in the moved namespace.
Summary: If a TypeLoc refers to a type alias defined in the moved namespace, we do not need to update its specifier since the type alias decl will be moved along with the type reference.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286873
2016-11-14 19:37:55 +00:00
Haojian Wu 2467539800 [clang-move] Fix an incorrect range for the functions whose returned value is a macro
Summary:
Fix an incorrect range for the functions whose returned value is a macro
(e.g. `bool`). This incorrect range can lead to modifications of an unexpected
file where the macro is in.

We should use expansion location instead of spelling location.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286833
2016-11-14 14:46:48 +00:00
Haojian Wu 35ca946760 [clang-move] Abstract a ClassMather for matching class declarations.
Summary:
No functionality change.

This is a refactoring patch, which makes the code more readable and easy
to extend it to support more types.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286825
2016-11-14 14:15:44 +00:00
Eric Liu 6aa9416d06 Handle adding new nested namespace in old namespace.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286486
2016-11-10 18:29:01 +00:00
Eric Liu 231c655851 [change-namespace] dyn_cast -> cast.
llvm-svn: 286485
2016-11-10 18:15:34 +00:00
Malcolm Parsons e293eab46f [clang-tidy] Add modernize-use-equals-delete check
Summary: Fixes PR27872

Reviewers: klimek, hokein, alexfh, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, danielmarjamaki, cfe-commits, mgorny

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

llvm-svn: 286472
2016-11-10 16:46:59 +00:00
Malcolm Parsons d784f20c13 [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC
llvm-svn: 286466
2016-11-10 16:19:17 +00:00
Simon Pilgrim 0e0f29c09f Fix -Wdocumentation warning
llvm-svn: 286449
2016-11-10 13:54:39 +00:00
Haojian Wu b53ec46773 [clang-move] Support template class.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286427
2016-11-10 05:33:26 +00:00
Felix Berger 85f9e8b316 [clang-tidy] Do not issue fix for functions that are referenced outside of callExpr
Summary: Suppress fixes for functions that are referenced within the
compilation unit outside of a call expression as the signature change
could break the code referencing the function.

We still issue a warning in this case so that users can decide to
manually change the function signature.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286424
2016-11-10 01:28:22 +00:00
Alexander Kornienko a6a52b2d63 [clang-tidy docs] Minor formatting changes.
llvm-svn: 286404
2016-11-09 22:31:07 +00:00
Alexander Kornienko 967f753e10 [clang-tidy docs] Recommend using add_new_check.py more
llvm-svn: 286390
2016-11-09 20:03:30 +00:00
Philipp Stephani 9934c54cca Fix grammar
"allow" requires a direct object in this case.

llvm-svn: 286381
2016-11-09 17:47:56 +00:00
Eric Liu b9bf1b5b85 [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
Summary:
when replacing symbol references in moved namespaces, trying to make the replace
name as short as possible by considering UsingDecl (i.e. UsingShadow) and
UsingDirectiveDecl (i.e. using namespace decl).

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286307
2016-11-08 22:44:17 +00:00
Haojian Wu 2930be1421 [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.
Summary: When moving all code to new.h/cc,  these code also will be formatted based on the given code style.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286281
2016-11-08 19:55:13 +00:00
Alexander Kornienko ed999fe0b2 Remove mentions of clang-analyzer-alpha
llvm-svn: 286257
2016-11-08 18:12:56 +00:00
Kirill Bobyrev b0cf6a3840 [clang-tidy] Improve rename_check.py.
-Start using argparse instead of mimicking CLI parsing.
-PEPify the code.
-Decrease the number of imports by slightly cleaning up the script.

Reviewers: alexfh

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

llvm-svn: 286228
2016-11-08 11:43:50 +00:00
Alexander Kornienko 7783ea6a61 [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them
llvm-svn: 286222
2016-11-08 08:28:19 +00:00
Mandeep Singh Grang 7c7ea7d0ae [clang-tools-extra] Format sources with clang-format. NFC.
Summary:
Ran clang-format on all .c/.cpp/.h files in clang-tools-extra.
Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories.

Reviewers: klimek, alexfh

Subscribers: nemanjai

Tags: #clang-tools-extra

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

llvm-svn: 286221
2016-11-08 07:50:19 +00:00
Alexander Kornienko 179e89f188 Use AnalyzerOptions::getRegisteredCheckers() instead of clang/StaticAnalyzer/Checkers/Checkers.inc
Summary: Depends on D26310.

Reviewers: zaks.anna, hokein

Subscribers: cfe-commits

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

llvm-svn: 286219
2016-11-08 07:43:42 +00:00
Alexander Kornienko 76e4315a0e [clang-tidy] Simplify matchers
llvm-svn: 286213
2016-11-08 05:58:07 +00:00
Haojian Wu 06e39a3aed [clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy-initialization.
Summary:

This will prevent the check warning the variables which have been
implicitly added by compiler, like the following case (in for-range loop):

  the variable '__end' is copy-constructed from a const reference...

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 286186
2016-11-08 00:45:34 +00:00
Haojian Wu a29ae6f2d7 [clang-tidy] Fix a regression issue introduced by r285239.
Summary:
r285239 changes the behavior of AST CXXDefaultArgExpr node.

Update `modernize-use-nullptr` to handle CXXDefaultArgExpr correctly.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 286156
2016-11-07 21:46:24 +00:00
Felix Berger 4a3f94c442 [clang-tidy] Move incomplete type test into separate test file
Summary: Move in complete type test which does not compile into its own test file.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286155
2016-11-07 21:45:58 +00:00
Felix Berger 7c6d289d66 [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified
Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286010
2016-11-04 20:51:31 +00:00
Felix Berger 3938033282 [clang-tidy] Ignore incomplete types when determining whether they are expensive to copy
Summary: IsExpensiveToCopy can return false positives for incomplete types, so ignore them.

All existing ClangTidy tests that depend on this function still pass as the types are complete.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286008
2016-11-04 20:29:22 +00:00
Malcolm Parsons c35be36962 [clang-tidy] Fixed readability-else-after-return for cascade statements
Summary:
Fix generated by this check changed program semantics
in the case where 'if' was a part (direct child) of other statement.

Fixes PR30652.

Patch by Paweł Żukowski.

Reviewers: malcolm.parsons, alexfh, djasper

Subscribers: mgehre, omtcyfz, cfe-commits

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

llvm-svn: 285999
2016-11-04 16:32:14 +00:00
Jonathan Coe 89f12c0c50 [clang-tidy] Ignore forward declarations without definitions in the same translation unit in readability-identifier-naming
Summary: This change ensures that forward declarations of classes are not considered for identifier naming checks within a translation unit.

Reviewers: alexfh, aaron.ballman

Subscribers: mgehre

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

llvm-svn: 285907
2016-11-03 13:52:09 +00:00