summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-query] Add 'detailed-ast' output as an alias for 'dump'Stephen Kelly2018-10-242-4/+10
| | | | | | | | | | | | Summary: Future development can then dump other content than AST. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53500 llvm-svn: 345193
* [clangd] Do not query index for new name completions.Kadir Cetinkaya2018-10-241-0/+9
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53192 llvm-svn: 345153
* [clangd] Don't show base class versions of members as completions.Sam McCall2018-10-241-3/+6
| | | | | | | | | | | | | | Summary: These are available via qualifiers, but signal to noise level is low. Keep required quailifier machinery around though, for cross-ns completion. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53571 llvm-svn: 345141
* [clangd] Downrank members from base classEric Liu2018-10-241-0/+11
| | | | | | | | | | | | Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53638 llvm-svn: 345140
* [clangd] Simplify auto hoverIlya Biryukov2018-10-241-0/+7
| | | | | | | | | | | | | | | | Summary: Use helper from clang. Also fixes some weird corner cases, e.g. auto (*foo)() = bar; Reviewers: kadircet, hokein Reviewed By: kadircet, hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53347 llvm-svn: 345128
* [clangd] Embed fixes as CodeAction, instead of clangd_fixes. Clean up ↵Sam McCall2018-10-241-4/+7
| | | | | | | | | | | | | | | | | | | serialization. Summary: CodeAction provides us with a standard way of representing fixes inline, so use it, replacing our existing ad-hoc extension. After this, it's easy to serialize diagnostics using the structured toJSON/Protocol.h mechanism rather than assembling JSON ad-hoc. Reviewers: hokein, arphaman Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53391 llvm-svn: 345119
* [clangd] Truncate SymbolID to 16 bytes.Sam McCall2018-10-241-14/+13
| | | | | | | | | | | | | | | 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
* Fix range length comparison in DraftStore::UpdateDraft when Unicode ↵Sam McCall2018-10-231-0/+10
| | | | | | | | | | | | | | | | | | | | | | | 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
* [change-namespace] Enhance detection of conflicting namespaces.Eric Liu2018-10-221-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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-2027-248/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-query] Add option to print matcher expressionStephen Kelly2018-10-201-6/+8
| | | | | | | | | | | | | | 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-191-1/+1
| | | | | | | | | | | | | | | | | | 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
* [clangd] Remove the overflow log.Haojian Wu2018-10-191-0/+5
| | | | | | | | | | | | | | 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] Names that are not spelled in source code are reserved.Eric Liu2018-10-182-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | 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-183-23/+38
| | | | | | | | | | | | | | | | | | | | | | 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-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-173-8/+83
| | | | | | | | | | | | | | | | 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] Collect refs from headers.Haojian Wu2018-10-171-0/+11
| | | | | | | | | | | | | | | | | 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] Refactor JSON-over-stdin/stdout code into Transport abstraction. ↵Sam McCall2018-10-172-0/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | (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] 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
* [clang-doc] Add unit tests for bitcodeJulie Hockett2018-10-162-0/+261
| | | | | | | | | | | | Adds unit tests for the BitcodeWriter and BitcodeReader libraries. 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/D53082 llvm-svn: 344651
* [clang-doc] Add unit tests for serializationJulie Hockett2018-10-165-0/+609
| | | | | | | | | | | | Adds unit tests for the Serialize 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/D53081 llvm-svn: 344650
* Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport ↵Krasimir Georgiev2018-10-162-200/+0
| | | | | | | | | abstraction." This reverts commit r344620. Breaks upstream bots. llvm-svn: 344637
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.Sam McCall2018-10-162-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | 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: 344620
* [clangd] Allow disble down traversals from root.Eric Liu2018-10-161-0/+14
| | | | | | | | | | | | | | Summary: This is useful for symbo scope proximity, where down traversals from the global scope if not desired. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53317 llvm-svn: 344604
* [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test.Sam McCall2018-10-161-3/+0
| | | | | | | | | | | | | | | | | | | Summary: One relatively boring bug: forgot to notify the CV after enqueue. One much more fun bug: the thread member could access instance variables before they were initialized. Although the thread was last in the init list, QueueCV etc were listed after Thread in the class, so their default constructors raced with the thread itself. We have to get very unlucky to lose this race, I saw it 0.02% of the time. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53313 llvm-svn: 344595
* [clangd] Optionally use dex for the preamble parts of the dynamic index.Sam McCall2018-10-163-16/+12
| | | | | | | | | | | | | | | Summary: Reuse the old -use-dex-index experiment flag for this. To avoid breaking the tests, make Dex deduplicate symbols, addressing an old FIXME. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53288 llvm-svn: 344594
* [clangd] Disable timeouting test while investigatingSam McCall2018-10-161-0/+3
| | | | llvm-svn: 344586
* [clangd] Use SyncAPI in more places in tests. NFCSam McCall2018-10-151-86/+50
| | | | llvm-svn: 344520
* [clangd] Minimal implementation of automatic static index (not enabled).Sam McCall2018-10-154-1/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: See tinyurl.com/clangd-automatic-index for design and goals. Lots of limitations to keep this patch smallish, TODOs everywhere: - no serialization to disk - no changes to dynamic index, which now has a much simpler job - no partitioning of symbols by file to avoid duplication of header symbols - no reindexing of edited files - only a single worker thread - compilation database is slurped synchronously (doesn't scale) - uses memindex, rebuilds after every file (should be dex, periodically) It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering isn't clear (it should really be in ClangdServer, but ClangdLSPServer has all the CDB interactions). Reviewers: ioeric Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53032 llvm-svn: 344513
* [clangd] Fix some references missing in dynamic index.Haojian Wu2018-10-151-0/+51
| | | | | | | | | | | | | | | | | | | Summary: Previously, SymbolCollector postfilters all references at the end to find all references of interesting symbols. It was incorrect when indxing main AST where we don't see locations of symbol declarations and definitions in the main AST (as those are in preamble AST). The fix is to do earily check during collecting references. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53273 llvm-svn: 344507
* [clangd] Support hover on "aut^o *".Haojian Wu2018-10-121-0/+19
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53186 llvm-svn: 344330
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-108-23/+24
| | | | | | | | | | | | | | | | | | | This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
* [clangd] Make FSProvider const-correct. NFCSam McCall2018-10-102-4/+4
| | | | llvm-svn: 344118
* [clangd] Mark colon as a safe character when percent-encoding.Kadir Cetinkaya2018-10-091-3/+6
| | | | | | | | | | | | | | Summary: Also change output of percent-encoding to use upper-case letters. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53016 llvm-svn: 344033
* [clangd] Fix nondeterministic testSam McCall2018-10-091-1/+4
| | | | llvm-svn: 344030
* [clangd] Revert back to previous heuristic for diagnostic range extraction.Kadir Cetinkaya2018-10-091-2/+9
| | | | | | | | | | | | | | Summary: Also add a few new test cases and a special case into handling of empty fixit ranges that collides with location of a diag. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52889 llvm-svn: 344025
* [clangd] Avoid cache main file status in preamble.Eric Liu2018-10-091-1/+5
| | | | | | | | | | | | Summary: Main file can certainly change when reusing preamble. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52991 llvm-svn: 344024
* [clang-move] Dump whether a declaration is templated.Eric Liu2018-10-081-20/+26
| | | | llvm-svn: 343982
* [clangd] Remove debugging output in testSam McCall2018-10-051-5/+0
| | | | llvm-svn: 343845
* [clangd] Fix a subtle case for GetBeginningOfIdentifier.Sam McCall2018-10-051-4/+21
| | | | | | | | | | Calling getMacroArgExpansionLocation too early was causing Lexer::getRawToken to do the wrong thing - lexing the macro name instead of the arg contents. Differential Revision: https://reviews.llvm.org/D52928 llvm-svn: 343844
* [clangd] Simplify Dex query tree logic and fix missing-posting-list bugSam McCall2018-10-041-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The bug being fixed: when a posting list doesn't exist in the index, it was previously just dropped from the query rather than being treated as empty. Now that we have the FALSE iterator, we can use it instead. The query tree logic previously had a bunch of special cases to detect whether subtrees are empty. Now we just naively build the whole tree, and rely on the query optimizations to drop the trivial parts. Finally, there was a bug in trigram generation: the empty query would generate a single trigram "$$$" instead of no trigrams. This had no effect (there was no posting list, so the other bug cancelled it out). But we now have to fix this bug too. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52796 llvm-svn: 343802
* [clangd] Add std::move for converting-return to satisfy older compilersSam McCall2018-10-041-1/+1
| | | | llvm-svn: 343800
* [clangd] fix another ambigous constructor in DexTestJonas Toth2018-10-041-3/+3
| | | | llvm-svn: 343796
* [clangd] Fix ambiguous constructor in DexTestSam McCall2018-10-041-2/+2
| | | | llvm-svn: 343793
* [clangd] expose MergedIndex classSam McCall2018-10-043-21/+22
| | | | | | | | | | | | | | Summary: This allows inheriting from it, so index() can ga away and allowing TestTU::index) to be fixed. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52250 llvm-svn: 343780
OpenPOWER on IntegriCloud