summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Truncate SymbolID to 16 bytes.Sam McCall2018-10-244-21/+26
| | | | | | | | | | | | | | | Summary: The goal is 8 bytes, which has a nonzero risk of collisions with huge indexes. This patch should shake out any issues with truncation at all, we can lower further later. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53587 llvm-svn: 345113
* [clang-tidy] Add a separate section for NOLINT(NEXTLINE)? doc.Alexander Kornienko2018-10-231-7/+10
| | | | llvm-svn: 345049
* [clangd] Lazily create CDB, remove setCompileCommandsDir.Sam McCall2018-10-232-39/+19
| | | | | | | | | | | | | | Summary: The only way to actually set the directory is at initialize time, so now CDB is lazy we can pass it to the constructor. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53572 llvm-svn: 345031
* [clangd] Remove caching of compilation database commands.Sam McCall2018-10-234-78/+4
| | | | | | | | | | | | | | | | | Summary: The CDB implementations used in open-source code are fast, and our private slow CDB will soon do the relevant caching itself. Simplifying the GlobalCDB layer in clangd is important to get auto-index implemented at the right layer. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53439 llvm-svn: 345024
* [clangd] Support passing a relative path to -compile-commands-dirSam McCall2018-10-231-10/+18
| | | | | | | | | | | | | | | | | | Summary: This is useful when using clangd with CMake based projects in Visual Studio Code since when using CMake the `compile_commands.json` file is usually located in a `build` subdirectory which isn't a parent directory of the source files. Allowing passing relative paths to -compile-commands-dir allows specifying `clangd.arguments = ["-compile-commands-dir=build"]` in VSCode's settings file and having it work for each CMake based project that uses the `build` subdirectory as the build directory (instead of having to specify the absolute path to the compile commands directory for each separate project in VSCode's settings). Patch by Daan De Meyer! Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53481 llvm-svn: 345022
* Fix range length comparison in DraftStore::UpdateDraft when Unicode ↵Sam McCall2018-10-234-7/+29
| | | | | | | | | | | | | | | | | | | | | | | characters are removed from the document Summary: See http://lists.llvm.org/pipermail/clangd-dev/2018-October/000171.html for context. I kept the error (instead of downgrading to a log message) since the range lengths differing does indicate either a bug in the client or server range calculation or the buffers being out of sync (which both seems serious enough to me to be an error). If any existing clients aside from VSCode break they should only break when accidentally typing a Unicode character which should only be a minor nuisance for a little while until the bug is fixed in the respective client. Patch by Daan De Meyer! Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, kadircet, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53527 llvm-svn: 345020
* [clang-tidy] Fix typo abls->absl.Benjamin Kramer2018-10-221-1/+1
| | | | llvm-svn: 344968
* [clang-tidy] tryfix windows buildJonas Toth2018-10-221-0/+1
| | | | llvm-svn: 344947
* [Documentation] Fix grammar related to Clang-tidy cppcoreguidelines-macro-usage.Eugene Zelenko2018-10-222-2/+2
| | | | llvm-svn: 344943
* [clang-tidy] implement cppcoreguidelines macro rulesJonas Toth2018-10-2210-0/+252
| | | | | | | | | | | | | | | | Summary: In short macros are discouraged by multiple rules (and sometimes reference randomly). [Enum.1], [ES.30], [ES.31] This check allows only headerguards and empty macros for annotation. Reviewers: aaron.ballman, hokein Reviewed By: aaron.ballman Subscribers: jbcoe, Eugene.Zelenko, klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D41648 llvm-svn: 344940
* [clangd] Support URISchemes configuration in BackgroundIndex.Eric Liu2018-10-222-4/+9
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53503 llvm-svn: 344912
* [change-namespace] Enhance detection of conflicting namespaces.Eric Liu2018-10-222-11/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For example: ``` namespace util { class Base; } namespace new { namespace util { class Internal; } } namespace old { util::Base b1; } ``` When changing `old::` to `new::`, `util::` in namespace "new::" will conflict with "new::util::" unless a leading "::" is added. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53489 llvm-svn: 344897
* ReleaseNotes: move readability-redundant-smartptr-get part down below new checksMiklos Vajna2018-10-221-4/+4
| | | | llvm-svn: 344885
* [clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-getMiklos Vajna2018-10-216-1/+52
| | | | | | | | | | | | | And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth Differential Revision: https://reviews.llvm.org/D53454 llvm-svn: 344871
* [clangd] Fix unqualified make_unique after r344850. NFCSam McCall2018-10-201-2/+2
| | | | llvm-svn: 344858
* Check that __MAC_OS_X_VERSION_MIN_REQUIRED is defined before checkingAkira Hatanaka2018-10-201-1/+3
| | | | | | whether it is too old. llvm-svn: 344856
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-2071-1139/+1089
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* Fix MSVC "truncation from 'double' to 'float'" warning. NFCI.Simon Pilgrim2018-10-201-1/+1
| | | | llvm-svn: 344845
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2018-10-201-0/+1
| | | | llvm-svn: 344844
* [clang-query] Add option to print matcher expressionStephen Kelly2018-10-205-17/+42
| | | | | | | | | | | | | | Summary: This is useful if using clang-query -f with a file containing multiple matchers. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52859 llvm-svn: 344840
* Disable unittests/clangd/JSONTransportTests.cpp on versions of macosxAkira Hatanaka2018-10-201-2/+3
| | | | | | | | earlier than 10.13. rdar://problem/45310173 llvm-svn: 344827
* [clangd] Set workspace root when initializing ClangdServer, disallow mutation.Sam McCall2018-10-194-24/+13
| | | | | | | | | | | | | | | | | | Summary: Rename instance variable to WorkspaceRoot to match what we call it internally. Add fixme to set it automatically. Don't do it yet, clients have assumptions that the constructor won't access the FS. Don't second-guess the provided root. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53404 llvm-svn: 344787
* [clang-tidy] Resolve readability-else-after-return false positive for ↵Marek Kurdej2018-10-192-57/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | constexpr if. Summary: It fixes the false positive when using constexpr if and where else cannot be removed: Example: ``` if constexpr (sizeof(int) > 4) // ... return /* ... */; else // This else cannot be removed. // ... return /* ... */; ``` Reviewers: alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: lebedev.ri, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D53372 llvm-svn: 344785
* [clangd] Remove the overflow log.Haojian Wu2018-10-194-2/+15
| | | | | | | | | | | | | | Summary: LLVM codebase has generated files (all are build/Target/XXX/*.inc) that exceed the MaxLine & MaxColumn. Printing these log would be noisy. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53400 llvm-svn: 344777
* [clangd] Fix msan failure after r344735 by initializing bitfieldsKrasimir Georgiev2018-10-191-0/+1
| | | | | | | | | That revision changed integer members to bitfields; the integers were default initialized before and the bitfields lost that default initialization. This started causing msan use-of-uninitialized memory in clangd tests. llvm-svn: 344773
* [clang-tidy] readability-uppercase-literal-suffix: specify target for ms ↵Roman Lebedev2018-10-191-3/+3
| | | | | | | | | test too Apparently the bots were still failing with this. Sadly, i did not see *this* failure when i last looked. llvm-svn: 344772
* [clang-tidy] readability-uppercase-literal-suffix: specify target for opencl ↵Roman Lebedev2018-10-181-3/+3
| | | | | | | | | test I'm not sure if it will actually help or not. ppc64be-clang-lnt-test bot is failing. llvm-svn: 344760
* [clang-tidy] readability-uppercase-literal-suffix: specify target for fp testsRoman Lebedev2018-10-182-6/+6
| | | | | | __float128 isn't universally avaliable. llvm-svn: 344758
* [clang-tidy] Non-private member variables in classes (MISRA, ↵Roman Lebedev2018-10-1810-0/+588
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CppCoreGuidelines, HICPP) Summary: Finds classes that not only contain the data (non-static member variables), but also have logic (non-static member functions), and diagnoses all member variables that have any other scope other than `private`. They should be made `private`, and manipulated exclusively via the member functions. Optionally, classes with all member variables being `public` could be ignored, and optionally all `public` member variables could be ignored. Options ------- * IgnoreClassesWithAllMemberVariablesBeingPublic Allows to completely ignore classes if **all** the member variables in that class have `public` visibility. * IgnorePublicMemberVariables Allows to ignore (not diagnose) **all** the member variables with `public` visibility scope. References: * MISRA 11-0-1 Member data in non-POD class types shall be private. * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-private * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-protected Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, zinovy.nis, cfe-commits, rnkovacs, nemanjai, mgorny, xazax.hun, kbarton Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52771 llvm-svn: 344757
* [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT ↵Roman Lebedev2018-10-1824-19/+1454
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4) Summary: Detects when the integral literal or floating point (decimal or hexadecimal) literal has non-uppercase suffix, and suggests to make the suffix uppercase, with fix-it. All valid combinations of suffixes are supported. ``` auto x = 1; // OK, no suffix. auto x = 1u; // warning: integer literal suffix 'u' is not upper-case auto x = 1U; // OK, suffix is uppercase. ... ``` References: * [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]] * MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix * MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52670 llvm-svn: 344755
* [clangd] Clear the semantic of RefSlab::size.Haojian Wu2018-10-185-12/+19
| | | | | | | | | | | | | | | | | Summary: The RefSlab::size can easily cause confusions, it returns the number of different symbols, rahter than the number of all references. - add numRefs() method and cache it, since calculating it everytime is nontrivial. - clear misused places. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53389 llvm-svn: 344745
* [clangd] Enforce rules around "initialize" request, and create ClangdServer ↵Sam McCall2018-10-187-15/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lazily. Summary: LSP is a slightly awkward map to C++ object lifetimes: the initialize request is part of the protocol and provides information that doesn't change over the lifetime of the server. Until now, we handled this by initializing ClangdServer and ClangdLSPServer right away, and making anything that can be set in the "initialize" request mutable. With this patch, we create ClangdLSPServer immediately, but defer creating ClangdServer until "initialize". This opens the door to passing the relevant initialize params in the constructor and storing them immutably. (That change isn't actually done in this patch). To make this safe, we have the MessageDispatcher enforce that the "initialize" method is called before any other (as required by LSP). That way each method handler can assume Server is initialized, as today. As usual, while implementing this I found places where our test cases violated the protocol. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53398 llvm-svn: 344741
* [clangd] Lay JSONRPCDispatcher to rest.Sam McCall2018-10-1814-661/+411
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most of its functionality is moved into ClangdLSPServer. The decoupling between JSONRPCDispatcher, ProtocolCallbacks, ClangdLSPServer was never real, and only served to obfuscate. Some previous implicit/magic stuff is now explicit: - the return type of LSP method calls are now in the signature - no more reply() that gets the ID using global context magic - arg tracing no longer relies on RequestArgs::stash context magic either This is mostly refactoring, but some deliberate fixes while here: - LSP method params are now by const reference - notifications and calls are now distinct namespaces. (some tests had protocol errors and needed updating) - we now reply to calls we failed to decode - outgoing calls use distinct IDs A few error codes and message IDs changed in unimportant ways (see tests). Reviewers: ioeric Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53387 llvm-svn: 344737
* [clangd] Names that are not spelled in source code are reserved.Eric Liu2018-10-188-15/+79
| | | | | | | | | | | | | | | | | | | | | | | | Summary: These are often not expected to be used directly e.g. ``` TEST_F(Fixture, X) { ^ // "Fixture_X_Test" expanded in the macro should be down ranked. } ``` Only doing this for sema for now, as such symbols are mostly coming from sema e.g. gtest macros expanded in the main file. We could also add a similar field for the index symbol. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53374 llvm-svn: 344736
* [clangd] Encode Line/Column as a 32-bits integer.Haojian Wu2018-10-1810-47/+126
| | | | | | | | | | | | | | | | | | | | | | Summary: This would buy us more memory. Using a 32-bits integer is enough for most human-readable source code (up to 4M lines and 4K columns). Previsouly, we used 8 bytes for a position, now 4 bytes, it would save us 8 bytes for each Ref and each Symbol instance. For LLVM-project binary index file, we save ~13% memory. | Before | After | | 412MB | 355MB | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53363 llvm-svn: 344735
* [clang-tidy] Ignore a case where the fix of make_unique check introduces ↵Haojian Wu2018-10-182-8/+14
| | | | | | | | | | | | | | | | | | | | side effect. Summary: Previously, ptr.reset(new char[5]) will be replaced with `p = make_unique<char[]>(5)`, the fix has side effect -- doing default initialization, it may cause performace regression (we are bitten by this rececntly) The check should be conservative for these cases. Reviewers: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D53377 llvm-svn: 344733
* Fix warning about unused variable [NFC]Mikael Holmen2018-10-181-1/+1
| | | | llvm-svn: 344724
* [clang-doc] Bringing bitcode tests in lineJulie Hockett2018-10-172-4/+18
| | | | | | | | | | | Makes bitcode tests line up with what's actually called in the tool. Should fix the failing bot. Also fixes a warning that was being thrown about initialization braces. Differential Revision: https://reviews.llvm.org/D53381 llvm-svn: 344707
* [clangd] Support scope proximity in code completion.Eric Liu2018-10-1710-37/+231
| | | | | | | | | | | | | | | | Summary: This should make all-scope completion more usable. Scope proximity for indexes will be added in followup patch. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53131 llvm-svn: 344688
* [clangd] Fix buildbot failure.Haojian Wu2018-10-171-3/+5
| | | | llvm-svn: 344680
* [clangd] Print numbers of symbols and refs as well when loading theHaojian Wu2018-10-171-2/+7
| | | | | | index. llvm-svn: 344679
* [clangd] Collect refs from headers.Haojian Wu2018-10-175-17/+53
| | | | | | | | | | | | | | | | | Summary: Add a flag to SymbolCollector to collect refs fdrom headers. Note that we collect refs from headers in static index, and we don't do it for dynamic index because of the preamble (we skip function body in preamble, collecting it will result incomplete results). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53322 llvm-svn: 344678
* [clangd] Hide unused function. NFCSam McCall2018-10-172-9/+2
| | | | llvm-svn: 344676
* [clangd] Rename and move trivial logger to Logger.cpp. NFCSam McCall2018-10-176-33/+33
| | | | llvm-svn: 344675
* [clangd] Simplify client capabilities parsing.Sam McCall2018-10-173-192/+76
| | | | | | | | | | | | | | | | | | Summary: Instead of parsing into structs that mirror LSP, simply parse into a flat struct that contains the info we need. This is an exception to our strategy with Protocol.h, which seems justified: - the structure here is very large and deeply nested - we care about almost none of it - we should never have to serialize client capabilities Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53266 llvm-svn: 344673
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. ↵Sam McCall2018-10-1723-341/+744
| | | | | | | | | | | | | | | | | | | | | | | | | | | (re-land r344620) Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 llvm-svn: 344672
* [clang-doc] Limit integration testsJulie Hockett2018-10-1635-4750/+94
| | | | | | | | | | | | | | | | Now that the clang-doc libraries are covered by unit tests, we don't need to have extensive (and unmaintainable) integration tests. This replaces the integration test suite with a smaller one that just tests the tool itself and removes extraneous dumping logic from the tool itself. Includes tests that cover the parse->serialize->merge->generate pipeline, as well as tests for the --public, --format, --doxygen, and --output flags. Differential Revision: https://reviews.llvm.org/D53150 llvm-svn: 344655
* [clang-doc] Add unit tests for Markdown generationJulie Hockett2018-10-162-0/+362
| | | | | | | | | | | | Add unit tests for Markdown generation. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53085 llvm-svn: 344654
* [clang-doc] Add unit tests for YAML generationJulie Hockett2018-10-162-0/+428
| | | | | | | | | | | | Adds unit tests for the YAML generator library. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53084 llvm-svn: 344653
* [clang-doc] Add unit tests for mergingJulie Hockett2018-10-162-0/+237
| | | | | | | | | | | | Adds unit tests for the merging logic in Respresentation.cpp. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53083 llvm-svn: 344652
OpenPOWER on IntegriCloud