summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Strip the ' [some-check-name]' suffix from clang-tidy diagnostics. ↵Sam McCall2019-04-173-8/+17
| | | | | | | | | | | | | | The check name is reported in Diagnostic.code. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60819 llvm-svn: 358612
* [clangd] Use shorter, more recognizable codes for diagnostics.Sam McCall2019-04-1710-16/+26
| | | | | | | | | | | | | | | | | | | | | Summary: - for warnings, use the flag the warning is controlled by (-Wfoo) - for errors, keep using the internal name (there's nothing better) but drop the err_ prefix This comes at the cost of uniformity, it's no longer totally obvious exactly what the code field contains. But the -Wname flags are so much more useful to end-users than the internal warn_foo that this seems worth it. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60822 llvm-svn: 358611
* [clangd] Recognize "don't include me directly" pattern, and suppress include ↵Sam McCall2019-04-173-49/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | insertion. Summary: Typically used with umbrella headers, e.g. GTK: #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) #error "Only <gtk/gtk.h> can be included directly." #endif Heuristic is fairly conservative, a quick code search over github showed a fair number of hits and few/no false positives. (Not all were umbrella headers, but I'd be happy avoiding include insertion for all of them). We may want to relax the heuristic later to catch more cases. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60815 llvm-svn: 358605
* [clang-tidy] Fix invalid location in readability-misleading-indentation ↵Alexander Kornienko2019-04-172-3/+16
| | | | | | | | | | diagnostic Before this patch readability-misleading-indentation could issue diagnostics with an invalid location, which would lead to an assertion failure in ClangTidyContext::diag() llvm-svn: 358589
* [clang-tidy] Add fix descriptions to clang-tidy checks.Haojian Wu2019-04-1720-188/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Include textual diagnostic ID as Diagnostic.code.Sam McCall2019-04-1714-33/+137
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58291 llvm-svn: 358575
* [clangd] Include insertion: require header guards, drop other heuristics, ↵Sam McCall2019-04-178-139/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | treat .def like .inc. Summary: We do have some reports of include insertion behaving badly in some codebases. Requiring header guards both makes sense in principle, and is likely to disable this "nice-to-have" feature in codebases where headers don't follow the expected pattern. With this we can drop some other heuristics, such as looking at file extensions to detect known non-headers - implementation files have no guards. One wrinkle here is #import - objc headers may not have guards because they're intended to be used via #import. If the header is the main file or is #included, we won't collect locations - merge should take care of this if we see the file #imported somewhere. Seems likely to be OK. Headers which have a canonicalization (stdlib, IWYU) are exempt from this check. *.inc files continue to be handled by looking up to the including file. This patch also adds *.def here - tablegen wants this pattern too. In terms of code structure, the division between SymbolCollector and CanonicalIncludes has shifted: SymbolCollector is responsible for more. This is because SymbolCollector has all the SourceManager/HeaderSearch access needed for checking for guards, and we interleave these checks with the *.def checks in a loop (potentially). We could hand all the info into CanonicalIncludes and put the logic there if that's preferable. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60316 llvm-svn: 358571
* [clangd] lower_bound -> bsearch, NFCSam McCall2019-04-172-8/+8
| | | | llvm-svn: 358561
* clangd: Change Windows.h to windows.h.Peter Collingbourne2019-04-171-1/+1
| | | | | | This makes the file more cross compilation friendly. llvm-svn: 358549
* [clangd] Check file path of declaring header when deciding whether to insert ↵Eric Liu2019-04-165-29/+28
| | | | | | | | | | | | | | | | | | | include. Summary: Previously, we would use include spelling of the declaring header to check whether the inserted header is the same as the main file. This doesn't help because we only have file path of the main file. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60687 llvm-svn: 358496
* [clangd] Fallback to OrigD when SLoc is invalidKadir Cetinkaya2019-04-152-0/+14
| | | | | | | | | | | | | | | | | Summary: Some implicit/built-in decls lack the source location information. Fallback to OrigD that we've seen in the source code instead of the canonical one in those cases. Reviewers: sammccall Subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D60689 llvm-svn: 358413
* [clangd] Wait for compile command in ASTWorker instead of ClangdServerEric Liu2019-04-159-102/+194
| | | | | | | | | | | | | | | | | | Summary: This makes addDocument non-blocking and would also allow code completion (in fallback mode) to run when worker waits for the compile command. Reviewers: sammccall, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60607 llvm-svn: 358400
* [clangd] Bump clangd-index version for TemplateArgument changesKadir Cetinkaya2019-04-151-1/+1
| | | | llvm-svn: 358383
* [clangd] Reorder source files in CMakeListsKadir Cetinkaya2019-04-151-1/+1
| | | | llvm-svn: 358373
* [clang-tidy] Add MagnitudeBitsUpperLimit option to ↵Tamas Zolnai2019-04-146-21/+89
| | | | | | | | | | | | | | | | | | | | | bugprone-too-small-loop-variable Summary: The bugprone-too-small-loop-variable check often catches loop variables which can represent "big enough" values, so we don't actually need to worry about that this variable will overflow in a loop when the code iterates through a container. For example a 32 bit signed integer type's maximum value is 2 147 483 647 and a container's size won't reach this maximum value in most of the cases. So the idea of this option to allow the user to specify an upper limit (using magnitude bit of the integer type) to filter out those catches which are not interesting for the user, so he/she can focus on the more risky integer incompatibilities. Next to the option I replaced the term "positive bits" to "magnitude bits" which seems a better naming both in the code and in the name of the new option. Reviewers: JonasToth, alexfh, aaron.ballman, hokein Reviewed By: JonasToth Subscribers: Eugene.Zelenko, xazax.hun, jdoerfert, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59870 llvm-svn: 358356
* [clang-tidy] Use back-tick hereTamas Zolnai2019-04-131-2/+2
| | | | llvm-svn: 358333
* [clangd] Fix an overflow inside a testKadir Cetinkaya2019-04-121-0/+2
| | | | llvm-svn: 358293
* [clangd] Enable clang-tidy by default.Haojian Wu2019-04-121-1/+1
| | | | | | | | | | | | | | | | | | | Summary: We have turned on the flag internally for a while, and we don't receive complains. Should be good to turn it on now. If the projects doesn't have .clang-tidy files, no clang-tidy check will be run. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60560 llvm-svn: 358282
* [clangd] Show template argument list in workspacesymbols and documentsymbols ↵Kadir Cetinkaya2019-04-127-45/+64
| | | | | | | | | | | | | | | | | | responses Summary: Last part of re-landing rC356541. Puts TemplateArgumentsList into responses of the above mentioned two requests. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59641 llvm-svn: 358274
* [clangd] Add TemplateArgumentList into SymbolKadir Cetinkaya2019-04-125-1/+80
| | | | | | | | | | | | | | | | | | | | | Summary: Part of re-landing rC356541 with D59599. Changes the way we store template arguments, previous patch was storing them inside Name field of Symbol. Which was violating the assumption: ```Symbol::Scope+Symbol::Name == clang::clangd::printQualifiedName``` which was made in multiple places inside codebase. This patch instead moves those arguments into their own field. Currently the field is meant to be human-readable, can be made structured if need be. Reviewers: ioeric, ilya-biryukov, gribozavr Subscribers: MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59640 llvm-svn: 358273
* [clangd] Print template arguments helperKadir Cetinkaya2019-04-125-18/+161
| | | | | | | | | | | | | | | | Summary: Prepares ground for printing template arguments as written in the source code, part of re-landing rC356541 with D59599 applied. Reviewers: ioeric, ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59639 llvm-svn: 358272
* [clangd] Use identifiers in file as completion candidates when build is not ↵Eric Liu2019-04-1114-85/+299
| | | | | | | | | | | | | | | | | | | | | | ready. Summary: o Lex the code to get the identifiers and put them into a "symbol" index. o Adds a new completion mode without compilation/sema into code completion workflow. o Make IncludeInserter work even when no compile command is present, by avoiding inserting non-verbatim headers. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60126 llvm-svn: 358159
* [clangd] Include compile command heuristic in logsSam McCall2019-04-112-2/+5
| | | | llvm-svn: 358157
* clangd-fuzzer: repair the buildSaleem Abdulrasool2019-04-101-1/+2
| | | | | | The inclusion of private headers of clangd percolates into the fuzzer. llvm-svn: 358127
* build: add binary dir to the unittestsSaleem Abdulrasool2019-04-101-0/+3
| | | | | | | Missed part of the change to make clangd build on Darwin. Fixes the build after SVN r358103. llvm-svn: 358107
* clangd: fix the build with XPCSaleem Abdulrasool2019-04-101-0/+1
| | | | | | | | | | | `Transport.h` does not include `Features.inc`. However, since it is used in a subdirectory, it cannot directly include the header as it is not available. Include `Features.inc` in `ClangdLSPServer.h` prior to the inclusion of `Transport.h` which will provide the interfaces in `ClangdMain.cpp` where the symbol `newXPCTransport` will not be defined due to it being preprocessed away since the configuration is not passed along to the initial inclusion. llvm-svn: 358103
* [clangd] Fix non-indexing of builtin functions like printf when the TU is CSam McCall2019-04-102-6/+14
| | | | llvm-svn: 358098
* [clangd] Use #if CLANGD_BUILD_XPC because it may be defined as 0Fangrui Song2019-04-101-1/+1
| | | | llvm-svn: 358094
* clangd: repair the build after SVN r358091Saleem Abdulrasool2019-04-101-1/+1
| | | | | | Fix the name of the variable being checked. NFCI. llvm-svn: 358093
* [clangd] Don't insert extra namespace qualifiers when Sema gets lost.Sam McCall2019-04-102-71/+78
| | | | | | | | | | | | | | | | | | | | | | | | Summary: There are cases where Sema can't tell that "foo" in foo::Bar is a namespace qualifier, like in incomplete macro expansions. After this patch, if sema reports no specifier but it looks like there's one in the source code, then we take it into account. Reworked structure and comments in getQueryScopes to try to fight creeping complexity - unsure if I succeeded. I made the test harder (the original version also passes). Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60503 llvm-svn: 358091
* [clangd] Add -header-insertion=never flag to disable include insertion in ↵Sam McCall2019-04-104-8/+43
| | | | | | | | | | | | | | | | code completion Summary: One clear use case: use with an editor that reacts poorly to edits above the cursor. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60409 llvm-svn: 358075
* [clangd] Refactor speculateCompletionFilter and also extract scope.Sam McCall2019-04-103-56/+88
| | | | | | | | | | | | | | | | | | | Summary: Intent is to use the heuristically-parsed scope in cases where we get bogus results from sema, such as in complex macro expansions. Added a motivating testcase we currently get wrong. Name changed because we (already) use this for things other than speculation. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60500 llvm-svn: 358074
* ClangTidy: Avoid mixing stdout with stderror when dealing with a large ↵Andi-Bogdan Postelnicu2019-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | number of files. Summary: At Mozilla we are using this tool in order to perform review-time static-analysis, since some patches contain a large number of files we've discovered this issue, where `stderr` gets mixed with `stdout` thus obfuscating our possibility to parse the output. The patch that we are currently use can be found [here](https://searchfox.org/mozilla-central/source/build/build-clang/clang-tidy-8.patch). This is just an upstream of the original patch. Reviewers: JonasToth Reviewed By: JonasToth Subscribers: cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D60453 llvm-svn: 357994
* [clangd] Add fallback mode for code completion when compile command or ↵Eric Liu2019-04-086-17/+96
| | | | | | | | | | | | | | | | | | | | | | | | | preamble is not ready. Summary: When calling TUScehduler::runWithPreamble (e.g. in code compleiton), allow entering a fallback mode when compile command or preamble is not ready, instead of waiting. This allows clangd to perform naive code completion e.g. using identifiers in the current file or symbols in the index. This patch simply returns empty result for code completion in fallback mode. Identifier-based plus more advanced index-based completion will be added in followup patches. Reviewers: ilya-biryukov, sammccall Reviewed By: sammccall Subscribers: sammccall, javed.absar, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59811 llvm-svn: 357916
* Make SourceManager::createFileID(UnownedTag, ...) take a const ↵Nico Weber2019-04-042-2/+2
| | | | | | | | | | | | | | | | | | | | | llvm::MemoryBuffer* Requires making the llvm::MemoryBuffer* stored by SourceManager const, which in turn requires making the accessors for that return const llvm::MemoryBuffer*s and updating all call sites. The original motivation for this was to use it and fix the TODO in CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag version of createFileID, and since llvm::SourceMgr* hands out a const llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO this way actually works, but this seems like a good change on its own anyways. No intended behavior change. Differential Revision: https://reviews.llvm.org/D60247 llvm-svn: 357724
* check-clang-tools: Actually build and run XPC testNico Weber2019-04-042-3/+3
| | | | | | | | | | | | | | The CMake variable controlling if XPC code is built is called CLANGD_BUILD_XPC but three places unintentionally checked the non-existent variable CLANGD_BUILD_XPC_SUPPORT instead, which (due to being nonexistent, and due to cmake) always silently evaluated to false. Luckily the test still seems to pass, despite never running after being added almost 3 months ago in r351280. Differential Revision: https://reviews.llvm.org/D60120 llvm-svn: 357719
* Fix clangd-fuzzer buildNico Weber2019-04-042-2/+6
| | | | | | | | | r357102 made clangd-fuzzer no longer compile, but before r357654 / r357694 we didn't notice. Fix the compile. Also add a dep on FuzzMutate which I forgot to do in r357654. llvm-svn: 357696
* Use a cmake check for linux that actually works.Nico Weber2019-04-041-1/+1
| | | | llvm-svn: 357694
* [clangd] Test #import directive go-to-definition. NFCSam McCall2019-04-041-0/+12
| | | | llvm-svn: 357690
* [clangd] Stop passing around PCHContainerOperations, just create it in ↵Sam McCall2019-04-0414-90/+52
| | | | | | place. NFC llvm-svn: 357689
* Make clangd-fuzzer use the normal add_llvm_fuzzer() machineryNico Weber2019-04-044-9/+24
| | | | | | | | | This allows building it even if no fuzzer is enabled. (Sadly, it only builds on Linux at the moment.) Differential Revision: https://reviews.llvm.org/D60201 llvm-svn: 357654
* [clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks methodAlexander Kornienko2019-04-034-6/+0
| | | | | | | | | | | | | | | | | | Summary: All in-tree clang-tidy checks have been migrated to the new ClangTidyCheck::registerPPCallbacks method. Time to drop the old one. Reviewers: sammccall, hokein Reviewed By: hokein Subscribers: xazax.hun, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60197 llvm-svn: 357582
* gn build: Add build files for clangd xpc framework codeNico Weber2019-04-032-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a bit of a larger change since this is the first (and as far as I can tell only) place where the LLVM build produces macOS framework bundles. GN has some built-in support for this, so use that. `gn help create_bundle` has a terse description (but it's a bit outdated: `deps` must be `public_deps` and the conditionals in the example in the help aren't quite right on non-iOS). We need a new 'copy_bundle_data' tool, and since we copy the clangd.xpc bundle as bundle_data into ClangdXPC.framework it needs to be able to handle directories in addition to files. GN also insists we have a compile_xcassets tool even though it's not used. I just made that run `false`. Despite GN's support for bundles, we still need to manually create the expected symlink structure in the .framework bundle. Since this code never runs on Windows, it's safe to create the symlinks before the symlink targets exist, so we can just make the bundle depend on the steps that create the symlinks. For this to work, change the symlink script to create the symlink's containing directory if it doesn't yet exist. I locally verified that CMake and GN build create the same bundle structure. (I noticed that both builds set LC_ID_DYLIB to the pre-copy libClangdXPCLib.dylib name, but that seems to not cause any issues and it happens in the CMake build too.) (Also add an error message to clangd-xpc-test-client for when loading the dylib fails – this was useful while locally debugging this.) Differential Revision: https://reviews.llvm.org/D60130 llvm-svn: 357574
* [clangd] Return clangd::TextEdit in ClangdServer::rename. NFCIlya Biryukov2019-04-035-22/+17
| | | | | | | | | | | | | | | | | | | | Summary: Instead of tooling::Replacement. To avoid the need to have contents of the file at the caller site. This also aligns better with other methods in ClangdServer, majority of those already return LSP-specific data types. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60179 llvm-svn: 357561
* [clang-tidy] make getLangOpts return a const refAlexander Kornienko2019-04-021-1/+1
| | | | llvm-svn: 357468
* [clangd] Use capacity() instead of size() in RefSlab::bytes()Ilya Biryukov2019-04-021-1/+1
| | | | | | | | | | | | | | | | Patch by Nathan Ridge. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60040 llvm-svn: 357454
* Fix clangd unittest _WIN32 ifdefReid Kleckner2019-04-011-2/+2
| | | | | | WIN32 is not defined, _WIN32 is, use that instead. llvm-svn: 357429
* Spelling correction for docs for cppcoreguidelines-owning-memorySylvestre Ledru2019-03-311-1/+1
| | | | | | | | | | | | | | Summary: There's a typo in the docs, as mentioned in the title. Please see the diff. Reviewers: JonasToth Subscribers: sylvestre.ledru, nemanjai, kbarton, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D60050 llvm-svn: 357371
* gn build: Add build files for most clang-tools-extra unit testsNico Weber2019-03-311-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D60038 llvm-svn: 357369
* Rename IncludeFixerTests to ClangIncludeFixerTests and ChangeNamespaceTests ↵Nico Weber2019-03-302-4/+4
| | | | | | | | to ClangChangeNamespaceTests Follow-up to r356897 and r356254. llvm-svn: 357356
OpenPOWER on IntegriCloud