summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-rename/USRLocFinder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [refactor] Move clang-rename into the clang repositoryAlex Lorenz2017-06-301-509/+0
| | | | | | | | | | | | The core engine of clang-rename will be used for local and global renames in the new refactoring engine, as mentioned in http://lists.llvm.org/pipermail/cfe-dev/2017-June/054286.html. The clang-rename tool is still supported but might get deprecated in the future. Differential Revision: https://reviews.llvm.org/D34696 llvm-svn: 306840
* clang-rename: fix formattingMiklos Vajna2017-04-231-2/+1
| | | | | | As detected by clang-format. llvm-svn: 301130
* Fix windows buildbot error.Haojian Wu2017-04-041-1/+1
| | | | llvm-svn: 299422
* [clang-rename] Support renaming qualified symbolHaojian Wu2017-04-041-0/+343
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The patch adds a new feature for renaming qualified symbol references. Unlike orginal clang-rename behavior, when renaming a qualified symbol to a new qualified symbol (e.g "A::Foo" => "B::Bar"), this new rename behavior will consider the prefix qualifiers of the symbol, and calculate the new prefix qualifiers. It aims to add as few additional qualifiers as possible. As this is an early version (only supports renaming classes), I don't change current clang-rename interfaces at the moment, and would like to keep its (command-line tool) behavior. So I added new interfaces for the prototype. In the long run, these interfaces should be unified. No functionality changes in original clang-rename command-line tool. This patch also contains a few bug fixes of clang-rename which are discovered by the new unittest: * fix a potential nullptr accessment when class declaration doesn't have definition. * add USRs of nested declartaions in "getNamedDeclFor". Reviewers: ioeric Reviewed By: ioeric Subscribers: alexfh, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D31176 llvm-svn: 299419
* Fix some Clang-tidy modernize-use-default and Include What You Use warnings; ↵Eugene Zelenko2016-11-291-2/+10
| | | | | | | | other minor fixes (NFC). This preparation to remove SetVector.h dependency on SmallSet.h. llvm-svn: 288175
* [clang-rename] Enforce LLVM policy about braces around single line control ↵Kirill Bobyrev2016-09-041-19/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | flow statement body. Although it is not explicitly stated in LLVM Coding Standards, LLVM developers prefer to omit braces around flow control statements with single line body. For example the following piece of code ``` if (condition) std::cout << "Hello, world!" << std::endl; ``` is preferred to ``` if (condition) { std::cout << "Hello, world!" << std::endl; } ``` So far clang-rename has ignored this. This patch makes clang-rename more "LLVM-ish". llvm-svn: 280640
* [clang-rename] cleanup `auto` usagesKirill Bobyrev2016-08-151-5/+6
| | | | | | | | | | | | | | | | | | | As Alexander pointed out, LLVM Coding Standards are more conservative about using auto, i.e. it should be used in the following situations: * When the type is obvious, i.e. explicitly mentioned in the same expression. For example `if (const clang::FieldDecl *FieldDecl = Initializer->getMember())`. * When the type is totally non-obvious and one iterates over something. For example `for (const auto &CurrDecl : Context.getTranslationUnitDecl()->decls())`. Otherwise the type should be explicitly stated. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D23397 llvm-svn: 278760
* [clang-rename] cleanup: use isWrittenKirill Bobyrev2016-08-091-2/+2
| | | | | | | | | | | | | | nit: use isWritten and const auto *Initializer in NamedDeclFindingASTVisitor::VisitCXXConstructorDecl method. Test plan: make -j8 check-clang-tools (passed) Patch by Alexander Shaposhnikov! Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D23298 llvm-svn: 278112
* [clang-rename] fix bug with initializer listsKirill Bobyrev2016-08-091-11/+2
| | | | | | | | | | | Clang-rename is currently not able to find a symbol in initializer list. This patch fixes described issue. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D23193 llvm-svn: 278099
* [clang-rename] add support for template parameter renamingKirill Bobyrev2016-08-021-0/+7
| | | | | | | | | | | Few simple tweaks allow template parameters to be renamed. See TemplateTypenameFindBy{TemplateParam|TypeInside}.cpp Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D22853 llvm-svn: 277437
* [clang-rename] speedup RenamingActionKirill Bobyrev2016-07-291-16/+17
| | | | | | | | | | | | The complexity of renaming a USR is O(N) [N stands for number of nodes in Translation Unit]. In some cases there are more than one USR for a single symbol (see overridden functions and ctor/dtor handling), which means that the complexity of finding all of the corresponding USRs is O(N * M) [M stands for number of USRs corresponding to the symbols, which may be not quite small]. With a simple tweak we can make it O(N * log(M)) by passing whole list of USRs corresponding to the symbol to USRLocFinder. llvm-svn: 277131
* [clang-rename] remove redundant *_cast<> traversalKirill Bobyrev2016-07-281-34/+0
| | | | llvm-svn: 276971
* [clang-rename] introduce better symbol findingKirill Bobyrev2016-07-221-67/+45
| | | | | | | | | | | | | | | This patch introduces: * TypeLoc visiting, which helps a lot in renaming types * NestedNameSpecifierLoc visiting (through getting them via ASTMatcher at the moment, though, because RecursiveASTVisitor<T>::VisitNestedNameSpecifierLoc isn't implemented), which helps to treat nested names correctly * better code formatting and refactoring * bunch of tests Reviewers: alexfh Differential revision: https://reviews.llvm.org/D22465 llvm-svn: 276414
* [clang-rename] apply stylistic fixesKirill Bobyrev2016-07-151-3/+3
| | | | llvm-svn: 275550
* [clang-rename] exit code-related bugfix and code cleanupBenjamin Kramer2016-07-141-10/+12
| | | | | | | | | | | | | | 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
* [clang-tools] mark TokenName as unusedArtem Belevich2016-06-151-1/+1
| | | | | | Otherwise it produces compiler warning if asserts are disabled. llvm-svn: 272852
* clang-rename: implement renaming of classes with a dtorMiklos Vajna2016-06-151-0/+22
| | | | | | | | | | | 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
* clang-rename: implement handling of remaining named castsMiklos Vajna2016-06-131-0/+8
| | | | | | | | | | const_cast<> and reinterpret_cast<>. Reviewers: klimek Differential Revision: http://reviews.llvm.org/D21270 llvm-svn: 272574
* clang-rename: implement renaming of classes inside dynamic_castMiklos Vajna2016-06-081-13/+21
| | | | | | | | | | Refactor to do the same as what is done already for static_cast. Reviewers: klimek Differential Revision: http://reviews.llvm.org/D21120 llvm-svn: 272188
* clang-rename: implement renaming of classes inside static_castMiklos Vajna2016-06-061-0/+17
| | | | | | | | | | | "Derived" in static_cast<Derived&>(...) wasn't renamed, nor in its pointer equivalent. Reviewers: klimek Differential Revision: http://reviews.llvm.org/D21012 llvm-svn: 271933
* clang-rename: fix renaming heap allocationsMiklos Vajna2016-06-021-0/+11
| | | | | | | | | | The check failed, 'Cla *C = new Cla();' was renamed to 'D *C = new Cla();'. Reviewers: klimek Differential Revision: http://reviews.llvm.org/D20635 llvm-svn: 271572
* clang-rename: fix renaming non-members variables when referenced as macro ↵Miklos Vajna2016-05-241-1/+3
| | | | | | | | | | | | arguments The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y). Reviewers: klimek Differential Revision: http://reviews.llvm.org/D20537 llvm-svn: 270599
* clang-rename: fix renaming members when referenced as macro argumentsMiklos Vajna2016-05-201-1/+3
| | | | | | | | | | The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y). Reviewers: klimek Differential Revision: http://reviews.llvm.org/D20446 llvm-svn: 270204
* clang-rename: handle non-inline ctor definitions when renaming classesMiklos Vajna2016-05-181-0/+5
| | | | | | | | | | The result of the test was C::D(), not D::D(). Reviewers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20356 llvm-svn: 269952
* clang-rename: avoid StringRef members in USRLocFindingASTVisitorMiklos Vajna2016-05-171-2/+2
| | | | | | | | | | | | Even if this is defined in the .cpp file and only used as part of the function (so here it's safe), usually storing StringRefs in the class is dangerous, so don't do so. Reviewers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20296 llvm-svn: 269796
* clang-rename: check that the source location we find actually has the old nameMiklos Vajna2016-05-131-5/+15
| | | | | | | | | | | This more general check could have prevented the specific problem "getSourceOrder() == -1" guards. Reviewers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20216 llvm-svn: 269402
* clang-rename: fix renaming of field with implicit initializersMiklos Vajna2016-05-111-0/+5
| | | | | | | | | | The last check failed as Cla::Cla() was rewritten to Cla::hector(). Reviewers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20150 llvm-svn: 269161
* clang-rename: when renaming a field, rename initializers of that field as wellMiklos Vajna2016-05-071-0/+13
| | | | | | | | | | Summary: The second check failed, the initializer wasn't renamed. Reviewers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D19957 llvm-svn: 268857
* When renaming a class, ename pointers to that class as well.Manuel Klimek2016-05-041-0/+12
| | | | | | Patch by Miklos Vajna. llvm-svn: 268484
* Revert rL215947: "[clang-rename] revert r215839"Manuel Klimek2014-08-201-0/+103
| | | | | | Make tests not depend on grep supporting -bo. llvm-svn: 216041
* [clang-rename] revert r215839Gerolf Hoflehner2014-08-181-103/+0
| | | | | | | | | | | | | | | | | | | | The commit broke public build bots for more than 24 hours. (view as text) ******************** TEST 'Clang Tools :: clang-rename/VarTest.cpp' FAILED ******************** Script: -- cat /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/tools/extra/test/clang-rename/VarTest.cpp > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp clang-rename -offset=$(grep -FUbo 'foo;' /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp | head -1 | cut -d: -f1) -new-name=hector /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp -i -- sed 's,//.*,,' /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp | FileCheck /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang.src/tools/extra/test/clang-rename/VarTest.cpp -- Exit Code: 1 Command Output (stderr): -- clang-rename: could not find symbol at /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/tools/clang/tools/extra/test/clang-rename/Output/VarTest.cpp.tmp.cpp:2:1 (offset 14). llvm-svn: 215947
* First version of a clang-rename tool.Manuel Klimek2014-08-171-0/+103
Summary: Note that this code is still grossly under-tested - the next steps will be to add significantly better test coverage. Patch by Matthew Plant. Test Plan: Reviewers: Subscribers: llvm-svn: 215839
OpenPOWER on IntegriCloud