summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Refactoring.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Apply clang-tidy's performance-unnecessary-value-param to parts of clang.Benjamin Kramer2017-03-211-1/+1
| | | | | | No functionality change intended. llvm-svn: 298443
* clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyleAntonio Maiorano2017-01-171-4/+9
| | | | | | | | | | Change the contract of GetStyle so that it returns an error when an error occurs (i.e. when it writes to stderr), and only returns the fallback style when it can't find a configuration file. Differential Revision: https://reviews.llvm.org/D28081 llvm-svn: 292174
* Deduplicate replacements by FileEntry instead of file names.Eric Liu2016-11-071-2/+4
| | | | | | | | | | | | | | | Summary: The current version does not deduplicate equivalent file paths correctly. For example, a relative path and an absolute path are considered inequivalent. Comparing FileEnry addresses these issues. Reviewers: djasper Subscribers: alexshap, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D26288 llvm-svn: 286096
* Deduplicate sets of replacements by file names.Eric Liu2016-10-141-2/+2
| | | | | | | | | | | | | | | Summary: If there are multiple <File, Replacements> pairs with the same file path after removing dots, we only keep one pair (with path after dots being removed) and discard the rest. Reviewers: djasper Subscribers: klimek, hokein, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D25565 llvm-svn: 284219
* Implement tooling::Replacements as a class.Eric Liu2016-08-011-6/+10
| | | | | | | | | | | | | | | | | | | Summary: - Implement clang::tooling::Replacements as a class to provide interfaces to control how replacements for a single file are combined and provide guarantee on the order of replacements being applied. - tooling::Replacements only contains replacements for the same file now. Use std::map<std::string, tooling::Replacements> to represent multi-file replacements. - Error handling for the interface change will be improved in followup patches. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21748 llvm-svn: 277335
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+1
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Make tooling::applyAllReplacements return llvm::Expected<string> instead of ↵Eric Liu2016-07-111-2/+6
| | | | | | | | | | | | | | | | empty string to indicate potential error. Summary: return llvm::Expected<> to carry error status and error information. This is the first step towards introducing "Error" into tooling::Replacements. Reviewers: djasper, klimek Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21601 llvm-svn: 275062
* Avoid unnecessary std::string copies. NFC.Benjamin Kramer2016-05-291-2/+2
| | | | llvm-svn: 271182
* Added formatAndApplyAllReplacements that works on multiple files in libTooling.Eric Liu2016-03-291-0/+25
| | | | | | | | | | | | | | Summary: formatAndApplyAllReplacements takes a set of Replacements, applies them on a Rewriter, and reformats the changed code. Reviewers: klimek, djasper Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17852 llvm-svn: 264745
* Introduce a PCHContainerOperations interface (NFC).Adrian Prantl2015-06-201-3/+4
| | | | | | | | | | | | | | | | A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
* Refactor libTooling to reduce required dependencies.Daniel Jasper2014-10-291-261/+0
| | | | | | | | | | This moves classes for storing and applying replacements to separate files. These classes specifically are used by clang-format which doesn't have any other dependencies on clangAST. Thereby, the size of clang-format's binary can be cut roughly in half and its build time sped up. llvm-svn: 220867
* Tooling: Ignore file names in tooling::deduplicate.Benjamin Kramer2014-09-091-5/+19
| | | | | | | | | | | This was horribly broken due to how the sort predicate works. We would report a conflict for files with a replacement in the same position but different names if the length differed. Just ignore paths as this is often what the user wants. Files can occur with different names (due to symlinks or relative paths) and we don't ever want to do the same edit in one file twice. llvm-svn: 217439
* Overload SourceManager::overrideFileContents so that unconditionally passing ↵David Blaikie2014-08-271-1/+1
| | | | | | | | | | ownership is explicitly done using unique_ptr. Only those callers who are dynamically passing ownership should need the 3 argument form. Those accepting the default ("do pass ownership") should do so explicitly with a unique_ptr now. llvm-svn: 216614
* Update for LLVM api change.Rafael Espindola2014-08-271-2/+3
| | | | llvm-svn: 216585
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210780
* [C++11] Use 'nullptr'. Tooling edition.Craig Topper2014-05-201-2/+2
| | | | llvm-svn: 209192
* Added a const qualifier to SourceManager& parameters.Alexander Kornienko2014-03-051-5/+7
| | | | llvm-svn: 202964
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Use Rewriter::overwriteChangedFiles() directlyAlp Toker2013-10-291-17/+1
| | | | | | | | | | | | | This replaces the custom code in RefactoringTool::saveRewrittenFiles() which lacked atomic file saving and error diagnostics, resolving an old FIXME from r157331. Landing this time with the proper return code, plus a very unhelpful comment cleared up. Rubber-stamped by Manuel Klimek. llvm-svn: 193594
* Revert "Use Rewriter::overwriteChangedFiles() directly"Alp Toker2013-10-291-1/+17
| | | | | | | | This wasn't ready for prime time yet, seems to break tools-extra. This reverts commit r193590. llvm-svn: 193592
* Use Rewriter::overwriteChangedFiles() directlyAlp Toker2013-10-291-17/+1
| | | | | | | | | The old code in RefactoringTool::saveRewrittenFiles() lacked atomic moves and diagnostics and had FIXME to this effect. Rubber-stamped by Manuel Klimek. llvm-svn: 193590
* Reverted r192992 broke windows and freebsd builds.Ariel J. Bernal2013-10-181-10/+4
| | | | llvm-svn: 192997
* This patch fixes replacements that are not applied when relative paths areAriel J. Bernal2013-10-181-4/+10
| | | | | | | | | | specified. In particular it makes sure that relative paths for non-virtual files aren't made absolute. Added unittest. llvm-svn: 192992
* Revert commit r192299 until find a way to account for simlinks in OS X.Ariel J. Bernal2013-10-091-10/+4
| | | | llvm-svn: 192313
* This patch fixes replacements that are not applied when relative paths areAriel J. Bernal2013-10-091-7/+12
| | | | | | | | | | specified. In particular it makes sure that relative paths for non-virtual files aren't made absolute. Added unittest test. llvm-svn: 192299
* Fixed replacements for files with relative paths are not applied.Ariel J. Bernal2013-10-011-1/+12
| | | | | | | | Replacements were no applied when using a compilation database with paths in the compilation command relative to the compile directory. This patch makes those paths abosulte. llvm-svn: 191776
* Adding a vector version of clang::tooling::shiftedCodePosition().Edwin Vane2013-08-271-0/+17
| | | | | | | | | During the transition of clang::tooling::Replacements from std::set to std::vector, functions such as clang::tooling::applyAllReplacements() have been duplicated to take a std::vector<Replacement>. Applying this same temporary duplication to clang::tooling::shiftedCodePosition(). llvm-svn: 189358
* Tweak Replacement comparisonsEdwin Vane2013-08-161-13/+14
| | | | | | | | * Introduce operator< to replace Replacement::Less * Make operator== and operator< on Replacements non-member functions * Change order of comparisons in operator< to do string comparisons last llvm-svn: 188550
* Adding a vector version of tooling::applyAllReplacementsEdwin Vane2013-08-131-0/+17
| | | | | | | | | | | One day soon, tooling::Replacements will be changed from being implemented as an std::set to being implemented as an std::vector. Until then, some new code using vectors of Replacements would enjoy having a version of applyAllReplacements that takes a vector. Differential Revision: http://llvm-reviews.chandlerc.com/D1380 llvm-svn: 188295
* Fixing a conflict detection bug in tooling::deduplicateEdwin Vane2013-08-131-2/+3
| | | | | | | | If a Replacment is contained within the conflict range being built, the conflict range would be erroneously shortened. Now fixed. Tests updated to catch this case. llvm-svn: 188287
* Introduce Replacement deduplication and conflict detection functionEdwin Vane2013-08-081-0/+44
| | | | | | | | | | Summary: This patch adds tooling::deduplicate() which removes duplicates from and looks for conflicts in a vector of Replacements. Differential Revision: http://llvm-reviews.chandlerc.com/D1314 llvm-svn: 187979
* Constify Replacements parameter to applyAllReplacements.David Blaikie2013-07-171-4/+4
| | | | | | | | http://llvm-reviews.chandlerc.com/D1169 Patch by Guillaume Papin. llvm-svn: 186526
* Update for llvm API change.Rafael Espindola2013-07-161-2/+2
| | | | llvm-svn: 186448
* Let clang-format move the cursor appropriately.Daniel Jasper2013-05-211-0/+13
| | | | | | | | | With this patch, clang-format will try to keep the cursor at the original code position in editor integrations (implemented for emacs and vim). This means, after formatting, clang-format will try to keep the cursor on the same character of the same token. llvm-svn: 182373
* Add a more convenient interface to use clang-format.Daniel Jasper2013-05-161-13/+44
| | | | | | | | | | | | It turns out that several implementations go through the trouble of setting up a SourceManager and Lexer and abstracting this into a function makes usage easier. Also abstracts SourceManager-independent ranges out of tooling::Refactoring and provides a convenience function to create them from line ranges. llvm-svn: 181997
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-7/+7
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Allow RefactoringTool to write to memory instead of always to diskEdwin Vane2013-01-111-29/+34
| | | | | | | | | | | | | | | RefactoringTool::run() always writes the result of rewrites to disk. Instead, make this optional and provide a method for getting the refactoring results in a memory buffer instead. Also made ClangTool polymorphic so RefactoringTool could inherit from it to properly express the IS-A relationship. This change also provides access to ClangTool's public interface, e.g. mapVirtualFile() which is important once refactored buffers start living in memory instead of on disk. Reviewers: klimek llvm-svn: 172219
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-231-5/+4
| | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
* Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.Ted Kremenek2012-09-011-1/+1
| | | | | | | This is similar to how we divide up the StaticAnalyzer libraries to separate core functionality to what is clearly associated with Frontend actions. llvm-svn: 163050
* Adds a toString method to Replacement, which helps debugging.Manuel Klimek2012-05-301-0/+8
| | | | | | Adds missing header guards to Refactoring.h. llvm-svn: 157694
* Adds the Refactoring library, which is a layer on top of the Tooling libraryManuel Klimek2012-05-231-0/+178
that allows easy refactoring across translation units. llvm-svn: 157331
OpenPOWER on IntegriCloud