summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
Commit message (Collapse)AuthorAgeFilesLines
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-1/+1
|
* Remove \brief commands from doxygen comments.Dmitri Gribenko2019-08-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
* [clang-tools-extra] Adopt FileManager's error-returning APIsHarlan Haskins2019-08-011-3/+3
| | | | | | | | The FileManager has been updated to return llvm::ErrorOr from getFile and getDirectory, this commit updates all the callers of those APIs from clang. llvm-svn: 367617
* [clang-tidy] Add fix descriptions to clang-tidy checks.Haojian Wu2019-04-171-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Motivation/Context: in the code review system integrating with clang-tidy, clang-tidy doesn't provide a human-readable description of the fix. Usually developers have to preview a code diff (before vs after apply the fix) to understand what the fix does before applying a fix. This patch proposes that each clang-tidy check provides a short and actional fix description that can be shown in the UI, so that users can know what the fix does without previewing diff. This patch extends clang-tidy framework to support fix descriptions (will add implementations for existing checks in the future). Fix descriptions and fixes are emitted via diagnostic::Note (rather than attaching the main warning diagnostic). Before this patch: ``` void MyCheck::check(...) { ... diag(loc, "my check warning") << FixtItHint::CreateReplacement(...); } ``` After: ``` void MyCheck::check(...) { ... diag(loc, "my check warning"); // Emit a check warning diag(loc, "fix description", DiagnosticIDs::Note) << FixtItHint::CreateReplacement(...); // Emit a diagnostic note and a fix } ``` Reviewers: sammccall, alexfh Reviewed By: alexfh Subscribers: MyDeveloperDay, Eugene.Zelenko, aaron.ballman, JonasToth, xazax.hun, jdoerfert, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59932 llvm-svn: 358576
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* Deduplicate replacements from diagnostics.Eric Liu2018-09-251-4/+15
| | | | | | | | | | | | | | | | | | | Summary: After r329813, clang-apply-replacements stopped deduplicating identical replacements; however, tools like clang-tidy relies on the deduplication of identical dignostics replacements from different TUs to apply fixes correctly. This change partially roll back the behavior by deduplicating changes from diagnostics. Ideally, we should deduplicate on diagnostics level, but we need to figure out an effecient way. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52264 llvm-svn: 342951
* [clang-apply-replacements] Convert tooling::Replacements to ↵Malcolm Parsons2018-04-111-241/+90
| | | | | | | | | | | | | | | | | | | | tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting. Summary: By converting Replacements by AtomicChange, clang-apply-replacements is able like clang-tidy to automatically cleanup and format changes. This should permits to close this ticket: https://bugs.llvm.org/show_bug.cgi?id=35051 and attempt to follow hints from https://reviews.llvm.org/D43500 comments. Reviewers: klimek, ioeric Reviewed By: ioeric Subscribers: malcolm.parsons, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D43764 Patch by Jeremy Demeule. llvm-svn: 329813
* [clang-tidy] clang-apply-replacements: Don't insert null entryKevin Funk2017-07-251-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: [clang-tidy] clang-apply-replacements: Don't insert null entry Fix crash when running clang-apply-replacements on YML files which contain an invalid file path. Make sure we never add a nullptr into the map. The previous code started adding nullptr to the map after the first warnings via errs() has been emitted. Backtrace: ``` Starting program: /home/kfunk/devel/build/llvm/bin/clang-apply-replacements /tmp/tmpIqtp7m [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Described file '.moc/../../../../../../src/qt5.8/qtremoteobjects/src/remoteobjects/qremoteobjectregistrysource_p.h' doesn't exist. Ignoring... ... Program received signal SIGSEGV, Segmentation fault. main (argc=<optimized out>, argv=<optimized out>) at /home/kfunk/devel/src/llvm/tools/clang/tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:262 (gdb) p FileAndReplacements.first $1 = (const clang::FileEntry *) 0x0 (gdb) ``` Added tests. Before patch: ``` ******************** TEST 'Clang Tools :: clang-apply-replacements/invalid-files.cpp' FAILED ******************** Script: -- mkdir -p /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files clang-apply-replacements /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files ls -1 /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files | FileCheck /home/kfunk/devel/src/llvm/tools/clang/tools/extra/test/clang-apply-replacements/invalid-files.cpp --check-prefix=YAML -- Exit Code: 139 Command Output (stderr): -- Described file 'idonotexist.h' doesn't exist. Ignoring... /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/invalid-files.cpp.script: line 4: 9919 Segmentation fault clang-apply-replacements /home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply- replacements/Output/Inputs/invalid-files -- ``` After Patch: ``` PASS: Clang Tools :: clang-apply-replacements/invalid-files.cpp (5 of 6) ``` Reviewers: alexfh, yawanng Reviewed By: alexfh Subscribers: cfe-commits, klimek, JDevlieghere, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D35194 llvm-svn: 308974
* [clang-tidy] Add check name to YAML export (clang-tools-extra part)Alexander Kornienko2017-01-031-2/+76
| | | | | | | | | | | | Add a field indicating the associated check for every replacement to the YAML report generated with the '-export-fixes' option. Update clang-apply-replacements to handle the new format. Patch by Alpha Abdoulaye! Differential revision: https://reviews.llvm.org/D26137 llvm-svn: 290893
* modernize-use-auto NFC fixesPiotr Padlewski2016-12-141-5/+2
| | | | llvm-svn: 289656
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-9/+5
| | | | | | | | | | | | | | | | 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
* Fix clang-tools-extra build after r283815 (Store FileEntry::Filename as a ↵Mehdi Amini2016-10-101-1/+1
| | | | | | StringRef instead of raw pointer) llvm-svn: 283819
* Changes related to new implementation of tooling::Replacements as class.Eric Liu2016-08-011-2/+77
| | | | | | | | | | | | 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
* Fix test failure introduced by r253859. I believe that the new behaviorDaniel Jasper2015-11-231-6/+3
| | | | | | | | | in r253859 makes sense in many cases and thus, I have fixed the implementation of calculateChangedRanges instead. It had a FIXME anyway saying that it was unecessarily using shiftedCodePosition which resulted in O(N^2) runtime. llvm-svn: 253929
* Refactor: Simplify boolean conditional return statements in ↵Alexander Kornienko2015-11-051-4/+1
| | | | | | | | | | clang-apply-replacements Differential revision: http://reviews.llvm.org/D10025 Patch by Richard Thomson! llvm-svn: 252207
* clang-tools-extra: Appease PR24881. [-Wdocumentation]NAKAMURA Takumi2015-09-191-1/+2
| | | | | | \returns doesn't accept \li, but \parblock \li. llvm-svn: 248080
* clang-apply-replacements: For-rangify.Benjamin Kramer2014-09-091-24/+16
| | | | | | No functionality change. llvm-svn: 217442
* clang-apply-replacements: Deduplicate paths with FileManager.Benjamin Kramer2014-09-091-30/+25
| | | | | | | | Bucket replacements by FileEntry instead of path. The same file with different paths is very common, relative #include paths and symlinks can easily create them. When that occurs we would apply the fix twice. llvm-svn: 217440
* Update for LLVM api changeRafael Espindola2014-08-251-5/+4
| | | | llvm-svn: 216396
* Update for llvm api change.Rafael Espindola2014-07-061-4/+4
| | | | llvm-svn: 212406
* Prefix error_code with std.Rafael Espindola2014-06-121-4/+3
| | | | llvm-svn: 210840
* Quick build fix.Rafael Espindola2014-06-121-0/+1
| | | | llvm-svn: 210838
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210776
* [C++11] Use 'nullptr'.Craig Topper2014-06-091-1/+1
| | | | llvm-svn: 210447
* [C++11] Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-091-1/+1
| | | | | | | | This removes all references to OwningPtr, which should be fairly undisruptive to out-of-tree projects since they are unlikely to use clang-tools-extra as a library instead of a set of tools. llvm-svn: 203382
* Update for llvm api change.Rafael Espindola2014-02-241-1/+1
| | | | llvm-svn: 202055
* Update for llvm api change.Rafael Espindola2014-02-241-1/+1
| | | | llvm-svn: 202045
* Fix the build after r195016.Alexander Kornienko2013-11-181-2/+1
| | | | llvm-svn: 195020
* clang-apply-replacements: Add code formatting functionalityEdwin Vane2013-09-301-1/+27
| | | | | | | | | | | | | | The tool now supports a collection of arguments to turn on and provide settings for the formatting of code affected by applying replacements: * --format turns on formatting (default style is LLVM) * --style controls code style settings * --style-config allows one to explicitly indicate where a style config file lives. The libclangApplyReplacements interface has a new function to turn Replacements into Ranges to be used with tooling::reformat(). llvm-svn: 191667
* Rename clang-replace -> clang-apply-replacementsEdwin Vane2013-09-031-0/+254
Made changes throughout clang-tools-extra for the renaming of clang-replace to clang-apply-replacements as per feedback from community. llvm-svn: 189832
OpenPOWER on IntegriCloud