summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Support UTF-32 (i.e. codepoint) offsets.Sam McCall2019-03-281-0/+87
| | | | | | | | | | | | | | | | Summary: (Changes to UTF-8/UTF-16 here are NFC, moving things around to make the cases more symmetrical) Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59927 llvm-svn: 357173
* [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extensionSam McCall2019-03-271-6/+47
| | | | | | | | | | | | | | | | Summary: Still some pieces to go here: unit tests for new SourceCode functionality and a command-line flag to force utf-8 mode. But wanted to get early feedback. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58275 llvm-svn: 357102
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-256-5/+5
| | | | | | | | | | | Makes the name of this directory consistent with the names of the other directories in clang-tools-extra. Similar to r356254. No intended behavior change. Differential Revision: https://reviews.llvm.org/D59750 llvm-svn: 356897
* [clang-tidy] Move all checks to the new registerPPCallbacks APIAlexander Kornienko2019-03-222-6/+7
| | | | llvm-svn: 356796
* Fix clang-move test.Alexander Kornienko2019-03-221-1/+1
| | | | llvm-svn: 356795
* Revert "[clangd] Print arguments in template specializations"Jordan Rupprecht2019-03-203-92/+45
| | | | | | This reverts commit 44a63f6a150dec72dea43730d2a89d292e58bd6f. It segfaults on an internal test case (will follow up off thread). llvm-svn: 356623
* [clangd] Print arguments in template specializationsKadir Cetinkaya2019-03-203-45/+92
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59354 llvm-svn: 356541
* [clangd] Add support for type hierarchy (super types only for now)Kadir Cetinkaya2019-03-193-0/+530
| | | | | | | | | | | | | | | | | | | | | | | Summary: Patch by Nathan Ridge(@nridge)! This is an LSP extension proposed here: https://github.com/Microsoft/vscode-languageserver-node/pull/426 An example client implementation can be found here: https://github.com/theia-ide/theia/pull/3802 Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet Tags: #clang Differential Revision: https://reviews.llvm.org/D56370 llvm-svn: 356445
* [clangd] Remove includes of "gmock-matchers.h". NFCIlya Biryukov2019-03-152-2/+0
| | | | | | For consistency with most of the test code. llvm-svn: 356264
* [clangd] Tune the fuzzy-matching algorithmIlya Biryukov2019-03-151-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To reduce the gap between prefix and initialism matches. The motivation is producing better scoring in one particular example, but the change does not seem to cause large regressions in other cases. The examples is matching 'up' against 'unique_ptr' and 'upper_bound'. Before the change, we had: - "[u]nique_[p]tr" with a score of 0.3, - "[up]per_bound" with a score of 1.0. A 3x difference meant that symbol quality signals were almost always ignored and 'upper_bound' was always ranked higher. However, intuitively, the match scores should be very close for the two. After the change we have the following scores: - "[u]nique_[p]tr" with a score of 0.75, - "[up]per_bound" with a score of 1.0. Reviewers: ioeric Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59300 llvm-svn: 356261
* Rename directory housing clang-change-namespace to be eponymousNico Weber2019-03-153-2/+2
| | | | | | | | | Makes the name of this directory consistent with the names of the other directories in clang-tools-extra. Differential Revision: https://reviews.llvm.org/D59382 llvm-svn: 356254
* [clangd] Store explicit template specializations in index for code ↵Kadir Cetinkaya2019-03-143-8/+88
| | | | | | | | | | | | | | | | | | | | | | | | | navigation purposes Summary: This introduces ~4k new symbols, and ~10k refs for LLVM. We need that information for providing better code navigation support: - When references for a class template is requested, we should return these specializations as well. - When children of a specialization is requested, we should be able to query for those symbols(instead of just class template) Number of symbols: 378574 -> 382784 Number of refs: 5098857 -> 5110689 Reviewers: hokein, gribozavr Reviewed By: gribozavr Subscribers: nridge, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59083 llvm-svn: 356125
* [clangd] Remove ./ and ../ in the file pathsKadir Cetinkaya2019-03-081-0/+33
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59084 llvm-svn: 355681
* [clangd] Make sure constructors do not reference classKadir Cetinkaya2019-03-081-0/+9
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58815 llvm-svn: 355679
* [clangd] Adjust compile commands to be applicable for toolingKadir Cetinkaya2019-03-081-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385 clang tool invocations adjust commands normally like this. In clangd we have different code paths for invoking a frontend action(preamble builds, ast builds, background index, clangd-indexer) they all work on the same GlobalCompilationDatabase abstraction, but later on are subject to different modifications. This patch makes sure all of the clangd actions make use of the same compile commands before invocation. Enables background-index to work on chromium codebase(since they had dependency file output in their compile commands). Reviewers: gribozavr, hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59086 llvm-svn: 355669
* [clangd] Add Source to clangd::Diagnostic.Haojian Wu2019-03-061-0/+17
| | | | | | | | | | | | | | | Summary: clangd embedder can distinguish diagnostics from clang or clang-tidy. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58600 llvm-svn: 355493
* Fix file headers. NFCFangrui Song2019-03-015-5/+5
| | | | llvm-svn: 355188
* [clangd] Improve global code completion when scope specifier is unresolved.Eric Liu2019-02-271-2/+33
| | | | | | | | | | | | | | | | | | | | | | | Summary: Suppose `clangd::` is unresolved in the following example. Currently, we simply use "clangd::" as the query scope. We can do better by combining with accessible scopes in the context. The query scopes can be `{clangd::, clang::clangd::}`. ``` namespace clang { clangd::^ } ``` Reviewers: ilya-biryukov, sammccall, hokein, kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58448 llvm-svn: 354963
* [clangd] Index UsingDeclsKadir Cetinkaya2019-02-264-8/+35
| | | | | | | | | | | | | | | | Summary: D58340 enables indexing of USRs, this makes sure test in clangd are aligned with the change Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58341 llvm-svn: 354879
* [clangd] Drop documentation in static index if symbols are not indexed for ↵Haojian Wu2019-02-251-0/+31
| | | | | | | | | | | | | | | | | | | completion. Summary: This is a further optimization of r350803, we drop docs in static index for symbols not being indexed for completion, while keeping the docs in dynamic index (we rely on dynamic index to get docs for class members). Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56539 llvm-svn: 354792
* [clangd] Enhance macro hover to see full definitionMarc-Andre Laperle2019-02-241-1/+19
| | | | | | | | | | | | | | | | Summary: Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com> Reviewers: simark, ilya-biryukov, sammccall, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D55250 llvm-svn: 354761
* [clangd] Don't attach FixIt to the source code in macro.Haojian Wu2019-02-221-0/+12
| | | | | | | | | | | | | | | | | | Summary: We are less certain it is the correct fix. Also, clang doesn't apply FixIt to the source code in macro. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58525 llvm-svn: 354664
* [clangd] Only report explicitly typed symbols during code navigationKadir Cetinkaya2019-02-212-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Clangd was reporting implicit symbols, like results of implicit cast expressions during code navigation, which is not desired. For example: ``` struct Foo{ Foo(int); }; void bar(Foo); vod foo() { int x; bar(^x); } ``` Performing a GoTo on the point specified by ^ would give two results one pointing to line `int x` and the other for definition of `Foo(int);` Reviewers: ilya-biryukov, sammccall Subscribers: ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58495 llvm-svn: 354585
* [clangd] Enable indexing of template type parametersKadir Cetinkaya2019-02-212-5/+9
| | | | | | | | | | | | | | Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36285 Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58294 llvm-svn: 354561
* [clangd] Handle another incomplete-type diagnostic case in IncludeFixer.Eric Liu2019-02-211-0/+5
| | | | llvm-svn: 354558
* [clangd] Fix a crash in SelectionIlya Biryukov2019-02-201-0/+5
| | | | | | | | | | | | | | | | | | | Summary: The assertion checking that a range of a node is a token range does not hold in case of "split" tokens, e.g. between two closing template argument lists (`vector<vector<int>>`). Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58447 llvm-svn: 354507
* [clangd] Revert r354442 and r354444Kadir Cetinkaya2019-02-201-34/+0
| | | | | | Looks like sysroot is only working on linux. llvm-svn: 354453
* [clangd] Try to fix windows build botsKadir Cetinkaya2019-02-201-3/+8
| | | | llvm-svn: 354444
* [clangd] Testcase for bug 39811Kadir Cetinkaya2019-02-201-0/+29
| | | | | | | | | | Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58133 llvm-svn: 354442
* [clangd] Handle unresolved scope specifier when fixing includes.Eric Liu2019-02-191-4/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In the following examples, "clangd" is unresolved, and the fixer will try to fix include for `clang::clangd`; however, clang::clangd::X is usually intended. So when handling a qualifier that is unresolved, we change the unresolved name and scopes so that the fixer will fix "clang::clangd::X" in the following example. ``` namespace clang { clangd::X ~~~~~~ } // or clang::clangd::X ~~~~~~ ``` Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58185 llvm-svn: 354330
* [clangd] Add tests for template specializationsKadir Cetinkaya2019-02-181-0/+52
| | | | | | | | | | Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58190 llvm-svn: 354272
* [clangd] Cache include fixes for diagnostics caused by the same unresolved ↵Eric Liu2019-02-181-0/+38
| | | | | | | | | | | | | | | | | | | | | | name or incomplete type. Summary: Multiple diagnostics can be caused by the same unresolved name or incomplete type, especially if the code is copy-pasted without #includes. The cache can avoid making repetitive index requests, and thus reduce latency and allow more diagnostics to be fixed (we limit the number of index requests for each parse). Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58239 llvm-svn: 354268
* [clangd] Handle a few more diag kinds in include fixer.Eric Liu2019-02-131-4/+15
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58135 llvm-svn: 353926
* Revamp the "[clangd] Format tweak's replacements"Haojian Wu2019-02-111-36/+4
| | | | | | | | | | | | | | | | | | | | Summary: This patch contains two parts: 1) reverts commit r353306. 2) move the format logic out from tweaks, keep tweaks API unchanged. Reviewers: sammccall, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58051 llvm-svn: 353712
* [clangd] Prefer location from codegen files when merging symbols.Eric Liu2019-02-112-0/+36
| | | | | | | | | | | | | | | | | | | Summary: For example, if an index symbol has location in a .proto file and an AST symbol has location in a generated .proto.h file, then we prefer location in .proto which is more meaningful to users. Also use `mergeSymbols` to get the preferred location between AST location and index location in go-to-def. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58037 llvm-svn: 353708
* [clangd] Index parameters in function declsKadir Cetinkaya2019-02-112-0/+10
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57950 llvm-svn: 353696
* [clangd] Fix broken windows build bots.Kadir Cetinkaya2019-02-111-2/+2
| | | | llvm-svn: 353694
* [clangd] Make system header mappings available for PreambleParsedCallbackKadir Cetinkaya2019-02-111-0/+33
| | | | | | | | | | | | | | | | | | Summary: SystemHeaderMappings were added only after takeIncludes call, which resulted in getting mapping on main file ast updates but not on preamble ast updates. Fixes https://github.com/clangd/clangd/issues/8 Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58029 llvm-svn: 353687
* [clangd] Fix an assertion in TypoCorrection.Eric Liu2019-02-081-0/+15
| | | | | | | | | | | | | | Summary: https://github.com/clangd/clangd/issues/7 Reviewers: sammccall, hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57944 llvm-svn: 353514
* [clangd] Fix an assertion failure in Selection.Haojian Wu2019-02-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The assertion is triggered when the Decl is null. Details for the assertion: F0207 09:55:09.069385 47308 logging.cc:84] assert.h assertion failed at llvm/include/llvm/Support/Casting.h:105 in static bool llvm::isa_impl_cl<clang::TranslationUnitDecl, const clang:: Decl *>::doit(const From *) [To = clang::TranslationUnitDecl, From = const clang::Decl *]: Val && "isa<> used on a null pointer" 15 *** Check failure stack trace: *** 19 @ 0x55615c1f7e06 __assert_fail 20 @ 0x55615a6297d8 clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl() 21 @ 0x55615a62f48d clang::RecursiveASTVisitor<>::TraverseTemplateTemplateParmDecl() 22 @ 0x55615a62b264 clang::RecursiveASTVisitor<>::TraverseDecl() 23 @ 0x55615a62979c clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl() 24 @ 0x55615a63060c clang::RecursiveASTVisitor<>::TraverseClassTemplatePartialSpecializationDecl() 25 @ 0x55615a62ae45 clang::RecursiveASTVisitor<>::TraverseDecl() Reviewers: sammccall Subscribers: javed.absar, kristof.beyls, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57879 llvm-svn: 353421
* [clangd] Suggest adding missing includes for typos (like include-fixer).Eric Liu2019-02-071-9/+86
| | | | | | | | | | | | | | | | | | | Summary: This adds include-fixer feature into clangd based on D56903. Clangd now captures diagnostics caused by typos and attach include insertion fixes to potentially fix the typo. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, MaskRay, javed.absar, ilya-biryukov, mgorny Tags: #clang Differential Revision: https://reviews.llvm.org/D57021 llvm-svn: 353380
* [clangd] Add type boost to fuzzy find in Dex.Eric Liu2019-02-061-0/+22
| | | | | | | | | | | | | | | | | | Summary: No noticeable impact on code completions overall except some improvement on cross-namespace completion. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57815 llvm-svn: 353310
* [clangd] Format tweak's replacements.Haojian Wu2019-02-061-4/+36
| | | | llvm-svn: 353306
* [clangd] Some minor fixes.Haojian Wu2019-02-062-5/+4
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57755 llvm-svn: 353283
* [clangd] Enable include insertion for static indexKadir Cetinkaya2019-02-043-10/+48
| | | | | | | | | | | | | | Summary: This enables include insertion by adding canonical includes into preambledata. Reviewers: ioeric, ilya-biryukov Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D57508 llvm-svn: 353054
* [clangd] Fix heap-use-after-free after r352868Eric Liu2019-02-021-5/+8
| | | | llvm-svn: 352957
* [clangd] Expose SelectionTree to code tweaks, and use it for swap if branches.Sam McCall2019-02-011-6/+41
| | | | | | | | | | | | | | | | | Summary: This reduces the per-check implementation burden and redundant work. It also makes checks range-aware by default (treating the commonAncestor as if it were a point selection should be good baseline behavior). Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet Tags: #clang Differential Revision: https://reviews.llvm.org/D57570 llvm-svn: 352876
* [clangd] Lib to compute and represent selection under cursor.Sam McCall2019-02-012-0/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The primary problem this solves is to expose the codeAction selection to AST-based refactorings in a way that makes it easy and efficient for them to bind to the right parts of the AST. It should also allow us to make XRefs based features (textDocument/definition) more robust, more easily implement textDocument/typeDefinition etc. As an example, template parameter references can be identified without special handling. There should be slight speedup too: we can prune most of the AST traversal in most cases. Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection. That captures a smaller set of AST nodes, has a slightly different way of representing selections, and generally has mare features and does more work. The overall shape is pretty similar, and yet I can't quite get to behave as I expect. Reviewers: ilya-biryukov, kadircet Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman Tags: #clang Differential Revision: https://reviews.llvm.org/D57562 llvm-svn: 352874
* [clangd] Penalize file-scope symbols in the ranking for non-completion queriesSam McCall2019-02-011-1/+11
| | | | | | | | Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D56653 llvm-svn: 352868
* [clangd] Implement textDocument/declaration from LSP 3.14Sam McCall2019-02-015-122/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: LSP now reflects the declaration/definition distinction. Language server changes: - textDocument/definition now returns a definition if one is found, otherwise the declaration. It no longer returns declaration + definition if they are distinct. - textDocument/declaration returns the best declaration we can find. - For macros, the active macro definition is returned for both methods. - For include directive, the top of the target file is returned for both. There doesn't appear to be a discovery mechanism (we can't return everything to clients that only know about definition), so this changes existing behavior. In practice, it should greatly reduce the fraction of the time we need to show the user a menu of options. C++ API changes: - findDefinitions is replaced by locateSymbolAt, which returns a vector<LocatedSymbol> - one for each symbol under the cursor. - this contains the preferred declaration, the definition (if found), and the symbol name This API enables some potentially-neat extensions, like swapping between decl and def, and exposing the symbol name to the UI in the case of multiple symbols. Reviewers: hokein Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D57388 llvm-svn: 352864
OpenPOWER on IntegriCloud