Commit Graph

72 Commits

Author SHA1 Message Date
Fangrui Song 95b45cb4fd [clang-move] Remove clang:: qualifier
Summary:
The use sites are enclosed by `namespace clang`, so clang:: is not
necessary. Many unqualified names have already been used, e.g. SourceManager SourceLocation LangOptions. This change makes the code terser and more consistent.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ioeric, cfe-commits

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

llvm-svn: 344256
2018-10-11 16:09:26 +00:00
Eric Liu 254b017905 [clang-move] Fix broken json output.
llvm-svn: 344055
2018-10-09 15:17:16 +00:00
Eric Liu bce181c64f [clang-move] Dump whether a declaration is templated.
llvm-svn: 343982
2018-10-08 17:22:50 +00:00
Argyrios Kyrtzidis 2b6ec65696 [clang-move] Explicitly ignore implicit UsingDirectiveDecls instead of depending on them missing source locations
This is adjustment to allow the logic to work even if implicit UsingDirectiveDecls get actual source locations.
There should be no functionality change.

llvm-svn: 341161
2018-08-31 03:51:33 +00:00
Stephen Kelly c09197e086 Port getLocEnd -> getEndLoc
Subscribers: nemanjai, ioeric, kbarton, cfe-commits

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

llvm-svn: 339401
2018-08-09 22:43:02 +00:00
Stephen Kelly 43465bf3fd Port getLocStart -> getBeginLoc
Reviewers: javed.absar

Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits

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

llvm-svn: 339400
2018-08-09 22:42:26 +00:00
Eric Liu fa63e9831e Replace hardcoded format styles in a few tools with the default style in libFormat.
llvm-svn: 338696
2018-08-02 10:30:56 +00:00
Zachary Turner 1f67a3cba9 [FileSystem] Split up the OpenFlags enumeration.
This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

llvm-svn: 334221
2018-06-07 19:58:58 +00:00
Eric Liu 07d4730ca4 Second attempt to fix clang-move tests broken by r332590 on windows
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12010

Add back a path conversion removed in a previous attempt. I removed it
because it didn't seem necessary. Added it back to see if this would fix
the bot.

llvm-svn: 332612
2018-05-17 14:59:15 +00:00
Eric Liu 5e721378eb Attempt to fix clang-move tests broken by r332590 on windows
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

llvm-svn: 332603
2018-05-17 12:40:50 +00:00
Eric Liu ad3fed62a9 [clang-move] Fix a potential bug where realpath doesn't work on VFS.
llvm-svn: 332518
2018-05-16 20:10:10 +00:00
Nicola Zaghen 0efd52487e [clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM

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

llvm-svn: 332371
2018-05-15 16:37:45 +00:00
Julie Hockett 546943f9f1 Reland "[tools] Updating PPCallbacks::InclusionDirective calls"
This commit relands r331905.

r331904 added SrcMgr::CharacteristicKind to the InclusionDirective
callback, this revision updates instances of it in clang-tools-extra.

llvm-svn: 332023
2018-05-10 19:13:14 +00:00
Julie Hockett 4a43843532 Revert "[tools] Updating PPCallbacks::InclusionDirective calls"
This reverts commit r331905, since it's dependent on reverted r331905.

llvm-svn: 331931
2018-05-09 22:25:43 +00:00
Julie Hockett 4e548fe06f [tools] Updating PPCallbacks::InclusionDirective calls
[revision] added SrcMgr::CharacteristicKind to the InclusionDirective
callback, this revision updates instances of it in clang-tools-extra.

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

llvm-svn: 331905
2018-05-09 18:27:37 +00:00
Richard Smith 4bb15ab853 Fix up after clang r331155.
llvm-svn: 331156
2018-04-30 05:26:07 +00:00
Roman Lebedev 12b40745ab Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"
This reverts commit rL326202

This broke gcc4.8 builds, compiler just segfaults:
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673

llvm-svn: 326203
2018-02-27 15:54:41 +00:00
Roman Lebedev 6b56a11961 [Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Summary:
I'm not sure whether there are any principal reasons why it returns raw owning pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is Clang-tools-extra part.
Clang part is D43779.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: ioeric, jkorous-apple, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 326202
2018-02-27 15:19:28 +00:00
Haojian Wu cee2059f9b [clang-move] Fix the incorrect expansion end location.
Summary:
Before the fix, if clang-move decides to move the following macro statement, it only moves the first line `DEFINE(A,`.

```
DEFINE(A,
       B);
```

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, cfe-commits

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

llvm-svn: 324886
2018-02-12 12:26:12 +00:00
Haojian Wu d478634777 [clang-move] Don't dump macro symbols.
Reviewers: ioeric

Subscribers: klimek, cfe-commits

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

llvm-svn: 324742
2018-02-09 15:57:30 +00:00
Haojian Wu fb68ca1825 [clang-move] Clever on handling header file which includes itself.
Summary:
Previously, we assume only old.cc includes "old.h", which would
introduce incorrect fixes for the cases where old.h also includes `#include "old.h"`

Although it should not be occurred in real projects, clang-move should handle this.

Old.h:

```
class Foo {};
```

after moving to a new old.h:

```
class Foo {};
```

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits, klimek

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

llvm-svn: 323865
2018-01-31 12:12:29 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Haojian Wu 03c8963c32 [clang-move] Find template class forward declarations more precisely.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 301914
2017-05-02 12:15:11 +00:00
Alexander Shaposhnikov ffb997a8eb [clang-move] Create ClangMoveActionFactory on stack
This diff removes unnecessary using of unique_ptr with ClangMoveActionFactory (pico cleanup).
NFC

Test plan: make check-clang-tools

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

llvm-svn: 300356
2017-04-14 18:12:11 +00:00
Haojian Wu 4a92050ce2 [clang-move] Extend clang-move to support moving global variable.
Summary: Also support dumping global variables.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 296337
2017-02-27 13:19:13 +00:00
Haojian Wu 903d35e50e Remove dead code.
llvm-svn: 292218
2017-01-17 13:46:59 +00:00
Haojian Wu 4775ce56ec [clang-move] Handle helpers with forward declarations.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 292215
2017-01-17 13:22:37 +00:00
Haojian Wu b3d9888449 [clang-move] Ignore using decls which are defined in macros.
Summary:
Also ignore helpers which are defined in macro. Currently clang-move doesn't
handle macro well enough, especiall for complex macros. This patch will ignore
declarations in macros to make the behavior of clang-move more correct.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 292207
2017-01-17 10:08:11 +00:00
Antonio Maiorano 0d7d9c20a5 Update tools to use new getStyle API
Depends on https://reviews.llvm.org/D28081

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

llvm-svn: 292175
2017-01-17 00:13:32 +00:00
Haojian Wu 85867727fa [clang-move] Dump enum and type alias declarations.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 292098
2017-01-16 09:34:07 +00:00
Haojian Wu d69d90753c [clang-move] Support moving type alias declarations.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 290967
2017-01-04 14:50:49 +00:00
Haojian Wu 32a552f6b0 [clang-move] Support moving enum declarations.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 290891
2017-01-03 14:22:25 +00:00
Haojian Wu 3626516b14 [clang-move] Only move used helper declarations.
Summary:
Instead of moving all the helper declarations blindly, this patch
implements an AST-based call graph solution to make clang-move only move used
helper decls to new.cc and remove unused decls in old.cc.

Depends on D27674.

Reviewers: ioeric

Subscribers: mgorny, cfe-commits

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

llvm-svn: 290873
2017-01-03 09:00:51 +00:00
Haojian Wu dc4edba576 [clang-move] Fix incorrect EndLoc for declarations in macros.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 289541
2016-12-13 15:35:47 +00:00
Alexander Shaposhnikov b8c997f1d2 [clang-move] Fix buildbot failures
Fix the buildbot failures introduced by D27669

llvm-svn: 289465
2016-12-12 20:24:44 +00:00
Alexander Shaposhnikov 62a154dab6 [clang-move] Use appendArgumentsAdjuster for adding extra arguments
1. Remove some boilerplate code for appending -fparse-all-comments to the list of arguments.
2. Run clang-format -i against ClangMoveMain.cpp.

Test plan: make check-all

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

llvm-svn: 289464
2016-12-12 19:56:37 +00:00
Eric Liu 47a42d53fc [clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.
llvm-svn: 288791
2016-12-06 10:12:23 +00:00
Eric Liu 033b3a8b25 [clang-move] don't miss ',' in json output when there are duplicate elements.
llvm-svn: 288586
2016-12-03 15:28:03 +00:00
Haojian Wu 08e402ac93 [clang-move] some tweaks.
* Don't save SourceManager for each declarations.
* Rename some out-dated methods.

No functionality change.

llvm-svn: 288498
2016-12-02 12:39:39 +00:00
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
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
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
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
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
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
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
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
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