summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Avoid inconsistent notes in readability-container-size-emptyAlexander Kornienko2018-11-272-2/+15
| | | | | | | | | When a warning is issued in a template instantiation, the check would previously use template arguments in a note, which would result in inconsistent or duplicate warnings (depending on how deduplication was done). This patch removes template arguments from the note. llvm-svn: 347652
* [clang-tidy] Minor fixes in a testAlexander Kornienko2018-11-271-8/+8
| | | | | | | Use CHECK-FIXES where it was intended instead of CHECK-MESSAGES. Fixed compiler warnings to pacify YouCompleteMe. llvm-svn: 347651
* [clangd] NFC: Prefer `isa<>` to `dyn_cast<>` to do the checking.Henry Wong2018-11-271-2/+2
| | | | | | | | | | | | | | Summary: Prefer `isa<>` to `dyn_cast<>` when there only need a checking. Reviewers: ilya-biryukov, MaskRay Reviewed By: ilya-biryukov, MaskRay Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits, MTC Differential Revision: https://reviews.llvm.org/D54878 llvm-svn: 347635
* [clangd] Do not drop diagnostics from macrosIlya Biryukov2018-11-262-2/+25
| | | | | | if they still end up being in the main file. llvm-svn: 347574
* [clang-tidy] Improving narrowing conversionsGuillaume Chatelet2018-11-269-66/+988
| | | | | | | | | | | | | | | | | | | | | Summary: Newly flagged narrowing conversions: - integer to narrower signed integer (this is compiler implementation defined), - integer - floating point narrowing conversions, - floating point - integer narrowing conversions, - constants with narrowing conversions (even in ternary operator). Reviewers: hokein, alexfh, aaron.ballman, JonasToth Reviewed By: aaron.ballman, JonasToth Subscribers: lebedev.ri, courbet, nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53488 llvm-svn: 347570
* [clangd] Enable auto-index behind a flag.Sam McCall2018-11-2615-22/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Ownership and configuration: The auto-index (background index) is maintained by ClangdServer, like Dynamic. (This means ClangdServer will be able to enqueue preamble indexing in future). For now it's enabled by a simple boolean flag in ClangdServer::Options, but we probably want to eventually allow injecting the storage strategy. New 'sync' command: In order to meaningfully test the integration (not just unit-test components) we need a way for tests to ensure the asynchronous index reads/writes occur before a certain point. Because these tests and assertions are few, I think exposing an explicit "sync" command for use in tests is simpler than allowing threading to be completely disabled in the background index (as we do for TUScheduler). Bugs: I fixed a couple of trivial bugs I found while testing, but there's one I can't. JSONCompilationDatabase::getAllFiles() may return relative paths, and currently we trigger an assertion that assumes they are absolute. There's no efficient way to resolve them (you have to retrieve the corresponding command and then resolve against its directory property). In general I think this behavior is broken and we should fix it in JSONCompilationDatabase and require CompilationDatabase::getAllFiles() to be absolute. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54894 llvm-svn: 347567
* [clangd] Fix compilation of IndexBenchmarkIlya Biryukov2018-11-261-2/+2
| | | | llvm-svn: 347566
* [clangd] Fix use-after-free with expected types in indexingIlya Biryukov2018-11-261-2/+4
| | | | llvm-svn: 347563
* [clangd] Add type boosting in code completionIlya Biryukov2018-11-264-2/+43
| | | | | | | | | | | | Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52276 llvm-svn: 347562
* [clangd] Collect and store expected types in the indexIlya Biryukov2018-11-264-1/+15
| | | | | | | | | | | | | | | | | | | | Summary: And add a hidden option to control whether the types are collected. For experiments, will be removed when expected types implementation is stabilized. The index size is almost unchanged, e.g. the YAML index for all clangd sources increased from 53MB to 54MB. Reviewers: ioeric, sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52274 llvm-svn: 347560
* [clangd] Initial implementation of expected typesIlya Biryukov2018-11-265-0/+304
| | | | | | | | | | | | | | | | | Summary: Provides facilities to model the C++ conversion rules without the AST. The introduced representation can be stored in the index and used to implement type-based ranking improvements for index-based completions. Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: malaperle, mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52273 llvm-svn: 347559
* [clangd] Fix missing include from r347538 - fix windows buildbotsSam McCall2018-11-261-0/+1
| | | | llvm-svn: 347554
* [clang-tidy] No warning for auto new expression in smart checkHaojian Wu2018-11-262-0/+6
| | | | | | | | | | | | Summary: The fix for `auto` new expression is illegal. Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54832 llvm-svn: 347551
* [clangd] Tune down scope boost for global scopeEric Liu2018-11-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This improves cross-namespace completions and has ignorable impact on other completion types. Metrics ``` ================================================================================================== OVERALL (excl. CROSS_NAMESPACE) ================================================================================================== Total measurements: 109367 (-6) All measurements: MRR: 68.11 (+0.04) Top-1: 58.59% (+0.03%) Top-5: 80.00% (+0.01%) Top-100: 95.92% (-0.02%) Full identifiers: MRR: 98.35 (+0.09) Top-1: 97.87% (+0.17%) Top-5: 98.96% (+0.01%) Top-100: 99.03% (+0.00%) Filter length 0-5: MRR: 23.20 (+0.05) 58.72 (+0.01) 70.16 (-0.03) 73.44 (+0.03) 76.24 (+0.00) 80.79 (+0.14) Top-1: 11.90% (+0.03%) 45.07% (+0.03%) 58.49% (-0.05%) 62.44% (-0.02%) 66.31% (-0.05%) 72.10% (+0.07%) Top-5: 35.51% (+0.08%) 76.94% (-0.01%) 85.10% (-0.13%) 87.40% (-0.02%) 88.65% (+0.01%) 91.84% (+0.17%) Top-100: 83.25% (-0.02%) 96.61% (-0.15%) 98.15% (-0.02%) 98.43% (-0.01%) 98.53% (+0.01%) 98.66% (+0.02%) ================================================================================================== CROSS_NAMESPACE ================================================================================================== Total measurements: 17702 (+27) All measurements: MRR: 28.12 (+3.26) Top-1: 21.07% (+2.70%) Top-5: 35.11% (+4.48%) Top-100: 74.31% (+1.02%) Full identifiers: MRR: 79.20 (+3.72) Top-1: 71.78% (+4.86%) Top-5: 88.39% (+2.84%) Top-100: 98.99% (+0.00%) Filter length 0-5: MRR: 0.92 (-0.10) 5.51 (+0.57) 18.30 (+2.34) 21.62 (+3.76) 32.00 (+6.00) 41.55 (+7.61) Top-1: 0.56% (-0.08%) 2.44% (+0.15%) 9.82% (+1.47%) 12.59% (+2.16%) 21.17% (+4.47%) 30.05% (+6.72%) Top-5: 1.20% (-0.15%) 7.14% (+1.04%) 25.17% (+3.91%) 29.74% (+5.90%) 43.29% (+9.59%) 54.75% (+9.79%) Top-100: 5.49% (-0.01%) 56.22% (+2.59%) 86.69% (+1.08%) 89.03% (+2.04%) 93.74% (+0.78%) 96.99% (+0.59%) ``` Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54851 llvm-svn: 347548
* [clangd] Use testPath in the test.Haojian Wu2018-11-261-2/+2
| | | | llvm-svn: 347547
* [clang-tidy] PrintStackTraceOnErrorSignalAlexander Kornienko2018-11-261-0/+2
| | | | llvm-svn: 347546
* [clangd] Cleanup after landing documentSymbol. NFCIlya Biryukov2018-11-262-5/+6
| | | | | | | | - fix compile error on older gcc in Protocol.cpp, - remove redundant 'llvm::' qualifiers from Protocol.cpp, - remove unused variables in AST.cpp llvm-svn: 347539
* [clangd] Auto-index watches global CDB for changes.Sam McCall2018-11-269-61/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of receiving compilation commands, auto-index is triggered by just filenames to reindex, and gets commands from the global comp DB internally. This has advantages: - more of the work can be done asynchronously (fetching compilation commands upfront can be slow for large CDBs) - we get access to the CDB which can be used to retrieve interpolated commands for headers (useful in some cases where the original TU goes away) - fits nicely with the filename-only change observation from r347297 The interface to GlobalCompilationDatabase gets extended: when retrieving a compile command, the GCDB can optionally report the project the file belongs to. This naturally fits together with getCompileCommand: it's hard to implement one without the other. But because most callers don't care, I've ended up with an awkward optional-out-param-in-virtual method pattern - maybe there's a better one. This is the main missing integration point between ClangdServer and BackgroundIndex, after this we should be able to add an auto-index flag. Reviewers: ioeric, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D54865 llvm-svn: 347538
* [clang-tidy] Don't generate incorrect fixes for class with deleted copy ↵Haojian Wu2018-11-262-0/+72
| | | | | | | | | | | | | | | | | constructor in smart_ptr check. Summary: The fix for aggregate initialization (`std::make_unique<Foo>(Foo {1, 2})` needs to see Foo copy constructor, otherwise we will have a compiler error. So we only emit the check warning. Reviewers: JonasToth, aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54745 llvm-svn: 347537
* A bit of AST matcher cleanup, NFC.Alexander Kornienko2018-11-2528-221/+198
| | | | | | | | | Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). llvm-svn: 347520
* [clangd] Add 'Switch header/source' command in clangd-vscodeMarc-Andre Laperle2018-11-242-5/+42
| | | | | | | | | | | | | | | | | Summary: Alt+o is used on Windows/Linux and Option+Cmd+o on macOS. Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com> Reviewers: hokein, ilya-biryukov, ioeric Reviewed By: ioeric Subscribers: sammccall, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54781 llvm-svn: 347509
* [clangd] Add support for hierarchical documentSymbolIlya Biryukov2018-11-2314-161/+457
| | | | | | | | | | | | Reviewers: ioeric, sammccall, simark Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52311 llvm-svn: 347498
* Remove the optional dependency from libclang to clang-tidy/include-fixerBenjamin Kramer2018-11-232-26/+0
| | | | | | | clangd does a better job on both of these, so don't slow down everyone's build for a poorly working libclang feature. llvm-svn: 347496
* [clang-tidy] Ignore matches in template instantiations (cert-dcl21-cpp)Alexander Kornienko2018-11-231-1/+2
| | | | | | | | The test fails with a local modification to clang-tidy/ClangTidyDiagnosticConsumer.cpp to include fixes into the key when deduplicating the warnings. llvm-svn: 347495
* [clangd] Cleanup: make the diags callback global in TUSchedulerIlya Biryukov2018-11-225-137/+182
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54760 llvm-svn: 347474
* [clangd] Cleanup error consumption code. NFCIlya Biryukov2018-11-224-47/+18
| | | | | | | - Remove reimplementations of llvm::consumeError. - Simplify test code by using EXPECT_ERROR where it fits. llvm-svn: 347472
* [clang-tidy] Ignore template instantiations in modernize-use-usingAlexander Kornienko2018-11-222-1/+23
| | | | | | | | | | The test I'm adding passes without the change due to the deduplication logic in ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal integration with clang-tidy. I've verified the fix by locally changing LessClangTidyError to consider replacements. llvm-svn: 347470
* [clangd] Cleanup: make diagnostics callbacks from TUScheduler non-racyIlya Biryukov2018-11-226-41/+40
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, removeDoc followed by an addDoc to TUScheduler resulted in racy diagnostic responses, i.e. the old dianostics could be delivered to the client after the new ones by TUScheduler. To workaround this, we tracked a version number in ClangdServer and discarded stale diagnostics. After this commit, the TUScheduler will stop delivering diagnostics for removed files and the workaround in ClangdServer is not required anymore. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54829 llvm-svn: 347468
* [clangd] Cleanup: stop passing around list of supported URI schemes.Eric Liu2018-11-2226-228/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing around a list of supported URI schemes in clangd, we expose an interface to convert a path to URI using any compatible scheme that has been registered. It favors customized schemes and falls back to "file" when no other scheme works. Changes in this patch are: - URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a compatible scheme from the registry. - Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex etc). - Unit tests will use "unittest" by default. - Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only register the test scheme when lit-test or enable-lit-scheme is set. (The new flag is added to make lit protocol.test work; I wonder if there is alternative here.) Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54800 llvm-svn: 347467
* [clangd] Cleanup: use index file instead of header in workspace symbols lit ↵Eric Liu2018-11-223-8/+22
| | | | | | | | | | | | | | | | test. Summary: The full path of the input header depends on the execution environment and may result in different behavior (e.g. when different URI schemes are used). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54833 llvm-svn: 347466
* [clangd] Fix use-after-scope in unit testBenjamin Kramer2018-11-221-1/+1
| | | | | | | The scheduler holds a reference to `Proceed`, so it has to be destroyed after the scheduler. Found by asan. llvm-svn: 347460
* [clangd] Respect task cancellation in TUScheduler.Sam McCall2018-11-225-3/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - Reads are never executed if canceled before ready-to run. In practice, we finalize cancelled reads eagerly and out-of-order. - Cancelled reads don't prevent prior updates from being elided, as they don't actually depend on the result of the update. - Updates are downgraded from WantDiagnostics::Yes to WantDiagnostics::Auto when cancelled, which allows them to be elided when all dependent reads are cancelled and there are subsequent writes. (e.g. when the queue is backed up with cancelled requests). The queue operations aren't optimal (we scan the whole queue for cancelled tasks every time the scheduler runs, and check cancellation twice in the end). However I believe these costs are still trivial in practice (compared to any AST operation) and the logic can be cleanly separated from the rest of the scheduler. Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54746 llvm-svn: 347450
* Move the llvm lit test dependencies to clang-tools-extra.Haojian Wu2018-11-221-0/+11
| | | | | | | | | | | | Summary: Part of revert r343473 Reviewers: mgorny Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54798 llvm-svn: 347449
* Update call to EvaluateAsInt() to the new syntax.Bill Wendling2018-11-213-16/+23
| | | | llvm-svn: 347419
* Revert 347366, its prerequisite 347364 got reverted.Nico Weber2018-11-213-23/+16
| | | | llvm-svn: 347390
* [clang-tidy] Add a test for proper handling of locations in scratch space.Alexander Kornienko2018-11-211-0/+28
| | | | | | This test examines the behavior change of clang::tooling::Diagnostic in r347372. llvm-svn: 347373
* Update EvaluateAsInt to the new syntax.Bill Wendling2018-11-203-16/+23
| | | | llvm-svn: 347366
* [clang-tidy] Don't generate incorrect fixes for class constructed from ↵Haojian Wu2018-11-202-19/+63
| | | | | | | | | | | | | | | | | | | | | | | list-initialized arguments Summary: Currently the smart_ptr check (modernize-make-unique) generates the fixes that cannot compile for cases like below -- because brace list can not be deduced in `make_unique`. ``` struct Bar { int a, b; }; struct Foo { Foo(Bar); }; auto foo = std::unique_ptr<Foo>(new Foo({1, 2})); ``` Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54704 llvm-svn: 347315
* [clangd] Replay preamble #includes to clang-tidy checks.Sam McCall2018-11-206-22/+172
| | | | | | | | | | | | | | | | | | | | | Summary: This is needed to correctly handle checks that use IncludeInserter, which is very common. I couldn't find a totally safe example of a check to enable for testing, I picked modernize-deprecated-headers which some will probably hate. We should get configuration working... This depends on D54691 which ensures our calls to getFile(open=false) don't break subsequent accesses via the FileManager. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54694 llvm-svn: 347298
* [clangd] Allow observation of changes to global CDBs.Sam McCall2018-11-206-20/+195
| | | | | | | | | | | | | | | | | | Summary: Currently, changes *within* CDBs are not tracked (CDB has no facility to do so). However, discovery of new CDBs are tracked (all files are marked as modified). Also, files whose compilation commands are explicitly set are marked modified. The intent is to use this for auto-index. Newly discovered files will be indexed with low priority. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54475 llvm-svn: 347297
* Address comments.Kadir Cetinkaya2018-11-192-5/+7
| | | | llvm-svn: 347237
* Use digest size instead of hardcoding it.Kadir Cetinkaya2018-11-191-1/+1
| | | | llvm-svn: 347236
* [clangd] Store source file hash in IndexFile{In,Out}Kadir Cetinkaya2018-11-195-2/+51
| | | | | | | | | | | | | | Summary: Puts the digest of the source file that generated the index into serialized index and stores them back on load, if exists. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54693 llvm-svn: 347235
* Add the abseil-duration-factory-scale check.Aaron Ballman2018-11-188-0/+483
| | | | | | | | This check removes unneeded scaling of arguments when calling Abseil Time factory functions. Patch by Hyrum Wright. llvm-svn: 347163
* [clang-tidy/checks] Implement a clang-tidy check to verify Google ↵Stephane Moore2018-11-178-0/+254
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Objective-C function naming conventions 📜 Summary: §1 Description This check finds function names in function declarations in Objective-C files that do not follow the naming pattern described in the Google Objective-C Style Guide. Function names should be in UpperCamelCase and functions that are not of static storage class should have an appropriate prefix as described in the Google Objective-C Style Guide. The function `main` is a notable exception. Function declarations in expansions in system headers are ignored. Example conforming function definitions: ``` static bool IsPositive(int i) { return i > 0; } static bool ABIsPositive(int i) { return i > 0; } bool ABIsNegative(int i) { return i < 0; } ``` A fixit hint is generated for functions of static storage class but otherwise the check does not generate a fixit hint because an appropriate prefix for the function cannot be determined. §2 Test Notes * Verified clang-tidy tests pass successfully. * Used check_clang_tidy.py to verify expected output of processing google-objc-function-naming.m Reviewers: benhamilton, hokein, Wizard, aaron.ballman Reviewed By: benhamilton Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51575 llvm-svn: 347132
* [clangd] Fix crash hovering on non-decltype trailing returnMarc-Andre Laperle2018-11-172-2/+12
| | | | | | | | | | | | | | | | | | | | Summary: More specifically, hovering on "auto" in auto main() -> int { return 0; } Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com> Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54553 llvm-svn: 347119
* [clang-tidy] Expanded a test NFCAlexander Kornienko2018-11-161-8/+30
| | | | | | | Expanded the readability-inconsistent-declaration-parameter-name-macros.cpp to check notes and added a test with pasted tokens. llvm-svn: 347053
* [clangd] Truncate SymbolID to 8 bytes.Haojian Wu2018-11-163-12/+11
| | | | | | | | | | | | | | Summary: This is our goal. It has a non-zero rick, but so far we haven't see any collision (externally and internally). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54622 llvm-svn: 347044
* [clangd] Fix a compiler warning and test crashes caused in rL347038.Haojian Wu2018-11-162-1/+3
| | | | llvm-svn: 347039
* Introduce shard storage to auto-index.Kadir Cetinkaya2018-11-165-25/+275
| | | | | | | | | | | | Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: llvm-commits, mgorny, Eugene.Zelenko, ilya-biryukov, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54269 llvm-svn: 347038
OpenPOWER on IntegriCloud