summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Do not show namespace comments.Ilya Biryukov2018-06-271-0/+5
| | | | | | | | | | | | | | | | | | | | | Summary: Comments from namespaces that clangd produces are too noisy and often not useful. Namespaces have too many redecls and we don't have a good way of determining which of the comments are relevant and which should be ignored (e.g. because they come from code generators like the protobuf compiler). Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48211 llvm-svn: 335718
* [clangd] Simplify matches in FindSymbols testsMarc-Andre Laperle2018-06-261-57/+45
| | | | | | | | | | | | | | | | | Summary: Instead of checking symbol name and container (scope) separately, check the qualified name instead. This is much shorter and similar to how it is done in the SymbolCollector tests. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: simark Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47847 llvm-svn: 335624
* [clangd] More precise representation of symbol names/labels in the index.Sam McCall2018-06-225-95/+65
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, the strings matched LSP completion pretty closely. The completion label was a single string, for instance. This made implementing completion itself easy but makes it hard to use the names in other way, e.g. pretty-printed name in synthesized documentation/hover. It also limits our introspection into completion items, which can only be as precise as the indexed symbols. This change is a prerequisite to improvements to overload bundling which need to inspect e.g. signature structure. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48475 llvm-svn: 335360
* [clangd] Expose qualified symbol names in CompletionItem (C++ structure ↵Eric Liu2018-06-221-0/+12
| | | | | | | | | | | | | | | | | | | | only, no json). Summary: The qualified name can be used to match a completion item to its corresponding symbol. This can be useful for tools that measure code completion quality. Qualified names are not precise for identifying symbols; we need to figure out a better way to identify completion items. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48425 llvm-svn: 335334
* [clangd] Remove FilterText from the index.Sam McCall2018-06-221-8/+0
| | | | | | | | | | | | | | | | | Summary: It's almost always identical to Name, and in fact we never used it (we used name instead). The only case where they differ is objc method selectors (foo: vs foo:bar:). We can live with the latter for both name and filterText, so I've made that change too. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48375 llvm-svn: 335321
* [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.Eric Liu2018-06-211-36/+81
| | | | | | | | | | | | | | Summary: This allows tools to examine symbols that would be collected in a symbol index. For example, a tool that measures index-based completion quality would be interested in references to symbols that are collected in the index. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48418 llvm-svn: 335218
* Fix double-float constant truncation warnings. NFCI.Simon Pilgrim2018-06-211-4/+4
| | | | llvm-svn: 335209
* [clangd] Use workspace root path as hint path for resolving URIs in ↵Eric Liu2018-06-193-3/+14
| | | | | | | | | | | | | | | | | | workspace/symbol Summary: Some URI schemes require a hint path to be provided, and workspace root path seems to be a good fit. Reviewers: sammccall, malaperle Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48290 llvm-svn: 335035
* Fix clangd test to pass when delayed template parsing is on by defaultReid Kleckner2018-06-181-0/+3
| | | | llvm-svn: 334973
* [clangd] UI for completion items that would trigger include insertion.Eric Liu2018-06-152-54/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For completion items that would trigger include insertions (i.e. index symbols that are not #included yet), add a visual indicator "+" before the completion label. The inserted headers will appear in the completion detail. Open to suggestions for better visual indicators; "+" was picked because it seems cleaner than a few other candidates I've tried (*, #, @ ...). The displayed header would be like a/b/c.h (without quote) or <vector> for system headers. I didn't add quotation or "#include" because they can take up limited space and do not provide additional information after users know what the headers are. I think a header alone should be obvious for users to infer that this is an include header.. To align indentation, also prepend ' ' to labels of candidates that would not trigger include insertions (only for completions where index results are possible). Vim: {F6357587} vscode: {F6357589} {F6357591} Reviewers: sammccall, ilya-biryukov, hokein Reviewed By: sammccall Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48163 llvm-svn: 334828
* [clangd] Add option to fold overloads into a single completion item.Sam McCall2018-06-151-0/+52
| | | | | | | | | | | | | | | | | | | | | Summary: Adds a CodeCompleteOption to folds together compatible function/method overloads into a single item. This feels pretty good (for editors with signatureHelp support), but has limitations. This happens in the code completion merge step, so there may be inconsistencies (e.g. if only one overload made it into the index result list, no folding). We don't want to bundle together completions that have different side-effects (include insertion), because we can't constructo a coherent CompletionItem. This may be confusing for users, as the reason for non-bundling may not be immediately obvious. (Also, the implementation seems a little fragile) Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47957 llvm-svn: 334822
* [clangd] Boost completion score according to file proximity.Eric Liu2018-06-151-4/+64
| | | | | | | | | | | | | | | | Summary: Also move unittest: URI scheme to TestFS so that it can be shared by different tests. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47935 llvm-svn: 334810
* [clangd] Customizable URI schemes for dynamic index.Eric Liu2018-06-156-62/+67
| | | | | | | | | | | | | | | | | Summary: This allows dynamic index to have consistent URI schemes with the static index which can have customized URI schemes, which would make file proximity scoring based on URIs easier. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47931 llvm-svn: 334809
* [clangd] Do not report comments that only have special chars.Ilya Biryukov2018-06-151-0/+59
| | | | | | | | | | | | | | | | | | | | | Summary: Like the following: // ------- // ======= // ******* It does not cover all the cases, but those are definitely not very useful. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48171 llvm-svn: 334807
* [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"Sam McCall2018-06-142-42/+34
| | | | | | | | | | | | | | | | | Summary: This is a small code change but vastly reduces noise in code completion results. The intent of allowing this was to let [sc] ~ "strncpy" and [strcpy] ~ "strncpy" however the benefits for unsegmented names aren't IMO worth the costs. Test cases should be representative of the changes here. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47950 llvm-svn: 334712
* [clangd] Boost keyword completions.Sam McCall2018-06-141-1/+7
| | | | | | | | | | | | Summary: These have few signals other than being keywords, so the boost is high. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48083 llvm-svn: 334711
* Reverting r334604 due to failing tests.Aaron Ballman2018-06-132-610/+0
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/31500 llvm-svn: 334606
* Add a new class to analyze whether an expression is mutated within a statement.Aaron Ballman2018-06-132-0/+610
| | | | | | | | ExprMutationAnalyzer is a generally useful helper that can be used in different clang-tidy checks for checking whether a given expression is (potentially) mutated within a statement (typically the enclosing compound statement.) This is a more general and more powerful/accurate version of isOnlyUsedAsConst, which is used in ForRangeCopyCheck, UnnecessaryCopyInitialization. Patch by Shuai Wang llvm-svn: 334604
* [clangd] Move caching of compile args out of ClangdServer.Ilya Biryukov2018-06-133-27/+8
| | | | | | | | | | | | | | | | | | | | | Summary: Caching is now handled by ClangdLSPServer and hidden behind the GlobalCompilationDatabase interface. This simplifies ClangdServer. This change also removes the SkipCache flag from addDocument, which is now obsolete. No behavioral changes are intended, the clangd binary still caches the compile commands on the first read. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48068 llvm-svn: 334585
* [clangd] Require case-insensitive prefix match for macro completions.Sam McCall2018-06-081-1/+3
| | | | | | | | | | | | Summary: Macros are terribly spammy at the moment and this offers some relief. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47936 llvm-svn: 334287
* [clangd] Downrank symbols with reserved names (score *= 0.1)Sam McCall2018-06-081-5/+12
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: klimek, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47707 llvm-svn: 334274
* [clangd] Code completion: drop explicit injected names/operators, ignore ↵Sam McCall2018-06-072-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema priority Summary: Now we have most of Sema's code completion signals incorporated in Quality, which will allow us to give consistent ranking to sema/index results. Therefore we can/should stop using Sema priority as an explicit signal. This fixes some issues like namespaces always having a terrible score. The most important missing signals are: - Really dumb/rarely useful completions like: SomeStruct().^SomeStruct SomeStruct().^operator= SomeStruct().~SomeStruct() We already filter out destructors, this patch adds injected names and operators to that list. - type matching the expression context. Ilya has a plan to add this in a way that's compatible with indexes (design doc should be shared real soon now!) Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47871 llvm-svn: 334192
* [clangd] Make workspace/symbols actually rank its results.Sam McCall2018-06-071-3/+13
| | | | | | | | | | | | Summary: The index doesn't actually return results in ranked order. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47821 llvm-svn: 334162
* [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is ↵Sam McCall2018-06-062-10/+24
| | | | | | | | | | | | | | the full identifier name. Summary: Fix a couple of bugs in tests an in Quality to keep tests passing. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47815 llvm-svn: 334089
* Adjust symbol score based on crude symbol type.Sam McCall2018-06-061-0/+9
| | | | | | | | | | | | Summary: Numbers are guesses to be adjusted later. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47787 llvm-svn: 334074
* [clangd] Boost code completion results that are narrowly scoped (local, members)Sam McCall2018-06-053-1/+43
| | | | | | | | | | | | | | | | | | Summary: This signal is considered a relevance rather than a quality signal because it's dependent on the query (the fact that it's completion, and implicitly the query context). This is part of the effort to reduce reliance on Sema priority, so we can have consistent ranking between Index and Sema results. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47762 llvm-svn: 334026
* [clangd] Add "member" symbols to the indexMarc-Andre Laperle2018-06-054-40/+189
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds more symbols to the index: - member variables and functions - enum constants in scoped enums The code completion behavior should remain intact but workspace symbols should now provide much more useful symbols. Other symbols should be considered such as the ones in "main files" (files not being included) but this can be done separately as this introduces its fair share of problems. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: ioeric, sammccall Reviewed By: ioeric, sammccall Subscribers: hokein, sammccall, jkorous, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits Differential Revision: https://reviews.llvm.org/D44954 llvm-svn: 334017
* [clangd] Test tweaks (consistency, shorter, doc). NFCSam McCall2018-06-052-33/+23
| | | | llvm-svn: 334014
* Silence a "truncation from double to float" diagnostic in MSVC; NFC.Aaron Ballman2018-06-051-1/+1
| | | | llvm-svn: 334013
* [clangd] Boost scores for decls from current file in completionIlya Biryukov2018-06-041-10/+43
| | | | | | | | | | | | | | Summary: This should, arguably, give better ranking. Reviewers: ioeric, sammccall Reviewed By: sammccall Subscribers: mgorny, klimek, MaskRay, jkorous, mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D46943 llvm-svn: 333906
* [clangd] Fix inverted test (--gtest_filter strikes again...)Sam McCall2018-06-041-1/+1
| | | | llvm-svn: 333897
* [clang][tooling] Don't forget to link to clangToolingInclusions.Roman Lebedev2018-06-041-0/+1
| | | | | | | Fixes build with shared libs, broken by rL333874. Some buildbot converage is sorely missing. llvm-svn: 333891
* [clangd] Avoid indexing decls associated with friend decls.Eric Liu2018-06-041-0/+42
| | | | | | | | | | | | | | | | | | | | Summary: These decls are sometime used as the canonical declarations (e.g. for go-to-def), which seems to be bad. - friend decls that are not definitions should be ignored for indexing purposes - this means they should never be selected as canonical decl - if the friend decl is the only decl, then the symbol should not be indexed Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47623 llvm-svn: 333885
* [clangd] Hover should return null when not hovering over anything.Sam McCall2018-06-042-3/+15
| | | | | | | | | | | | Summary: Also made JSON serialize Optional<T> to simplify this. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47701 llvm-svn: 333881
* [clangd] Keep only a limited number of idle ASTs in memoryIlya Biryukov2018-06-012-29/+87
| | | | | | | | | | | | | | | | | | | | | | | Summary: After this commit, clangd will only keep the last 3 accessed ASTs in memory. Preambles for each of the opened files are still kept in memory to make completion and AST rebuilds fast. AST rebuilds are usually fast enough, but having the last ASTs in memory still considerably improves latency of operations like findDefinition and documeneHighlight, which are often sent multiple times a second when moving around the code. So keeping some of the last accessed ASTs in memory seems like a reasonable tradeoff. Reviewers: sammccall Reviewed By: sammccall Subscribers: malaperle, arphaman, klimek, javed.absar, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47063 llvm-svn: 333737
* [clangd] Add forgotten include guard to TestFS.h. NFCIlya Biryukov2018-05-301-0/+3
| | | | llvm-svn: 333548
* [clangd] Avoid inserting new #include when declaration is present in the ↵Eric Liu2018-05-301-3/+33
| | | | | | | | | | | | | | | | | main file. Summary: Also fix USR generation for classes in unit tests. The previous USR only works for class members, which happens to work when completing class name inside the class, where constructors are suggested by sema. Reviewers: sammccall, ilya-biryukov Subscribers: klimek, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47466 llvm-svn: 333519
* [clangd] Remove the outdated comment. NFCIlya Biryukov2018-05-281-1/+0
| | | | llvm-svn: 333373
* [clangd] Remove accessors for top-level decls from preambleIlya Biryukov2018-05-281-17/+18
| | | | | | | | | | | | | | | | | | | | | | Summary: They cause lots of deserialization and are not actually used. The ParsedAST accessor that previously returned those was renamed from getTopLevelDecls to getLocalTopLevelDecls in order to avoid confusion. This change should considerably improve the speed of findDefinition and other features that try to find AST nodes, corresponding to the locations in the source code. Reviewers: ioeric, sammccall Reviewed By: sammccall Subscribers: klimek, mehdi_amini, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47331 llvm-svn: 333371
* [clangd] Fix leak sanitizers warnings in clangdIlya Biryukov2018-05-281-0/+20
| | | | | | | | | | | | | | | | The commit includes two changes: 1. Set DisableFree to false when building the ParsedAST. This is sane default, since clangd never wants to leak the AST. 2. Make sure CompilerInstance created in code completion is passed to the FrontendAction::BeginSourceFile call. We have to do this to make sure the memory buffers of remapped files are properly freed. Our tests do not produce any warnings under asan anymore. The changes are mostly trivial, just moving the code around. So sending without review. llvm-svn: 333370
* [clangd] Workaround the comments crash, reenable the test.Ilya Biryukov2018-05-281-1/+1
| | | | | | | | | | | This fix is still quite fragile, the underlying problem is that the code should not rely on source ranges coming from the preamble to be correct when reading from the text buffers. This is probably not possible to achieve in practice, so we would probably have to keep the contents of old headers around for the lifetime of the preamble. llvm-svn: 333369
* [clangd] Temporarily disable the test that crashes under asan.Ilya Biryukov2018-05-251-1/+2
| | | | | | | | | It turns out that our fix did not solve the problem completely and the crash due to stale preamble is still there under asan. Disabling the test for now, will reenable it when landing a proper fix for the problem. llvm-svn: 333280
* [clangd] Build index on preamble changes instead of the AST changesIlya Biryukov2018-05-243-8/+65
| | | | | | | | | | | | | | | | | | | | | Summary: This is more efficient and avoids data races when reading files that come from the preamble. The staleness can occur when reading a file from disk that changed after the preamble was built. This can lead to crashes, e.g. when parsing comments. We do not to rely on symbols from the main file anyway, since any info that those provide can always be taken from the AST. Reviewers: ioeric, sammccall Reviewed By: ioeric Subscribers: malaperle, klimek, javed.absar, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47272 llvm-svn: 333196
* [clangd] Serve comments for headers decls from dynamic index onlyIlya Biryukov2018-05-241-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To fix a crash in code completion that occurrs when reading doc comments from files that were updated after the preamble was computed. In that case, the files on disk could've been changed and we can't rely on finding the comment text with the same range anymore. The current workaround is to not provide comments from the headers at all and rely on the dynamic index instead. A more principled solution would be to store contents of the files read inside the preamble, but it is way harder to implement properly, given that it would definitely increase the sizes of the preamble. Together with D47272, this should fix all preamble-related crashes we're aware of. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47274 llvm-svn: 333189
* [clangd] Skip .inc headers when canonicalizing header #include.Eric Liu2018-05-241-3/+67
| | | | | | | | | | | | | | | | Summary: This assumes that .inc files are supposed to be included via headers that include them. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47187 llvm-svn: 333188
* [clangd] Fix code completion in MACROs with stringification.Eric Liu2018-05-241-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently, we only handle the first callback from sema code completion and ignore results from potential following callbacks. This causes causes loss of completion results when multiple contexts are tried by Sema. For example, we wouldn't get any completion result in the following completion as the first attemped context is natural language which has no candidate. The parser would backtrack and tried a completion with AST semantic, which would find candidate "::x". ``` void f(const char*, int); #define F(x) f(#x, x) int x; void main() { F(::^); } ``` To fix this, we only process a sema callback when it gives completion results or the context supports index-based completion. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47256 llvm-svn: 333174
* [clangd] Correctly handle IWYU prama with verbatim #include header.Eric Liu2018-05-221-0/+15
| | | | llvm-svn: 332959
* Trying to fix clang-move tests on windows build bot broken by r332717Eric Liu2018-05-181-17/+18
| | | | | | http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10702 llvm-svn: 332732
* Silence more truncation warnings; NFC.Aaron Ballman2018-05-181-5/+5
| | | | llvm-svn: 332723
* [clangd] Parse all comments in Sema and completion.Ilya Biryukov2018-05-161-0/+24
| | | | | | | | | | | | | | | | | | | | | Summary: And add tests for the comment extraction code. clangd will now show non-doxygen comments in completion for results coming from Sema and Dynamic index. Static index does not include the comments yet, I will enable it in a separate commit after investigating which implications it has for the size of the index. Reviewers: sammccall, hokein, ioeric Reviewed By: sammccall Subscribers: klimek, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D46002 llvm-svn: 332460
OpenPOWER on IntegriCloud