This reverts commit 97aa593a83 as it
causes problems (PR45453) https://reviews.llvm.org/D77574#1966321.
This additionally adds an explicit reference to FrontendOpenMP to
clang-tidy where ASTMatchers is used.
This is hopefully just a temporary solution. The dependence on
`FrontendOpenMP` from `ASTMatchers` should be handled by CMake
implicitly, not us explicitly.
Reviewed By: aheejin
Differential Revision: https://reviews.llvm.org/D77666
Use clang_target_link_libraries() in order to support linking against
libclang-cpp instead of static libraries.
Differential Revision: https://reviews.llvm.org/D68448
llvm-svn: 373786
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.
Differential revision: https://reviews.llvm.org/D66259
llvm-svn: 368944
to reflect the new license.
We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.
Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.
llvm-svn: 351636
Summary:
Following D48903 ([VirtualFileSystem] InMemoryFileSystem::status: Return
a Status with the requested name), the paths output by clang-move in the
FileToReplacements map may contain leading "./". For example, where we
would get "foo.h", we'll now get "./foo.h". This breaks the tests,
because we are doing exact string lookups in the FileToFileID and
Results maps (they contain "foo.h", but we search for "./foo.h").
To mitigate this, try to normalize a little bit the paths output by
clang-move to remove that leading "./".
This patch should be safe to merge before D48903, remove_dots will just
be a no-op.
Reviewers: ilya-biryukov, hokein
Reviewed By: hokein
Subscribers: ioeric, cfe-commits
Differential Revision: https://reviews.llvm.org/D48951
llvm-svn: 336358
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
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
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
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
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
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
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
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
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
clang-tools-extra\unittests\clang-move\ClangMoveTests.cpp(216) : error C2593: 'operator =' is ambiguous
llvm\include\llvm/ADT/SmallVector.h(898): could be 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)'
llvm\include\llvm/ADT/SmallVector.h(893): or 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVectorImpl<T> &&)'
with
[
T=std::string
]
llvm\include\llvm/ADT/SmallVector.h(883): or 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVector<std::string,4> &&)'
llvm\include\llvm/ADT/SmallVector.h(873): or 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(const llvm::SmallVector<std::string,4> &)'
while trying to match the argument list '(llvm::SmallVector<std::string,4>, initializer-list)'
llvm-svn: 284360
This diff replaces manual parsing of the comma-separated list of names with
cl::list and cl::CommaSeparated.
Test plan: make -j8 check-clang-tools
Differential revision: https://reviews.llvm.org/D25586
llvm-svn: 284291
Summary:
The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.
Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25610
llvm-svn: 284233
This reverts commit r283526 et al as it keeps randomly breaking bots, even after
the commit has gone, on other people's commit ranges.
Revert "[clang-move] Simplify lint tests" (r283545).
Revert "Fix buildbot error." (r283534).
Revert "Revert "fix buildbot error" since it is not right fix." (r283538).
llvm-svn: 283553
Summary:
cleanup the remaining empty namespace after moving out the
class defintitions.
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25282
llvm-svn: 283424
Summary:
Previously, all #includes (includeing old_header.h) in old.cc will be copied to new.cc,
however, the new.cc should include new_header.h instead of the old_header.h
Before applying the patch, the new.cc looks like:
```
#include "old_header.h"
...
```
The new.cc looks like with this patch:
```
#include "new_header"
...
```
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D24828
llvm-svn: 282247
Summary:
This patch introduces a new tool which moves a specific class definition
from files (.h, .cc) to new files (.h, .cc), which mostly acts like
"Extract class defintion". In the long term, this tool should be
merged in to clang-refactoring as a subtool.
clang-move not only moves class definition, but also moves all the
forward declarations, functions defined in anonymous namespace and #include
headers to new files, to make sure the new files are compliable as much
as possible.
To move `Foo` from old.[h/cc] to new.[h/cc], use:
```
clang-move -name=Foo -old_header=old.h -old_cc=old.cc -new_header=new.h
-new_cc=new.cc old.cc
```
To move `Foo` from old.h to new.h, use:
```
clang-move -name=Foo -old_header=old.h -new_header=new.h old.cc
```
Reviewers: klimek, djasper, ioeric
Subscribers: mgorny, beanz, Eugene.Zelenko, bkramer, omtcyfz, cfe-commits
Differential Revision: https://reviews.llvm.org/D24243
llvm-svn: 282070