summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy ObjC] [2/3] Support non-C++ files in ClangTidyTestHaojian Wu2017-10-261-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 2 of 3 of a series of changes to improve Objective-C linting in clang-tidy. Currently, `clang::tidy::test::runCheckOnCode()` assumes all files are C++ and unconditionally adds `-std=c++11` to the list of `clang-tidy` options. This updates the logic to check the extension of the source file and only add `-std=c++11` if the extension indicates C++ or Objective-C++. Depends On D39188 Test Plan: ninja ClangTidyTests && \ ./tools/clang/tools/extra/unittests/clang-tidy/ClangTidyTests Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: Wizard Differential Revision: https://reviews.llvm.org/D39189 llvm-svn: 316645
* [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checksHaojian Wu2017-10-262-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 1 of 3 of a series of changes to improve Objective-C linting in clang-tidy. This introduces a new clang-tidy module, `objc`, specifically for Objective-C / Objective-C++ checks. The module is currently empty; D39142 adds the first check. Test Plan: `ninja check-clang-tools` Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: Wizard, mgorny Differential Revision: https://reviews.llvm.org/D39188 llvm-svn: 316643
* [clangd] Allow to pass code completion opts to ClangdServer.Ilya Biryukov2017-10-231-12/+212
| | | | | | | | | | | | Reviewers: bkramer, krasimir, sammccall Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38731 llvm-svn: 316327
* [change-namespace] do not change type locs in defaulted functions.Eric Liu2017-10-161-0/+62
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38893 llvm-svn: 315892
* [clangd] Added async API to run code completion.Ilya Biryukov2017-10-051-5/+12
| | | | | | | | | | | | | | | | | | Summary: ClangdServer now provides async code completion API. It is still used synchronously by ClangdLSPServer, more work is needed to allow processing other requests in parallel while completion (or any other request) is running. Reviewers: klimek, bkramer, krasimir Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38583 llvm-svn: 314989
* [clangd] LSP extension to switch between source/header fileMarc-Andre Laperle2017-09-281-0/+79
| | | | | | | | | | | | | | | | | | Summary: Small extension to LSP to allow clients to use clangd to switch between C header files and source files. Final version will use the completed clangd indexer to use the index of symbols to be able to switch from header to source file when the file names don't match. Reviewers: malaperle, krasimir, bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, cfe-commits, arphaman Patch by: William Enright Differential Revision: https://reviews.llvm.org/D36150 llvm-svn: 314377
* [clangd] Serialize onDiagnosticsReady callbacks for the same file.Ilya Biryukov2017-09-201-0/+63
| | | | | | | | | | | | | | | | | Summary: Calls to onDiagnosticsReady were done concurrently before. This sometimes led to older versions of diagnostics being reported to the user after the newer versions. Reviewers: klimek, bkramer, krasimir Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38032 llvm-svn: 313754
* [clangd] Introduced Logger interface.Ilya Biryukov2017-09-201-8/+14
| | | | | | | | | | | | | | Summary: This fixes a bunch of logging-related FIXMEs. Reviewers: bkramer, krasimir, malaperle Reviewed By: malaperle Subscribers: malaperle, klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D37972 llvm-svn: 313730
* [clangd] Add support for snippet completionsIlya Biryukov2017-09-121-8/+13
| | | | | | | | | | | | | | Enhances CompletionItemsCollector in such a way that snippet completions can be presented to the client. Enable snippet completion items by specifying -enable-snippets while invoking the clangd executable. See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#completion-request See: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/browser/snippet.md Patch by Raoul Wols. llvm-svn: 313029
* [cmake] Support running extra clang tool tests without static analyzerMichal Gorny2017-08-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Support running the extra clang tool tests when the static analyzer is disabled. Disable the relevant clang-tidy tests and one include-fixer test that require it to work. Previously, the tests were disabled entirely with CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being enabled and the relevant tests are excluded and marked unsupported appropriately. In order to disable clang-tidy tests, the whole test directory is added to the exclude lists, to avoid having to explicitly add 'REQUIRES' line to every single test. If the other solution is preferable, I can update the patch. The yamldb_plugin include-fixer test is also updated to be disabled without static analyzer. It fails in that case because clang is not outputting a replacement suggestion -- but I don't know the exact reason why it does not do that. Differential Revision: https://reviews.llvm.org/D37188 llvm-svn: 311983
* Add braces to silence gcc dangling-else warnings. NFCI.Simon Pilgrim2017-08-141-2/+4
| | | | llvm-svn: 310830
* [clangd] Use multiple working threads in clangd.Ilya Biryukov2017-08-141-36/+306
| | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D36261 llvm-svn: 310821
* [clangd] Check if CompileCommand has changed on forceReparse.Ilya Biryukov2017-08-141-0/+47
| | | | | | | | | | | | Reviewers: krasimir, bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36398 llvm-svn: 310819
* [clang-tidy] Add a test.Alexander Kornienko2017-08-101-3/+9
| | | | llvm-svn: 310586
* [clang-tidy] Ignore newlines in checks listAlexander Kornienko2017-08-091-1/+1
| | | | | | | This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that LLVM YAML parser doesn't support multiline literal folding. llvm-svn: 310491
* ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.NAKAMURA Takumi2017-08-031-1/+2
| | | | llvm-svn: 309936
* [clangd] Rewrote AST and Preamble management.Ilya Biryukov2017-08-011-13/+48
| | | | | | | | | | | | | | Summary: The new implementation allows code completion that never waits for AST. Reviewers: bkramer, krasimir, klimek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36133 llvm-svn: 309696
* [clangd] Specified --gcc-toolchain explicitly in VFS test.Ilya Biryukov2017-07-211-5/+5
| | | | | | | In order to avoid platform-specific configuration quirks. (Possible fix for https://bugs.llvm.org/show_bug.cgi?id=33842) llvm-svn: 308721
* ClangApplyReplacementsTests: Add clangBasic in libdeps.NAKAMURA Takumi2017-07-151-0/+1
| | | | | | r308015 introduced clangBasic to instantiate Diagnostics &c, llvm-svn: 308085
* [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML outputAlexander Kornienko2017-07-142-0/+54
| | | | | | | | | | | | | | | | | | | | Summary: To get properly integration Clang-Tidy with CLion IDE, next things were implemented: * Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output. * Export all diagnostics, not just the ones with fixes * Test-cases Reviewers: alexfh, ilya-biryukov Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Vladimir Plyashkun! Differential Revision: https://reviews.llvm.org/D35349 llvm-svn: 308015
* [clangd] Add -ffreestanding on VFS tests.Ilya Biryukov2017-07-031-7/+16
| | | | | | | | | | | | | | | | | | Summary: They don't provide proper gcc installations and may fail on implicit <stdc-predef.h> include. Reviewers: klimek, krasimir, bkramer Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34936 llvm-svn: 307025
* [refactor] Move clang-rename into the clang repositoryAlex Lorenz2017-06-304-825/+0
| | | | | | | | | | | | The core engine of clang-rename will be used for local and global renames in the new refactoring engine, as mentioned in http://lists.llvm.org/pipermail/cfe-dev/2017-June/054286.html. The clang-rename tool is still supported but might get deprecated in the future. Differential Revision: https://reviews.llvm.org/D34696 llvm-svn: 306840
* [clangd] Run a test, searching for gcc install, only on Unix.Ilya Biryukov2017-06-291-0/+3
| | | | | | This should fix windows buildbots. llvm-svn: 306656
* [clangd] Added a test, checking that gcc install is searched via VFS.Ilya Biryukov2017-06-291-1/+62
| | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34755 llvm-svn: 306652
* [clang-tidy][Part1] Add a new module Android and three new checks.Yan Wang2017-06-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A common source of security bugs is code that opens a file descriptors without using the O_CLOEXEC flag. (Without that flag, an opened sensitive file would remain open across a fork+exec to a lower-privileged SELinux domain, leaking that sensitive data.). Add a new Android module and one checks in clang-tidy. -- open(), openat(), and open64() should include O_CLOEXEC in their flags argument. [android-file-open-flag] Links to part2 and part3: https://reviews.llvm.org/D33745 https://reviews.llvm.org/D33747 Reviewers: chh, alexfh, aaron.ballman, hokein Reviewed By: alexfh, hokein Subscribers: jbcoe, joerg, malcolm.parsons, Eugene.Zelenko, srhines, mgorny, xazax.hun, cfe-commits, krytarowski Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33304 llvm-svn: 306165
* [clangd] Add a filename parameter to FileSystemProvider.Ilya Biryukov2017-06-141-2/+14
| | | | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34151 llvm-svn: 305376
* [clangd] Store references instead of unique_ptrs in ClangdServer.Ilya Biryukov2017-06-131-61/+46
| | | | | | | | | | | | | | | | Summary: ClangdServer owned objects passed to it in constructor for no good reason. Lots of stuff was moved from the heap to the stack thanks to this change. Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34148 llvm-svn: 305298
* [clangd] Allow to override contents of the file during completion.Ilya Biryukov2017-06-131-0/+64
| | | | | | | | | | | | | | | | Summary: This is a reapplied r305280 with a fix to the crash found by build bots (StringRef to an out-of-scope local std::string). Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34146 llvm-svn: 305291
* Revert "[clangd] Allow to override contents of the file during completion."Ilya Biryukov2017-06-131-64/+0
| | | | | | | This caused buildbots failures, reverting until we'll find out what's wrong. llvm-svn: 305283
* [clangd] Allow to override contents of the file during completion.Ilya Biryukov2017-06-131-0/+64
| | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34107 llvm-svn: 305280
* [clangd] Use 'std::string' for VFSTag instead of 'int'Ilya Biryukov2017-06-131-2/+2
| | | | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34106 llvm-svn: 305279
* clang-rename: add new -force optionMiklos Vajna2017-06-021-1/+1
| | | | | | | | | | | | | | | | | Summary: The use-case is when renaming a widely used name, like a lower-level class in a codebase and clang-rename is simply invoked for each translation unit based on the compile database. In this case it's not interesting to show errors: not finding the symbol means there is simply nothing to do. Reviewers: klimek Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D32403 llvm-svn: 304534
* [clangd] Mark results of clangd requests with a tag provided by the ↵Ilya Biryukov2017-05-301-4/+36
| | | | | | | | | | | | | | | | | | | | FileSystemProvider. Summary: This allows an implementation of FileSystemProvider that can track which vfs::FileSystem were used for each of the requests. Reviewers: bkramer, krasimir Reviewed By: bkramer Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33678 llvm-svn: 304214
* ClangdTests.cpp: Use "clang/Config/config.h" instead of "llvm/Config/config.h".NAKAMURA Takumi2017-05-271-1/+1
| | | | llvm-svn: 304082
* ClangdTests.cpp: Fix a possible typo, it was "if (TmpDir2 != TmpDir2)"NAKAMURA Takumi2017-05-271-1/+1
| | | | | | It caused failures in unittests if TmpDir2 is not "/tmp" . llvm-svn: 304067
* [clangd] Attempt to fix tests failing on WindowsIlya Biryukov2017-05-261-8/+14
| | | | llvm-svn: 303993
* [clangd] Allow to use vfs::FileSystem for file accesses.Ilya Biryukov2017-05-263-0/+389
| | | | | | | | | | | | | | | | Summary: Custom vfs::FileSystem is currently used for unit tests. This revision depends on https://reviews.llvm.org/D33397. Reviewers: bkramer, krasimir Reviewed By: bkramer, krasimir Subscribers: klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D33416 llvm-svn: 303977
* [clang-move] Find template class forward declarations more precisely.Haojian Wu2017-05-021-5/+16
| | | | | | | | | | | | Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D32741 llvm-svn: 301914
* Fix compiler warnings: "ISO c99 requires rest arguments to be used" onHaojian Wu2017-04-071-3/+3
| | | | | | the test file. llvm-svn: 299764
* Fix -Wmissing-field-initializer warnings to unbreak the -Werror buildDavid Blaikie2017-04-051-49/+65
| | | | llvm-svn: 299561
* [clang-rename] Support renaming qualified symbolHaojian Wu2017-04-043-49/+676
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The patch adds a new feature for renaming qualified symbol references. Unlike orginal clang-rename behavior, when renaming a qualified symbol to a new qualified symbol (e.g "A::Foo" => "B::Bar"), this new rename behavior will consider the prefix qualifiers of the symbol, and calculate the new prefix qualifiers. It aims to add as few additional qualifiers as possible. As this is an early version (only supports renaming classes), I don't change current clang-rename interfaces at the moment, and would like to keep its (command-line tool) behavior. So I added new interfaces for the prototype. In the long run, these interfaces should be unified. No functionality changes in original clang-rename command-line tool. This patch also contains a few bug fixes of clang-rename which are discovered by the new unittest: * fix a potential nullptr accessment when class declaration doesn't have definition. * add USRs of nested declartaions in "getNamedDeclFor". Reviewers: ioeric Reviewed By: ioeric Subscribers: alexfh, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D31176 llvm-svn: 299419
* [clang-tidy] Fix treating non-space whitespaces in checks list.Marek Kurdej2017-03-231-87/+94
| | | | | | | | | | | | | | | | Summary: This furtherly improves r295303: [clang-tidy] Ignore spaces between globs in the Checks option. Trims all whitespaces and not only spaces and correctly computes the offset of the checks list (taking the size before trimming). Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D30567 llvm-svn: 298621
* [change-namespace] avoid adding leading '::' when possible.Eric Liu2017-03-211-45/+86
| | | | | | | | | | | | | | | | | | | | Summary: When changing namespaces, the tool adds leading "::" to references that need to be fully-qualified, which would affect readability. We avoid adding "::" when the symbol name does not conflict with the new namespace name. For example, a symbol name "na::nb::X" conflicts with "ns::na" since it would be resolved to "ns::na::nb::X" in the new namespace. Reviewers: hokein Reviewed By: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30493 llvm-svn: 298363
* [change-namespace] do not rename specialized template parameters.Eric Liu2017-03-171-0/+46
| | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31076 llvm-svn: 298090
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-132-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add fuzzy SymbolIndex, where identifier needn't match exactly. The purpose for this is global autocomplete in clangd. The query will be a partial identifier up to the cursor, and the results will be suggestions. It's in include-fixer because: - it handles SymbolInfos, actually SymbolIndex is exactly the right interface - it's a good harness for lit testing the fuzzy YAML index - (Laziness: we can't unit test clangd until reorganizing with a tool/ dir) Other questionable choices: - FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is an interface to allow extension to large monorepos (*cough*) - an always-true safety check that Identifier == Name is removed from SymbolIndexManager, as it's not true for fuzzy matching - exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though. Reviewers: bkramer Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D30720 llvm-svn: 297630
* [clang-rename] Introduce an unittest skeleton for clang-rename.Haojian Wu2017-03-103-0/+182
| | | | | | | | | | | | | | Summary: This will make references rename tests easier. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits, alexfh, mgorny Differential Revision: https://reviews.llvm.org/D30813 llvm-svn: 297450
* [include-fixer] Remove line number from Symbol identitySam McCall2017-03-092-166/+158
| | | | | | | | | | | | | | | | | | | Summary: Remove line number from Symbol identity. For our purposes (include-fixer and clangd autocomplete), function overloads within the same header should mostly be treated as a single combined symbol. We may want to track individual occurrences (line number, full type info) and aggregate this during mapreduce, but that's not done here. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30685 llvm-svn: 297371
* [change-namespace] get insertion points of forward declarations correct.Eric Liu2017-03-011-0/+30
| | | | | | | | | | | | | | | | Summary: Previously, the insertion points would conflict with the old namespace deletion. Reviewers: hokein Reviewed By: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30490 llvm-svn: 296604
* [include-fixer] Add usage count to find-all-symbols.Sam McCall2017-02-282-82/+194
| | | | | | | | | | | | | | | | | | | | | | | Summary: Add usage count to find-all-symbols. FindAllSymbols now finds (most!) main-file usages of the discovered symbols. The per-TU map output has NumUses=0 or 1 (only one use per file is counted). The reducer aggregates these to find the number of files that use a symbol. The NumOccurrences is now set to 1 in the mapper rather than being inferred by the reducer, for consistency. The idea here is to use NumUses for ranking: intuitively number of files that use a symbol is more meaningful than number of files that include the header. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30210 llvm-svn: 296446
* [clang-move] Extend clang-move to support moving global variable.Haojian Wu2017-02-271-1/+4
| | | | | | | | | | | | | | Summary: Also support dumping global variables. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30337 llvm-svn: 296337
OpenPOWER on IntegriCloud