summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Qualify uses of ::testing everywhere. NFCIlya Biryukov2019-05-0615-113/+110
| | | | | | | | | Add an initial '::' qualifier to all usages of 'testing' namespace that did not have one. The goal is to make our code style in tests more consistent. llvm-svn: 360026
* [clangd] Always call getFormatStyleForFile().Sam McCall2019-05-062-8/+9
| | | | | | | | | | This means "format" will no longer return an error if the -fallback-style flag is invalid, it will log and use LLVM style. This doesn't really matter. Also document the dependence on global variables. (This patch is a compromise - it's probably not worth actually avoiding the globals). llvm-svn: 360020
* [clangd] Support -fallback-style, similar to clang-format.Sam McCall2019-05-061-0/+9
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61519 llvm-svn: 360016
* Fix test to avoid assuming clang will diagnose problems in unreachable code.Richard Smith2019-05-061-0/+2
| | | | llvm-svn: 360009
* Fix up after r360006.Richard Smith2019-05-061-1/+1
| | | | llvm-svn: 360007
* [clang-tidy] openmp-exception-escape check: point to the structured-blockRoman Lebedev2019-05-052-8/+8
| | | | | | | | | | | | | I'm not sure what i was thinking when i wrote it to point at the directive. It's at the very least confusing, and in the `for` is very misleading. We should point at the actual Stmt out of which the exception escapes, to highlight where it should be fixed e.g. via adding try-catch block. Yes, this breaks existing NOLINT, which is why this change needs to happen now, not any later. llvm-svn: 360002
* [clangd] Fix header-guard check for include insertion, and don't index ↵Sam McCall2019-05-035-43/+84
| | | | | | | | | | | | | | | | | | | | | header guards. Summary: Both of these attempt to check whether a header guard exists while parsing the file. However the file is only marked as guarded once clang finishes processing it. We defer the checks and work until SymbolCollector::finish(). This is ugly and ad-hoc, deferring *all* work might be cleaner. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61442 llvm-svn: 359880
* Added an AST matcher for declarations that are in the `std` namespaceDmitri Gribenko2019-05-031-4/+0
| | | | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61480 llvm-svn: 359876
* [clangd] Also perform merging for symbol definitionsKadir Cetinkaya2019-05-032-17/+33
| | | | | | | | | | | | | | | | | | Summary: clangd currently prefers declarations from codegen files. This patch implements that behavior for definition locations. If we have definiton locations both coming from AST and index, clangd will perform a merging to show the codegen file if that's the case. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61126 llvm-svn: 359874
* [clangd] Minor code style cleanups in Protocol.h. NFCIlya Biryukov2019-05-031-6/+5
| | | | | | | | | | - Remove a parameter name that was misspelled (OS used for non-stream parameter) - Declare operator == (TextEdit, TextEdit) outside the struct, for consistency with other user-declared ops in our code. - Fix naming style of a parameter. llvm-svn: 359866
* [clangd][xpc] Cannonicalize value of CLANGD_BUILD_XPC before cachingJan Korous2019-05-021-0/+2
| | | | llvm-svn: 359824
* Fixed: Duck-typing in readability-redundant-smartptr-get didn't catch MSVC ↵Florian Gross2019-05-022-13/+110
| | | | | | | | STL smart pointers. Differential Revision: https://reviews.llvm.org/D61209 llvm-svn: 359801
* Reapply r359778: [clangd] Fix code completion of macros defined in the ↵Sam McCall2019-05-025-13/+97
| | | | | | | | | preamble region of the main file. The bad assert has been removed, and updateOutOfDateIdentifier has been guarded. This reverts commit r359796. llvm-svn: 359799
* Revert rL359778 : [clangd] Fix code completion of macros defined in the ↵Simon Pilgrim2019-05-025-97/+13
| | | | | | | | | | | | | | | | | | | | | | preamble region of the main file. Summary: This is a tricky case (we baked the assumption that symbols come from the preamble xor mainfile pretty deeply) and the fix is a bit of a hack: We look at the code to guess the macro names, and deserialize them from the preamble "by hand". Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60937 ........ Fix buildbots http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/47684/ llvm-svn: 359796
* [clangd] Fix code completion of macros defined in the preamble region of the ↵Sam McCall2019-05-025-13/+97
| | | | | | | | | | | | | | | | | | | | main file. Summary: This is a tricky case (we baked the assumption that symbols come from the preamble xor mainfile pretty deeply) and the fix is a bit of a hack: We look at the code to guess the macro names, and deserialize them from the preamble "by hand". Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60937 llvm-svn: 359778
* [clangd] Improvements to header mapping: more precise parsing of ↵Sam McCall2019-05-023-15/+105
| | | | | | | | | | | | | | | | | | | | | | cppreference symbol pages. Summary: Previously we were just jumping from the symbol index to the symbol page, and grabbing all the headers mentioned there. But the page often lists multiple symbols, and so we got false positives and thus ambiguities (which were dropped). Now we look at which declarations are for the symbol we want, and prefer headers listed above that symbol. If there are none, we fall back to the old behavior. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61316 llvm-svn: 359771
* [clangd] Standard library mapping: prefer "primary" versions of functions ↵Sam McCall2019-05-023-9/+54
| | | | | | | | | | | | | | over variants. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61349 llvm-svn: 359770
* [clangd] Restore conventional names for lit configs, and .in/.py split. Fix ↵Sam McCall2019-05-027-40/+76
| | | | | | build_mode indirection. llvm-svn: 359763
* [clangd] Delete an unused declarationFangrui Song2019-05-011-3/+0
| | | | llvm-svn: 359674
* [clangd] gen_std uses multiprocessing pool to be fast. While here, log ↵Sam McCall2019-04-301-24/+42
| | | | | | ambiguous symbols. NFC llvm-svn: 359564
* Fix Wpedantic "default argument specified for lambda parameter" warning. NFCI.Simon Pilgrim2019-04-301-3/+3
| | | | llvm-svn: 359548
* [clangd][xpc] Fix XPC unittestsJan Korous2019-04-292-1/+3
| | | | | | | | | Fix build after recent changes in clangd tests & add xpc unittests to check-clangd target. Differential Revision: https://reviews.llvm.org/D61271 llvm-svn: 359489
* [clangd] Fix serialization logic for Origin and Flags.Kadir Cetinkaya2019-04-292-5/+6
| | | | llvm-svn: 359470
* [clangd] Add separate unit tests for CanonicalIncludes. NFCSam McCall2019-04-293-35/+66
| | | | llvm-svn: 359455
* [clangd] Fix unittests CMake rulesSam McCall2019-04-292-4/+5
| | | | llvm-svn: 359442
* [clangd] Fix windows buildbot, remove stray file after r359424. NFCSam McCall2019-04-292-9/+1
| | | | llvm-svn: 359434
* [clangd] Surface diagnostics from headers inside main fileKadir Cetinkaya2019-04-295-19/+198
| | | | | | | | | | | | Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59302 llvm-svn: 359432
* [clangd] Delete config.clangd_xpc_support from test/ to unbreak check-llvm-toolsFangrui Song2019-04-292-5/+0
| | | | | | | D61187 didn't delete config.clangd_xpc_support from test/ CLANGD_BUILD_XPC is defined in clangd/CMakeLists.txt and not available in test/lit.site.cfg.py.in llvm-svn: 359428
* [clangd] Move clangd tests to clangd directory. check-clangd is no longer ↵Sam McCall2019-04-29112-58/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | part of check-clang-tools. Summary: Motivation: - this layout is a pain to work with - without a common root, it's painful to express things like "disable clangd" (D61122) - CMake/lit configs are a maintenance hazard, and the more the one-off hacks for various tools are entangled, the more we see apathy and non-ownership. This attempts to use the bare-minimum configuration needed (while still supporting the difficult cases: windows, standalone clang build, dynamic libs). In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in. The logic in these files is now minimal. (Much of clang-tools-extra's lit configs can probably be cleaned up by reusing lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of LDPATH mangling. I haven't attempted to fix any of those). Docs are still in clang-tools-extra/docs, I don't have any plans to touch those. Reviewers: gribozavr Subscribers: mgorny, javed.absar, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits, ilya-biryukov, thakis Tags: #clang Differential Revision: https://reviews.llvm.org/D61187 llvm-svn: 359424
* Fix typo in documentation.Nick Lewycky2019-04-261-1/+1
| | | | llvm-svn: 359329
* [clangd] Remove unused ClangdServer::dynamicIndex(). NFCIlya Biryukov2019-04-261-4/+0
| | | | llvm-svn: 359291
* filecheck etc are not clangd-specific deps. NFCSam McCall2019-04-261-1/+1
| | | | llvm-svn: 359289
* [clangd] Query index in code completion no-compile mode.Sam McCall2019-04-265-19/+385
| | | | | | | | | | | | | | Summary: We scrape the enclosing scopes from the source file, and use them in the query. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61077 llvm-svn: 359284
* [clangd] Optimize "don't include me" check.Sam McCall2019-04-252-7/+34
| | | | | | | | | | | | | | | | Summary: llvm::Regex is really slow, and regex evaluation during preamble indexing was showing up as 25% on a profile of clangd in a codebase with large preambles. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61120 llvm-svn: 359214
* [clangd] Use JSON streaming API for Trace rather than pasting strings. NFCSam McCall2019-04-252-30/+35
| | | | llvm-svn: 359202
* [Testing] Move clangd::Annotations to llvm testing supportIlya Biryukov2019-04-252-104/+39
| | | | | | | | | | | | | | | | | | | | | | | Summary: Annotations allow writing nice-looking unit test code when one needs access to locations from the source code, e.g. running code completion at particular offsets in a file. See comments in Annotations.cpp for more details on the API. Also got rid of a duplicate annotations parsing code in clang's code complete tests. Reviewers: gribozavr, sammccall Reviewed By: gribozavr Subscribers: mgorny, hiraditya, ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D59814 llvm-svn: 359179
* [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionalsDon Hinton2019-04-248-0/+379
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Looks at conditionals and finds cases of ``cast<>``, which will assert rather than return a null pointer, and ``dyn_cast<>`` where the return value is not captured. Additionally, finds cases that match the pattern ``var.foo() && isa<X>(var.foo())``, where the method is called twice and could be expensive. .. code-block:: c++ // Finds cases like these: if (auto x = cast<X>(y)) <...> if (cast<X>(y)) <...> // But not cases like these: if (auto f = cast<Z>(y)->foo()) <...> if (cast<Z>(y)->foo()) <...> Reviewers: alexfh, rjmccall, hokein, aaron.ballman, JonasToth Reviewed By: aaron.ballman Subscribers: xbolva00, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59802 llvm-svn: 359142
* [clangd] Fix broken helper deep in unit test. NFCSam McCall2019-04-241-9/+3
| | | | llvm-svn: 359112
* [clangd] Fix handling of include paths in windows testsKadir Cetinkaya2019-04-242-8/+12
| | | | llvm-svn: 359079
* [clang][HeaderSuggestion] Handle the case of dotdot with an absolute pathKadir Cetinkaya2019-04-241-0/+5
| | | | | | | | | | | | | | | | | Summary: Include insertion in clangd was inserting absolute paths when the include directory was an absolute path with a double dot. This patch makes sure double dots are handled both with absolute and relative paths. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60873 llvm-svn: 359078
* Re-apply r357823 "[Lexer] NFC: Fix an off-by-one bug in getAsCharRange()."Artem Dergachev2019-04-233-2/+6
| | | | | | | | | It now comes with a follow-up fix for the clients of this API in clangd and clang-tidy. Differential Revision: https://reviews.llvm.org/D59977 llvm-svn: 359035
* [clangd] Support dependent bases in type hierarchyFangrui Song2019-04-222-47/+69
| | | | | | | | | | | | Patch by Nathan Ridge! Dependent bases are handled heuristically, by replacing them with the class template that they are a specialization of, where possible. Care is taken to avoid infinite recursion. Differential Revision: https://reviews.llvm.org/D59756 llvm-svn: 358866
* [CodeComplete] Remove obsolete isOutputBinary().Sam McCall2019-04-181-4/+2
| | | | | | | | | | | | | | | | Summary: It's never set to true. Its only effect would be to set stdout to binary mode. Hopefully we have better ways of doing this by now :-) Reviewers: hokein Subscribers: jkorous, arphaman, kadircet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60871 llvm-svn: 358696
* [clangd] Support relatedInformation in diagnostics.Sam McCall2019-04-187-69/+213
| | | | | | | | | | | | | | Summary: We already have the structure internally, we just need to expose it. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60267 llvm-svn: 358675
* [clang-tidy] Address post-commit commentsHaojian Wu2019-04-182-31/+39
| | | | | | | | | | | | | | | | Summary: Also add a test to verify clang-tidy only apply the first alternative fix. Reviewers: alexfh Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60857 llvm-svn: 358666
* [clangd] Use llvm::set_thread_priority in background-indexKadir Cetinkaya2019-04-186-54/+32
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: krytarowski, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60865 llvm-svn: 358664
* [clangd] Emit better error messages when rename fails.Haojian Wu2019-04-182-6/+18
| | | | | | | | | | | | | | | | Summary: Currently we emit an unfriendly "clang diagnostic" message when rename fails. This patch makes clangd to emit a detailed diagnostic message. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60821 llvm-svn: 358658
* [clangd] Log verbosely (LSP bodies) in lit tests. NFCSam McCall2019-04-181-1/+2
| | | | llvm-svn: 358655
* [clang-tidy] Don't issue cppcoreguidelines-macro-usage on builtin macrosAlexander Kornienko2019-04-172-2/+3
| | | | | | | | | | | | | | | | | Before the patch calling clang-tidy with -header-filter=.* -system-headers would result in a few hundred useless warnings: warning: macro '_GNU_SOURCE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '_LP64' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_ACQUIRE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_ACQ_REL' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_CONSUME' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_RELAXED' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_RELEASE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__ATOMIC_SEQ_CST' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] warning: macro '__BIGGEST_ALIGNMENT__' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] ... and so on llvm-svn: 358621
* [clang-tidy] Add a check for [super self] in initializers 🔍Stephane Moore2019-04-178-0/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check aims to address a relatively common benign error where Objective-C subclass initializers call -self on their superclass instead of invoking a superclass initializer, typically -init. The error is typically benign because libobjc recognizes that improper initializer chaining is common¹. One theory for the frequency of this error might be that -init and -self have the same return type which could potentially cause inappropriate autocompletion to -self instead of -init. The equal selector lengths and triviality of common initializer code probably contribute to errors like this slipping through code review undetected. This check aims to flag errors of this form in the interests of correctness and reduce incidence of initialization failing to chain to -[NSObject init]. [1] "In practice, it will be hard to rely on this function. Many classes do not properly chain -init calls." From _objc_rootInit in https://opensource.apple.com/source/objc4/objc4-750.1/runtime/NSObject.mm.auto.html. Test Notes: Verified via `make check-clang-tools`. Subscribers: mgorny, xazax.hun, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59806 llvm-svn: 358620
OpenPOWER on IntegriCloud