summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/change-namespace/ChangeNamespace.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [change-namespace] add an option to dump changed files in YAML.Eric Liu2017-02-131-1/+1
| | | | | | | | | | | | Reviewers: hokein Reviewed By: hokein Subscribers: fhahn, cfe-commits Differential Revision: https://reviews.llvm.org/D29893 llvm-svn: 294969
* [change-namespace] trying to fix build bot failure caused by r293909.Eric Liu2017-02-021-0/+2
| | | | llvm-svn: 293927
* [change-namespace] fix unscoped enum constant references.Eric Liu2017-02-021-0/+30
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29460 llvm-svn: 293909
* [change-namespace] check using shadow decl correctly when shortening ↵Eric Liu2017-02-021-1/+2
| | | | | | | | | | | | | | | | | namespace specifiers. Summary: This fixes mismatch between template decls and template specialization decls. Also added a few more test cases. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29447 llvm-svn: 293897
* [change-namespace] correctly shorten namespace when references have leading '::'Eric Liu2017-01-261-4/+2
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29182 llvm-svn: 293187
* [change-namespace] add leading '::' to references in new namespace when name ↵Eric Liu2017-01-261-7/+37
| | | | | | | | | | | | | | | | | | conflict is possible. Summary: For example, when we change 'na' to "nb::nc", we need to add leading '::' to references "::nc::X" in the changed namespace. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29176 llvm-svn: 293182
* Update tools to use new getStyle APIAntonio Maiorano2017-01-171-3/+6
| | | | | | | | Depends on https://reviews.llvm.org/D28081 Differential Revision: https://reviews.llvm.org/D28315 llvm-svn: 292175
* [change-namespace] get newlines around moved namespace right.Eric Liu2017-01-041-15/+12
| | | | | | | | | | | | Summary: Previously, a `\n` might be left in the old namespace and thus not copied to the new namespace, which is bad. Reviewers: hokein Subscribers: alexshap, cfe-commits Differential Revision: https://reviews.llvm.org/D28282 llvm-svn: 290966
* [change-namespace] consider namespace aliases to shorten qualified names.Eric Liu2016-12-231-0/+41
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28052 llvm-svn: 290421
* [change-namespace] do not fix calls to overloaded operator functions.Eric Liu2016-12-201-0/+13
| | | | | | | | | | | | Summary: Also make sure one function reference is only processed once. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27982 llvm-svn: 290176
* [change-namespace] fix a case references to templated using alias are ↵Eric Liu2016-12-151-4/+6
| | | | | | qualified types. llvm-svn: 289816
* [change-namespace] handling templated type aliases correctly.Eric Liu2016-12-151-16/+32
| | | | | | | | | | | | Summary: This fixes templated type aliases and templated type aliases in classes. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27801 llvm-svn: 289799
* [change-namespace] don't crash when type reference is in function type ↵Eric Liu2016-12-141-14/+28
| | | | | | | | | | | | parameter list. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27758 llvm-svn: 289672
* modernize-use-auto NFC fixesPiotr Padlewski2016-12-141-1/+1
| | | | llvm-svn: 289656
* [change-namespace] always add a '::' prefix when a symbol reference needs to ↵Eric Liu2016-12-071-0/+4
| | | | | | be fully-qualified. llvm-svn: 288969
* [change-namespace] don't fix using shadow decls in classes.Eric Liu2016-12-071-10/+24
| | | | | | | | | | | | | | Summary: Using shadow declarations in classes always refers to base class, which does not need to be fixed/qualified since it can be inferred from inheritance. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27523 llvm-svn: 288919
* [change-namespace] move template class forward-declarations and don't move ↵Eric Liu2016-12-071-6/+18
| | | | | | | | | | | | | | | | | | fwd-decls in classes. Summary: Forward declarations in moved namespaces should be moved back to the old namespaces. We should also move template class forward declarations. Also fix a bug that moves forward declarations of nested classes. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27515 llvm-svn: 288908
* [change-namespace] get changing namespace to global correct.Eric Liu2016-12-051-2/+5
| | | | llvm-svn: 288662
* [change-namespace] don't generate replacements for files that don't match ↵Eric Liu2016-12-011-6/+11
| | | | | | | | | | | | file pattern. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27302 llvm-svn: 288376
* [change-namespace] fix non-calling function references.Eric Liu2016-11-291-15/+32
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27208 llvm-svn: 288139
* [change-namespace] handle constructor initializer: Derived : Base::Base() {} ↵Eric Liu2016-11-161-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [change-namespace] consider typedef/using alias decls in the moved namespace.Eric Liu2016-11-141-1/+20
| | | | | | | | | | | | 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
* Handle adding new nested namespace in old namespace.Eric Liu2016-11-101-11/+18
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26456 llvm-svn: 286486
* [change-namespace] dyn_cast -> cast.Eric Liu2016-11-101-3/+3
| | | | llvm-svn: 286485
* [change-namespace] shorten namespace qualifier based on UsingDecl and ↵Eric Liu2016-11-081-32/+111
| | | | | | | | | | | | | | | | | 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
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-4/+6
| | | | | | | | | | | | | | | | 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
* [change-namespace] fix namespace specifiers of template arguments.Eric Liu2016-10-311-4/+6
| | | | llvm-svn: 285549
* [change-namespace] don't miss comments in the beginning of a namespace block.Eric Liu2016-10-121-13/+41
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25397 llvm-svn: 284011
* [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.Eric Liu2016-10-051-10/+13
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25065 llvm-svn: 283333
* [change-namespace] Fix a misplaced case when there is no trailing newline ↵Haojian Wu2016-10-041-2/+3
| | | | | | | | | | | | character at the end of the file. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25226 llvm-svn: 283210
* [change-namespace] fix namespace specifier of global variables.Eric Liu2016-09-301-3/+20
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24963 llvm-svn: 282837
* Workaround ASTMatcher crashes. Added some more test cases.Eric Liu2016-09-271-10/+17
| | | | | | | | | | | | | | | Summary: - UsingDecl matcher crashed when `UsingShadowDecl` has no parent map. Workaround by moving parent check into `UsingDecl`. - FunctionDecl matcher crashed when there is a lambda defined in parameter list (also due to no parent map). Workaround by putting `unless(cxxMethodDecl())` before parent check. Reviewers: klimek, sbenza, aaron.ballman, hokein Subscribers: aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D24862 llvm-svn: 282486
* [change-namespace] fix qualifier of function references.Eric Liu2016-09-221-4/+34
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24803 llvm-svn: 282146
* [change-namespace] fix name qualifiers in UsingShadowDecl and ↵Eric Liu2016-09-211-4/+40
| | | | | | | | | | | | NestedNameSpecifier. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24784 llvm-svn: 282073
* Trying to fix name conflict in change-namespace tool.Eric Liu2016-09-191-4/+4
| | | | llvm-svn: 281920
* A clang tool for changing surrouding namespaces of class/function definitions.Eric Liu2016-09-191-0/+509
Summary: A tool for changing surrouding namespaces of class/function definitions while keeping references to types in the changed namespace correctly qualified by prepending namespace specifiers before them. Example: test.cc namespace na { class X {}; namespace nb { class Y { X x; }; } // namespace nb } // namespace na To move the definition of class Y from namespace "na::nb" to "x::y", run: clang-change-namespace --old_namespace "na::nb" \ --new_namespace "x::y" --file_pattern "test.cc" test.cc -- Output: namespace na { class X {}; } // namespace na namespace x { namespace y { class Y { na::X x; }; } // namespace y } // namespace x Reviewers: alexfh, omtcyfz, hokein Subscribers: mgorny, klimek, djasper, beanz, alexshap, Eugene.Zelenko, cfe-commits Differential Revision: https://reviews.llvm.org/D24183 llvm-svn: 281918
OpenPOWER on IntegriCloud