summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-rename
Commit message (Collapse)AuthorAgeFilesLines
* [refactor] Move clang-rename into the clang repositoryAlex Lorenz2017-06-3013-1767/+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: add new -force optionMiklos Vajna2017-06-023-6/+22
| | | | | | | | | | | | | | | | | Summary: The use-case is when renaming a widely used name, like a lower-level class in a codebase and clang-rename is simply invoked for each translation unit based on the compile database. In this case it's not interesting to show errors: not finding the symbol means there is simply nothing to do. Reviewers: klimek Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D32403 llvm-svn: 304534
* clang-rename: fix formattingMiklos Vajna2017-04-233-7/+5
| | | | | | As detected by clang-format. llvm-svn: 301130
* Wdocumentation fixSimon Pilgrim2017-04-061-3/+3
| | | | llvm-svn: 299642
* Fix windows buildbot error.Haojian Wu2017-04-041-1/+1
| | | | llvm-svn: 299422
* [clang-rename] Support renaming qualified symbolHaojian Wu2017-04-047-1/+428
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Spelling mistakes in comments. NFCI.Simon Pilgrim2017-03-301-1/+1
| | | | | | Based on corrections mentioned in patch for clang for PR27635 llvm-svn: 299074
* 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] Fix non-functional offset check.Benjamin Kramer2016-11-231-7/+6
| | | | | | | | | 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
* [clang-rename] Prune away AST nodes more correctly and effectively when ↵Benjamin Kramer2016-11-221-6/+9
| | | | | | | | | | | | | | | | | | 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
* Make Emacs libraries compatible with Emacs 24.Manuel Klimek2016-10-111-1/+6
| | | | | | | | Emacs 24 doesn't have format-message, fall back to format in that case. Patch by Philipp Stephani. llvm-svn: 283861
* [clang-rename] Overhaul clang-rename.el.Kirill Bobyrev2016-10-021-22/+52
| | | | | | | | | | | | | | | | | | | | | | | * Use lexical binding, as recommended for new libraries. * Fix customization variable (set correct group and type). * Create a new customization group for the library. * Autoload the main clang-rename command so that users don't have to explicitly load the library. * Correctly translate between file and buffer positions using bufferpos-to-filepos (if available) or a fallback. * Don't invoke the shell, it's not necessary and adds complexity. * Save clang-rename output in a buffer and display that on failure. * Save all buffers before calling clang-rename. This is required anyway and prevents data loss when the buffer is later reverted. * In revert-buffer, use keywords instead of t for Boolean arguments to improve readability. * Don't reset buffer modes when reverting. * Emacs treats the character after a symbol as part of the symbol, while clang-rename doesn't; resolve this inconsistency. * Formatting. Patch by Philipp Stephani! Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D25156 llvm-svn: 283067
* [clang-rename] Use checktime when reloading vim buffer after applying ↵Kirill Bobyrev2016-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | clang-rename After applying `clang-rename` to a vim buffer (using `clang-rename.py` as part of the vim integration) the buffer gets reloaded using `bufdo`. This solution is suboptimal, since syntax highlighting is turned off for performance reasons and never turned on, after all changes to the source file have been applied. A better solution to this is using `checktime`. It is exactly designed for this kind of task and doesn't have the syntax highlighting issue. Patch by Kai Wolf! Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D24791 llvm-svn: 282388
* [clang-rename] Fix handling of unchanged filesAlexander Shaposhnikov2016-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Fix the output of clang-rename for the files without modifications. Update the code in clang-reorder-fields/tool/ClangReorderFields.cpp to avoid inconsistency. Example: a.h: struct A {}; a.cpp: #include "a.h" int main() { return 0; } Before the changes the output looks like this: clang-rename -qualified-name=A -new-name=B a.cpp <<<<<INVALID SOURCE LOCATION>>>>> Test plan: make -j8 check-clang-tools Differential revision: https://reviews.llvm.org/D24634 llvm-svn: 281826
* [clang-rename] Merge rename-{at|all} & optimise.Kirill Bobyrev2016-09-163-199/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | Having both rename-at and rename-all both seems confusing and introduces unneeded difficulties. After merging rename-at and rename-all maintaining main function wrappers and custom help becomes redundant while CLI becomes less confusing. D24224 (which was the original patch causing buildbot failures) wasn't aware of bugs caused by passing both -offset and -qualified-name. After D24224 was landed it caused buildbot failures and therefor I just reverted it. Two things that make this patch different from D24224 are: * unittests/clang-rename was deleted, because it is unmaintained and doesn't do much. * Passing both `-offset` and `-qualified-name` isn't allowed anymore for the sake of preventing bugs. This patch is a trivial enhancement of accepted D24224 revision. Tested with `ninja check-all`. Differential Revision: https://reviews.llvm.org/D24567 llvm-svn: 281710
* reverting r281456Kirill Bobyrev2016-09-143-149/+199
| | | | llvm-svn: 281459
* [clang-rename] Merge rename-{at|all} & optimize.Kirill Bobyrev2016-09-143-199/+149
| | | | | | | | | | | | | | Having both rename-at and rename-all both seems confusing and introduces unneeded difficulties. Allowing to use both -qualified-name and -offset at once while performing efficient renamings seems like a feature, too. Maintaining main function wrappers and custom help becomes redundant while CLI becomes less confusing. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24224 llvm-svn: 281456
* [clang-rename] Add comment after namespace closingKirill Bobyrev2016-09-051-2/+3
| | | | llvm-svn: 280653
* [clang-rename] Enforce LLVM policy about braces around single line control ↵Kirill Bobyrev2016-09-044-62/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Fix Clang-tidy and IWYU warnings; other minor fixesKirill Bobyrev2016-09-041-3/+7
| | | | | | | | | Patch by Eugene Zelenko! Differential Revision: https://reviews.llvm.org/D24178 Reviewers: omtcyfz llvm-svn: 280638
* clang-rename: fix formatting in USRFinderMiklos Vajna2016-08-301-2/+1
| | | | | | As detected by clang-format. llvm-svn: 280063
* clang-rename: improve error message when -old-name is used and could not ↵Miklos Vajna2016-08-301-6/+9
| | | | | | | | | | | | | | find symbol Old output was: clang-rename: could not find symbol at tools/clang/tools/extra/test/clang-rename/ClassFindByName.cpp:1:1 (offset 0). Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D24002 llvm-svn: 280062
* minor header guards and help messages cleanupKirill Bobyrev2016-08-193-7/+7
| | | | llvm-svn: 279226
* [clang-rename] fix broken buildKirill Bobyrev2016-08-161-1/+1
| | | | | | | As Eric Fiselier pointed out, r278760 breaks build, because RecursiveASTVisitor doesn't have a const overload. This patch is a quick fix. llvm-svn: 278780
* [clang-rename] cleanup `auto` usagesKirill Bobyrev2016-08-154-25/+28
| | | | | | | | | | | | | | | | | | | 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 YAML reader: address post-commit commentsMiklos Vajna2016-08-101-6/+5
| | | | llvm-svn: 278201
* clang-rename rename-all: support reading old/newname pairs from a YAML fileMiklos Vajna2016-08-091-1/+57
| | | | | | | | | | | This is handy in case by the time clang-rename is invoked, an external tool already genereated a list of oldname -> newname pairs to handle. Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D23198 llvm-svn: 278145
* [clang-rename] cleanup: use isWrittenKirill Bobyrev2016-08-092-4/+4
| | | | | | | | | | | | | | 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-092-11/+21
| | | | | | | | | | | 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 missing clang-format improvementsKirill Bobyrev2016-08-042-3/+3
| | | | | | | | r277702 introduced clang-format changes so that later commits wouldn't introduce non-functional changes while running clang-format before commiting. Though, few changes by clang-format weren't in the patch. llvm-svn: 277709
* Run clang-format on clang-rename codeMiklos Vajna2016-08-043-13/+10
| | | | | | | | | | | So that later commits don't introduce non-functional changes when running clang-format before committing. Reviewers: klimek Differential Revision: https://reviews.llvm.org/D23153 llvm-svn: 277702
* [clang-rename] improve USRFindingActionKirill Bobyrev2016-08-032-29/+65
| | | | | | | | | | | | | | | | | | | | | | 1. Improve templated class renaming, namely add capabilities of finding partial and full specializations. Every class partial specialization has reference to the specialized class. Thus, storing all partial specializations and comparing specialized class decls to the FoundDecl solves this. All full class specializations can be found by calling ClassTemplateDecl::specializations(). 2. Fix virtual function and its overriding functions renaming. Renaming a virtual function requires renaming every other function in its "overriding graph". 3. Merge TemplateClassInstantiationFindBy{Declaration|TypeUse}.cpp tests into one test by adding multiple invocations of clang-rename to one test, because the only different thing across these tests is -offset passed to clang-rename. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D23058 llvm-svn: 277663
* [clang-rename] fix Emacs integration scriptKirill Bobyrev2016-08-021-3/+1
| | | | llvm-svn: 277491
* [clang-rename] fix Emacs script build failureKirill Bobyrev2016-08-021-2/+3
| | | | | | Clang-rename Emacs integration script sometimes doesn't work correctly. llvm-svn: 277469
* clang-rename: split existing options into two new subcommandsMiklos Vajna2016-08-023-81/+163
| | | | | | | | | | | | | | | - rename-at is meant to be integrated with editors and works mainly off of a location in a file, and this is the default - rename-all is optimized for one or more oldname->newname renames, and works with clang-apply-replacements Reviewers: bkramer, klimek Subscribers: omtcyfz Differential Revision: https://reviews.llvm.org/D21814 llvm-svn: 277438
* [clang-rename] add support for template parameter renamingKirill Bobyrev2016-08-022-0/+11
| | | | | | | | | | | 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] add basic Emacs integrationKirill Bobyrev2016-08-022-0/+52
| | | | | | | | | | This patch aims to add very basic Emacs integration. Reviewers: hokein, alexfh Differential Revision: https://reviews.llvm.org/D23006 llvm-svn: 277433
* [clang-rename] handle overridden functions correctlyKirill Bobyrev2016-08-011-17/+20
| | | | | | | | | | | | | 1. Renaming overridden functions only works for two levels of "overriding hierarchy". clang-rename should recursively add overridden methods. 2. Make use of forEachOverridden AST Matcher. 3. Fix two tests. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D23009 llvm-svn: 277356
* Changes related to new implementation of tooling::Replacements as class.Eric Liu2016-08-013-17/+24
| | | | | | | | | | | | Summary: See http://reviews.llvm.org/D21748 for details. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21749 llvm-svn: 277336
* [clang-rename] speedup RenamingActionKirill Bobyrev2016-07-293-32/+28
| | | | | | | | | | | | 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] USRFinder.cpp cleanupKirill Bobyrev2016-07-281-28/+25
| | | | llvm-svn: 276967
* clang-rename: adjust NamedDeclFindingASTVisitor for RecordDeclsSaleem Abdulrasool2016-07-281-6/+8
| | | | | | | | | | Ensure that Context is always properly initialised in the constructor. It is used for querying the LangOpts in VisitTypeLoc. Prevent a null pointer dereference in setResult by ensuring that a RecordDecl is being handled. Patch by Alexander Shaposhnikov! llvm-svn: 276948
* change Vim key binding for include-fixer and clang-renameKirill Bobyrev2016-07-271-3/+3
| | | | | | | | | | | | Change Vim key binding for include-fixer (`,cf` -> `<leader>cf`) and clang-rename (`,cr` -> `<leader>cr`) to use `<leader>` instead of `,` like cool Vim people (tm) do. Reviewers: ioeric Differential Revision: https://reviews.llvm.org/D22854 llvm-svn: 276870
* [clang-rename] skip CXXConversionDecl while searching for NamedDeclKirill Bobyrev2016-07-271-2/+2
| | | | llvm-svn: 276866
* [Clang-rename] Remove custom version, fix extra space in error message.Eugene Zelenko2016-07-251-20/+12
| | | | | | | | Also fixed some Include What You Use Warnings. Differential revision: https://reviews.llvm.org/D22654 llvm-svn: 276684
* [clang-rename] introduce better symbol findingKirill Bobyrev2016-07-225-128/+118
| | | | | | | | | | | | | | | 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] check whether -new-name is valid identifier in C++17 Kirill Bobyrev2016-07-211-1/+12
| | | | llvm-svn: 276259
* clangRename: Update libdeps to add clangASTMatchers.NAKAMURA Takumi2016-07-191-0/+1
| | | | | | Note, ClangRenameTests is linking USRFindingAction.cpp directly. llvm-svn: 275986
* [clang-rename] add support for overridden functionsKirill Bobyrev2016-07-191-42/+102
| | | | | | | | Reviewers: klimek Differential Revision: https://reviews.llvm.org/D22408 llvm-svn: 275958
OpenPOWER on IntegriCloud