summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unnecessary const&s; NFCGeorge Burgess IV2019-05-233-3/+3
| | | | | | | | | It's uncommon to rely on temporary lifetime extension when having a regular, non-`const&` value behaves identically. Since `Twine::str` and `buildFixMsgForStringFlag` both return regular `std::string`s, there's seemingly no point in having `const&` here. llvm-svn: 361457
* [clang-tidy] Add support for writing a check as a Transformer rewrite rule.Yitzhak Mandelbaum2019-05-225-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | This revision introduces an adaptor from Transformer's rewrite rules (`clang::tooling::RewriteRule`) to `ClangTidyCheck`. For example, given a RewriteRule `MyCheckAsRewriteRule`, it lets one define a tidy check as follows: ``` class MyTidyCheck : public TransformerClangTidyCheck { public: MyTidyCheck(StringRef Name, ClangTidyContext *Context) : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {} }; ``` Reviewers: aaron.ballman Subscribers: mgorny, xazax.hun, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D61386 llvm-svn: 361418
* [clangd] improve help message for limit-resultsKadir Cetinkaya2019-05-221-1/+1
| | | | | | | | | | | | | | | | | | Summary: Make it clear that the default is 100. Patch by Brennan Vincent(@umanwizard)! Reviewers: #clang-tools-extra, kadircet Reviewed By: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61865 llvm-svn: 361388
* [clang-tidy] remove default header-filter for run-clang-tidyDon Hinton2019-05-221-3/+0
| | | | | | | | | | | | | | | | | | | | | | Summary: run-clang-tidy.py was enforcing '-header-filter' parameter with an unfortunate default value when none was given. Thus, leading to overwritten clang-tidy configuration (e.g. from .clang-tidy). This change removes the default value for '-header-filter' resulting in the default behaviour of clang-tidy itself. Fixes PR#41426 Reviewed By: hintonda Patch by Torbjörn Klatt! Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61747 llvm-svn: 361344
* [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag ↵Sam McCall2019-05-215-27/+49
| | | | | | | | | | | | | | to force it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62135 llvm-svn: 361258
* [clangd] Add tweak to convert normal to raw string literal, when it contains ↵Sam McCall2019-05-213-3/+139
| | | | | | | | | | | | | | escapes. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62151 llvm-svn: 361252
* [clang-tidy] New option for misc-throw-by-value-catch-by-referenceAdam Balogh2019-05-214-2/+38
| | | | | | | | | | | | | | Catching trivial objects by value is not dangerous but may be inefficient if they are too large. This patch adds an option `WarnOnLargeObject` to the checker to also warn if such an object is caught by value. An object is considered as "large" if its size is greater than `MaxSize` which is another option. Default value is the machine word of the architecture (size of the type `size_t`). Differential Revision: https://reviews.llvm.org/D61851 llvm-svn: 361225
* [clangd] Make it possible to use VFS from parsing for getting tidy optionsIlya Biryukov2019-05-203-10/+29
| | | | | | | | | | | | | | | | | | | Summary: To give an option for clangd embedders with snapshotted filesystem to read config files from exact snapshots, possibly loosing some performance from caching capabilities of the current implementations. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62143 llvm-svn: 361178
* Disable the modernize-use-trailing-return-type.cpp test in C++2a modeDmitri Gribenko2019-05-201-1/+3
| | | | | | It is performing a use-of-uninitialized-value, as detected by MSan. llvm-svn: 361163
* [clangd] Fix naming warning from clang-tidy. NFCIlya Biryukov2019-05-201-5/+2
| | | | | | Also remove newlines and braces. llvm-svn: 361147
* [clang-tidy] Sort this list alphabeticallyTamas Zolnai2019-05-201-2/+2
| | | | llvm-svn: 361138
* Run ClangTidy tests in all C++ language modesDmitri Gribenko2019-05-20141-210/+282
| | | | | | | | | | | | | | | | | | | | | | | Summary: I inspected every test and did one of the following: - changed the test to run in all language modes, - added a comment explaining why the test is only applicable in a certain mode, - limited the test to language modes where it passes and added a FIXME to fix the checker or the test. Reviewers: alexfh, lebedev.ri Subscribers: nemanjai, kbarton, arphaman, jdoerfert, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62125 llvm-svn: 361131
* [clangd] Respect WarningsAsErrors configuration for clang-tidyFangrui Song2019-05-196-18/+70
| | | | | | | | | | | | This completes the fix for https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D61841 llvm-svn: 361113
* [clangd] Respect clang-tidy suppression commentsFangrui Song2019-05-196-13/+112
| | | | | | | | | | | | This partially fixes https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D60953 llvm-svn: 361112
* [Lex] Allow to consume tokens while preprocessingIlya Biryukov2019-05-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: By adding a hook to consume all tokens produced by the preprocessor. The intention of this change is to make it possible to consume the expanded tokens without re-runnig the preprocessor with minimal changes to the preprocessor and minimal performance penalty when preprocessing without recording the tokens. The added hook is very low-level and reconstructing the expanded token stream requires more work in the client code, the actual algorithm to collect the tokens using this hook can be found in the follow-up change. Reviewers: rsmith Reviewed By: rsmith Subscribers: eraman, nemanjai, kbarton, jsji, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59885 llvm-svn: 361007
* [clang-tidy] Removed superfluous and slightly annoying newlines in ↵Jonas Toth2019-05-161-2/+2
| | | | | | | | | | | | | | | | | | | | run-clang-tidy's output. Summary: The output of clang-tidy itself already has enough newlines, so the resulting output is more in line with the usual compiler output. Patch by svenpanne. Reviewers: alexfh, JonasToth Reviewed By: JonasToth Subscribers: JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61850 llvm-svn: 360883
* [clang-tidy] Handle member variables in readability-simplify-boolean-exprJonas Toth2019-05-162-18/+373
| | | | | | | | | | | | | | | | | - Add readability-simplify-boolean-expr test cases for member variables Fixes PR40179 Patch by LegalizeAdulthood. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: jdoerfert, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D56323 llvm-svn: 360882
* [clang-tidy] Do not list enabled checks when -quiet is given to run-clang-tidy.Jonas Toth2019-05-161-1/+6
| | | | | | | | | | | | | | | | | | Summary: When run-clang-tidy is given the -quiet flag, do not output the potentially hundreds of enabled check names at the beginning. Patch by svenpanne. Reviewers: alexfh, JonasToth Reviewed By: JonasToth Subscribers: JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61849 llvm-svn: 360869
* [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" ↵Don Hinton2019-05-155-13/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with correct attribution Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Patch by Torbjörn Klatt! Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360788
* Revert [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-155-36/+13
| | | | | | This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44) llvm-svn: 360787
* [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-155-13/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior to version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360785
* [clang-tidy] new check: bugprone-branch-cloneKristof Umann2019-05-158-0/+1393
| | | | | | | | | | | | | Implement a check for detecting if/else if/else chains where two or more branches are Type I clones of each other (that is, they contain identical code) and for detecting switch statements where two or more consecutive branches are Type I clones of each other. Patch by Donát Nagy! Differential Revision: https://reviews.llvm.org/D54757 llvm-svn: 360779
* [clang-tidy] Fix invalid fixit for ↵Matthias Gehre2019-05-142-0/+29
| | | | | | | | | | | | | | | | | | | readability-static-accessed-through-instance (bug 40544) Summary: Fixed https://bugs.llvm.org/show_bug.cgi?id=40544 Before, we would generate a fixit like `(anonymous namespace)::Foo::fun();` for the added test case. Reviewers: aaron.ballman, alexfh, xazax.hun Subscribers: rnkovacs, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D61874 llvm-svn: 360698
* [clang-tidy] readability-redundant-declaration: fix false positive with C ↵Matthias Gehre2019-05-133-2/+49
| | | | | | | | | | | | | | | | | | | "extern inline" Summary: readability-redundant-declaration was diagnosing a redundant declaration on "extern inline void f();", which is needed in C code to force an external definition of the inline function f. (This is different to how inline behaves in C++). Reviewers: alexfh, danielmarjamaki Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61700 llvm-svn: 360613
* [clang-tidy] new check: bugprone-unhandled-self-assignmentTamas Zolnai2019-05-128-0/+842
| | | | | | | | | | | | | | | | | | | | | Summary: This check searches for copy assignment operators which might not handle self-assignment properly. There are three patterns of handling a self assignment situation: self check, copy-and-swap or the less common copy-and-move. The new check warns if none of these patterns is found in a user defined implementation. See also: OOP54-CPP. Gracefully handle self-copy assignment https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP54-CPP.+Gracefully+handle+self-copy+assignment Reviewers: JonasToth, alexfh, hokein, aaron.ballman Subscribers: riccibruno, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D60507 llvm-svn: 360540
* Removing an unused member variable; NFC.Aaron Ballman2019-05-101-4/+2
| | | | llvm-svn: 360451
* [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'Don Hinton2019-05-1012-54/+85
| | | | | | | | | | | | | | | | | | | | | | | Summary: Change the namespace for llvm checkers from 'llvm' to 'llvm_check', and modify add_new_check.py and rename_check.py to support the new namespace. Checker, file, and directory names remain unchanged. Used new version of rename_check.py to make the change in existing llvm checkers, but had to fix LLVMTidyModule.cpp and LLVMModuleTest.cpp by hand. The changes made by rename_check.py are idempotent, so if accidentally run multiple times, it won't do anything. Reviewed By: aaron.ballman Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D60629 llvm-svn: 360450
* Recommit r360345 with fixes (was reverted in r360348).Aaron Ballman2019-05-108-0/+1184
| | | | | | | | Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types. Patch by Bernhard Manfred Gruber. llvm-svn: 360438
* check_clang_tidy.py now passes `-format-style=none` to clang_tidyDmitri Gribenko2019-05-091-7/+19
| | | | | | | | | | | | | | | | | Summary: If the test does not specify a formatting style, force "none"; otherwise autodetection logic can discover a ".clang-tidy" file that is not related to the test. Reviewers: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61739 llvm-svn: 360358
* [clangd] Bump index version and get rid of wrong assertionKadir Cetinkaya2019-05-092-2/+4
| | | | | | | | | | | | | | | | | | | | Summary: After rL360344, BackgroundIndex expects symbols with zero refcounts. Therefore existing index files are no longer valid. Assertion regarding finding target of a reference was wrong, since background-index might still be going on or we might've loaded only some part of the shards and might be missing the declaring shards for the symbol. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61734 llvm-svn: 360349
* Revert r360345 and r360346, as they are not passing the testbots.Aaron Ballman2019-05-098-1183/+0
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio llvm-svn: 360348
* Fixing a link in the release notes to appease the Sphinx bot.Aaron Ballman2019-05-091-2/+2
| | | | llvm-svn: 360346
* Add the modernize-use-trailing-return check to rewrite function signatures ↵Aaron Ballman2019-05-098-0/+1183
| | | | | | | | to use trailing return types. Patch by Bernhard Manfred Gruber. llvm-svn: 360345
* [clangd] Count number of references while merging RefSlabs inside FileIndexKadir Cetinkaya2019-05-097-33/+104
| | | | | | | | | | | | | | | | | | | | | | | Summary: For counting number of references clangd was relying on merging every duplication of a symbol. Unfortunately this does not apply to FileIndex(and one of its users' BackgroundIndex), since we get rid of duplication by simply dropping symbols coming from non-canonical locations. So only one or two(coming from canonical declaration header and defined source file, if exists) replications of the same symbol reaches merging step. This patch changes reference counting logic to rather count number of different RefSlabs a given SymbolID exists. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, mgrang, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59481 llvm-svn: 360344
* [clangd] Fix a TSAN warning in TUSchedulerTestsIlya Biryukov2019-05-091-2/+6
| | | | llvm-svn: 360336
* Fix gcc compilation warning in test case [NFC]Mikael Holmen2019-05-091-1/+1
| | | | | | | | | | Without this, gcc (7.4) complains with ../tools/clang/tools/extra/clangd/unittests/PrintASTTests.cpp:99:28: error: ISO C++11 requires at least one argument for the "..." in a variadic macro [-Werror] }))); ^ llvm-svn: 360334
* [clangd] Use AsyncTaskRunner in BackgroundIndex instead of std::threadIlya Biryukov2019-05-092-6/+7
| | | | | | | | | | | | | | | | | | Summary: To unify the way we create threads in clangd. This should simplify landing D50993. Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61724 llvm-svn: 360332
* [clang-tidy] Update documentation on ReSharper integration.Artem Dergachev2019-05-081-1/+1
| | | | | | | | | | It's now possible to set custom clang-tidy binary. Patch by Alexander Zaitsev! Differential Revision: https://reviews.llvm.org/D61475 llvm-svn: 360277
* Documentation for bugprone-inaccurate-erase: added an example of a bug that ↵Dmitri Gribenko2019-05-081-0/+16
| | | | | | | | | | | | | | this checker catches Reviewers: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61644 llvm-svn: 360247
* [clang-tidy] Do not show incorrect fix in modernize-make-uniqueIlya Biryukov2019-05-082-2/+11
| | | | | | | | | | | | | | | | | | Summary: The case when initialize_list hides behind an implicit case was not handled before. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61642 llvm-svn: 360231
* [clangd] Introduce intermediate representation of formatted textIlya Biryukov2019-05-075-0/+388
| | | | | | | | | | | | | | | | Summary: That can render to markdown or plain text. Used for findHover requests. Reviewers: malaperle, sammccall, kadircet Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58547 llvm-svn: 360151
* [clangd] Oops, switchSourceHeader still needs to return a URI.Sam McCall2019-05-072-3/+3
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61630 llvm-svn: 360121
* [clangd] switchSourceHeader uses null not empty string as sentinel.Sam McCall2019-05-072-5/+8
| | | | | | As far as I can see, only theia actually implements this, and it expects null. llvm-svn: 360119
* [clangd] Add test that r360116 accidentally fixed a duplicate-edits bug in ↵Sam McCall2019-05-072-20/+67
| | | | | | rename. NFC llvm-svn: 360118
* [clangd] Move Rename into its own file, and add unit test. NFCSam McCall2019-05-078-79/+164
| | | | | | | | | | | | Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61596 llvm-svn: 360116
* [clangd] add CLANG_ENABLE_CLANGD option to build clangd. Require threads.Sam McCall2019-05-071-1/+8
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61518 llvm-svn: 360115
* [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to ↵Adam Balogh2019-05-072-2/+21
| | | | | | | | | | | | structures) Accidentally taking the size of a struct-pointer type or a value of this type is more common than explicitly using the & operator for the value. This patch extends the check to include these cases. Differential Revision: https://reviews.llvm.org/D61260 llvm-svn: 360114
* [clangd] Expose whether no-compile completion was used.Sam McCall2019-05-063-0/+7
| | | | | | | | | | | | | | Summary: Embedding clients want to experiment with showing such results in e.g. a different color. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61588 llvm-svn: 360039
* [clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse ↵Adam Balogh2019-05-062-2/+84
| | | | | | | | | | | | | | | in pointer arithmetic Some programmers tend to forget that subtracting two pointers results in the difference between them in number of elements of the pointee type instead of bytes. This leads to codes such as `size_t size = (p - q) / sizeof(int)` where `p` and `q` are of type `int*`. Or similarily, `if (p - q < buffer_size * sizeof(int)) { ... }`. This patch extends `bugprone-sizeof-expression` to detect such cases. Differential Revision: https://reviews.llvm.org/D61422 llvm-svn: 360032
* [clangd] Boost code completion results that were named in the last few lines.Sam McCall2019-05-0610-6/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The hope is this will catch a few patterns with repetition: SomeClass* S = ^SomeClass::Create() int getFrobnicator() { return ^frobnicator_; } // discard the factory, it's no longer valid. ^MyFactory.reset(); Without triggering antipatterns too often: return Point(x.first, x.^second); I'm going to gather some data on whether this turns out to be a win overall. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61537 llvm-svn: 360030
OpenPOWER on IntegriCloud