summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.Sam McCall2019-12-023-17/+142
| | | | | | | | | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/211 Fixes https://github.com/clangd/clangd/issues/178 No tests - this is hard to test, and basically impossible to verify what we want (this produces compile commands that work on a real mac with recent toolchain) (Need someone on mac to verify it actually fixes these!) Reviewers: kbobyrev, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70863
* [clangd] Fix a regression issue in local rename.Haojian Wu2019-12-022-7/+20
| | | | | | | | | | | | | | Summary: The regression is that we can't rename symbols in annonymous namespaces. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70853
* [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804Adam Balogh2019-12-022-1/+2
| | | | | | | | | Applying parentheses for statement leads to compilation error. Bug [[ 43804 | https://bugs.llvm.org/show_bug.cgi?id=43804 ]] is a compilation error suggested by a wrong fix of this checker. This patch is a quick fix for this issue. Differential Revision: https://reviews.llvm.org/D70850
* Revert "[clangd] Rethink how SelectionTree deals with macros and #includes."Sam McCall2019-11-294-355/+153
| | | | | | | | This reverts commit 19daa21f841ad45290c923689ee3d25198651a4c. It causes a bunch of failures on a bot that I've been unable to reproduce so far: http://45.33.8.238/mac/3308/step_7.txt
* [clangd] Rethink how SelectionTree deals with macros and #includes.Sam McCall2019-11-294-153/+355
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The exclusive-claim model is successful at resolving conflicts over tokens between parent/child or siblings. However claims at the spelled-token level do the wrong thing for macro expansions, where siblings can be equally associated with the macro invocation. Moreover, any model that only uses the endpoints in a range can fail when a macro invocation occurs inside the node. To address this, we use the existing TokenBuffer in more depth. Claims are expressed in terms of expanded tokens, so there is no need to worry about macros, includes etc. Once we know which expanded tokens were claimed, they are mapped onto spelled tokens for hit-testing. This mapping is fairly flexible, currently the handling of macros is pretty simple (map macro args onto spellings, other macro expansions onto the macro name token). This mapping is in principle token-by-token for correctness (though there's some batching for performance). The aggregation of the selection enum is now more principled as we need to be able to aggregate several hit-test results together. For simplicity i removed the ability to determine selectedness of TUDecl. (That was originally implemented in 90a5bf92ff97b1, but doesn't seem to be very important or worth the complexity any longer). The expandedTokens(SourceLocation) helper could be added locally, but seems to make sense on TokenBuffer. Fixes https://github.com/clangd/clangd/issues/202 Fixes https://github.com/clangd/clangd/issues/126 Reviewers: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D70512
* [clangd] Fix 407ac2e, which was broken and committed too soonSam McCall2019-11-291-3/+3
|
* [clangd] Log cc1 args at verbose level.Sam McCall2019-11-293-4/+9
| | | | | | | | | | | | Summary: This will help debugging driver issues. Reviewers: kbobyrev Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70832
* [clangd] Correct the file path in Edit::replacements when generating the ↵Haojian Wu2019-11-293-8/+13
| | | | | | | | | | | | | | | | | rename edit. Summary: The file path was set to the file content previously, and it isn't covered by normal clangd & unittest code path (as we only uses the offset, length, replacement text). Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70828
* [include-fixer] Python 3 support for clang-include-fixer.pyBenjamin Kramer2019-11-281-8/+10
| | | | Patch by Yannick Brehon!
* [clangd] Don't perform rename when the refs result from index is incomplete.Haojian Wu2019-11-282-13/+51
| | | | | | | | | | | | | | Summary: Also do an early return if the number of affected files > limit to save some unnecessary FileURI computations. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70811
* [clangd] Prefer the left character if the character on the right of the ↵Haojian Wu2019-11-283-7/+5
| | | | | | | | | | | | | | cursor is semicolon. Summary: This would make go-to-def works on the cases like int A = abc^; Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70807
* [clangd] Tweak the no-index error message for rename, NFC.Haojian Wu2019-11-281-1/+1
| | | | | | | | | | | | Summary: The current error message doesn't fit well for cross-file rename. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70809
* Use InitLLVM in clang-tidyRui Ueyama2019-11-281-1/+2
| | | | | | | | | | | | | Update clang-tidy to use InitLLVM, like several other llvm tools that were previously updated. On Windows, this allows clang-tidy to operate on arguments containing characters which cannot be represented in the system's ANSI code page such as filenames with Unicode characters. Fixes bugzilla bug 43751. Patch by Tristan Labelle. Differential Revision: https://reviews.llvm.org/D70694
* [clang-tidy] Fix PR35824Gabor Horvath2019-11-272-1/+33
| | | | Differential Revision: https://reviews.llvm.org/D46027
* [clangd] Handle the missing call expr in targetDecl.Haojian Wu2019-11-272-0/+20
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70773
* [clangd] Shutdown cleanly on signals.Sam McCall2019-11-277-12/+190
| | | | | | | | | | | | | | | | Summary: This avoids leaking PCH files if editors don't use the LSP shutdown protocol. This is one fix for https://github.com/clangd/clangd/issues/209 (Though I think we should *also* be unlinking the files) Reviewers: kadircet, jfb Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70684
* [clang-tidy] Use range-for for check registration. NFCAlexander Kornienko2019-11-261-4/+2
| | | | Actually, just testing GitHub commit rights.
* [clangd] Speed up when building rename edit.Haojian Wu2019-11-263-34/+90
| | | | | | | | | | | | | | Summary: We used to scan the code everytime when computing the LSP position to the offset (respect the LSP encoding). Now we only scan the source code once. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70441
* [NFC] ASSERT_EQ before accessing items in containersKirill Bobyrev2019-11-262-2/+8
| | | | | | | | | | | | As discussed offline, something different from `EXPECT_EQ` should be used to check if the container contains enough items before accessing them so that other tests can still be run even if the assertion fails as opposed to having `EXPECT_EQ` failing and then aborting the run due to the errors caused by out-of-bounds memory access. Reviewed by: ilya-biryukov Differential Revision: https://reviews.llvm.org/D70528
* [clangd] Implement cross-file rename.Haojian Wu2019-11-2613-145/+523
| | | | | | | | | | | | | | | | | Summary: This is the initial version. The cross-file rename is purely based on the index. It is hidden under a command-line flag, and only available for a small set of symbols. Reviewers: ilya-biryukov, sammccall Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69263
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-259-18/+9
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-269-9/+18
| | | | | | | | | | | | | | InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
* Fix an unused variable warning where a variable was only used in an assert.Eric Christopher2019-11-251-1/+3
|
* [clangd] Fix diagnostic location for macro expansionsKadir Cetinkaya2019-11-252-5/+42
| | | | | | | | | | | | | | | | | Summary: Diagnostic locations were broken when it was result of a macro expansion. This patch fixes it by using expansion location instead of location inside macro body. Fixes https://github.com/clangd/clangd/issues/201. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70494
* [clangd] Improve symbol qualification in DefineInline code actionKadir Cetinkaya2019-11-253-7/+154
| | | | | | | | | | | | | | | | | | | | | | Summary: Currently define inline action fully qualifies any names in the function body, which is not optimal and definitely natural. This patch tries to improve the situation by dropping any name specifiers shared by function and names spelled in the body. For example if you are moving definition of a function in namespace clang::clangd, and body has any decl's coming from clang or clang::clangd namespace, those qualifications won't be added since they are redundant. It also drops any qualifiers that are visible in target context. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69033
* [clangd] Helper for getting nested namespace qualificationKadir Cetinkaya2019-11-253-9/+263
| | | | | | | | | | | | | | | | | Summary: Introduce a new helper for getting minimally required qualifiers necessary to spell a name at a point in a given DeclContext. Currently takes using directives and nested namespecifier of DeclContext itself into account. Initially will be used in define inline and outline actions. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69608
* Fix llvm-namespace-comment for macro expansionsMarcin Twardak2019-11-234-16/+179
| | | | | If a namespace is a macro name, it should be allowed to close the namespace with the same name.
* clang/Modules: Rename CompilerInstance::ModuleManager, NFCDuncan P. N. Exon Smith2019-11-221-2/+2
| | | | | | | | | | | | | | | | | | | Fix the confusing naming of `CompilerInstance::ModuleManager`. This is actually an instance of `ASTReader`, which contains an instance of `ModuleManager`. I have to assume there was a point in the past where they were just one class, but it's been pretty confusing for a while. I think it's time to fix it. The new name is `TheASTReader`; the annoying `The` prefix is so that we don't shadow the `ASTReader` class. I tried out `ASTRdr` but that seemed less clear, and this choice matches `ThePCHContainerOperations` just a couple of declarations below. Also rename `CompilerInstance::getModuleManager` and `CompilerInstance::createModuleManager` to `*ASTReader`, making some cases of `getModuleManager().getModuleManager()` a little more clear. https://reviews.llvm.org/D70583
* clang-tidy: don't use an absolute path in a testGeorge Burgess IV2019-11-221-1/+1
| | | | | | | `run_clang_tidy` takes a regular expression to match against compile_commands.json entries. If we pass "%t/test.cpp" and "%t" expands to anything that includes chars that a regex treats specially, like '+', this test starts failing.
* [clang-include-fixer] Suppress cmd prompt from Vim on WindowsReid Kleckner2019-11-221-1/+8
| | | | | | | | Copied from the clang-format.py editor integration. Reviewers: bkramer Differential Revision: https://reviews.llvm.org/D70518
* [clangd] Show lambda signature for lambda autocompletionsKirill Bobyrev2019-11-221-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | The original bug report can be found [here](https://github.com/clangd/clangd/issues/85) Given the following code: ```c++ void function() { auto Lambda = [](int a, double &b) {return 1.f;}; La^ } ``` Triggering the completion at `^` would show `(lambda)` before this patch and would show signature `(int a, double &b) const`, build a snippet etc with this patch. Reviewers: sammccall Reviewed by: sammccall Differential revision: https://reviews.llvm.org/D70445
* [clang-tidy] new performance-no-automatic-move check.Clement Courbet2019-11-228-0/+265
| | | | | | | | | | | | Summary: The check flags constructs that prevent automatic move of local variables. Reviewers: aaron.ballman Subscribers: mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70390
* [clangd] Inactive regions support as an extension to semantic highlightingNathan Ridge2019-11-217-14/+104
| | | | Differential Revision: https://reviews.llvm.org/D67536
* Fix unused variable warning. NFCI.Simon Pilgrim2019-11-211-1/+1
|
* [DeclCXX] Remove unknown external linkage specificationsEhud Katz2019-11-211-2/+0
| | | | | | | | | | | | | | | | Partial revert of r372681 "Support for DWARF-5 C++ language tags". The change introduced new external linkage languages ("C++11" and "C++14") which not supported in C++. It also changed the definition of the existing enum to use the DWARF constants. The problem is that "LinkageSpecDeclBits.Language" (the field that reserves this enum) is actually defined as 3 bits length (bitfield), which cannot contain the new DWARF constants. Defining the enum as integer literals is more appropriate for maintaining valid values. Differential Revision: https://reviews.llvm.org/D69935
* [clangd] Reland b5135a86e0476: Fix a crash in expected typesIlya Biryukov2019-11-212-4/+14
| | | | | | | Reverted in 6de45772e0910bf7fa626e5493a2798b071eb26c. With a fix to Windows tests. Differential Revision: https://reviews.llvm.org/D70481
* [clang-tidy] modernize-use-equals-default avoid adding redundant semicolonsMitchell Balan2019-11-206-12/+41
| | | | | | | | | | | | | | | | | | | Summary: `modernize-use-equals-default` replaces default constructors/destructors with `= default;`. When the optional semicolon after a member function is present, this results in two consecutive semicolons. This patch checks to see if the next non-comment token after the code to be replaced is a semicolon, and if so offers a replacement of `= default` rather than `= default;`. This patch adds trailing comments and semicolons to about 5 existing tests. Reviewers: malcolm.parsons, angelgarcia, aaron.ballman, alexfh Patch by: poelmanc Subscribers: MyDeveloperDay, JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70144
* Revert "[clangd] Fix a crash in expected types"Nico Weber2019-11-202-12/+4
| | | | | This reverts commit b5135a86e04761577494c70e7c0057136cc90b5b. Test fails on Windows.
* [clangd] Fix a crash in expected typesIlya Biryukov2019-11-202-4/+12
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70481
* [clangd] Treat UserDefinedLiteral as a leaf in SelectionTree, sidestepping ↵Sam McCall2019-11-202-0/+24
| | | | | | | | | | | | | | tokenization issues Summary: Fixes https://github.com/clangd/clangd/issues/203 Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70446
* [NFC] Refactor representation of materialized temporariesTyker2019-11-195-5/+5
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: thakis, sammccall, ilya-biryukov, rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* [NFC] Attempting to fix sphinx build failure with badly encoded characters ↵Mitchell Balan2019-11-191-1/+1
| | | | from incoming patch.
* [NFC] Attempting to fix sphinx build failure with badly encoded characters ↵Mitchell Balan2019-11-191-1/+1
| | | | from incoming patch.
* [clang-tidy] Give readability-redundant-member-init an option ↵Mitchell Balan2019-11-195-8/+91
| | | | | | | | | | | | | | | | | | | IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra Summary: readability-redundant-member-init removes redundant / unnecessary member and base class initialization. Unfortunately for the specific case of a copy constructor's initialization of a base class, gcc at strict warning levels warns if "base class is not initialized in the copy constructor of a derived class". This patch adds an option `IgnoreBaseInCopyConstructors` defaulting to 0 (thus maintaining current behavior by default) to skip the specific case of removal of redundant base class initialization in the copy constructor. Enabling this option enables the resulting code to continue to compile successfully under `gcc -Werror=extra`. New test cases `WithCopyConstructor1` and `WithCopyConstructor2` in clang-tools-extra/test/clang-tidy/readability-redundant-member-init.cpp show that it removes redundant members even from copy constructors. Reviewers: malcolm.parsons, alexfh, hokein, aaron.ballman, lebedev.ri Patch by: poelmanc Subscribers: mgehre, lebedev.ri, cfe-commits Tags: #clang, #clang-tools-extra Differential revision: https://reviews.llvm.org/D69145
* [clangd] Show values of more expressions on hoverSam McCall2019-11-192-14/+83
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70359
* [clang-tidy] DefaultOperatorNewCheck test fixes.Balázs Kéri2019-11-192-11/+11
|
* [clangd] Untangle Hover from XRefs, move into own file.Sam McCall2019-11-1913-1961/+2025
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This is mostly mechanical, with a few exceptions: - getDeducedType moved into AST.h where it belongs. It now takes ASTContext instead of ParsedAST, and avoids using the preprocessor. - hover now uses SelectionTree directly rather than via getDeclAtPosition helper - hover on 'auto' used to find the decl that contained the 'auto' and use that to set Kind and documentation for the hover result. Now we use targetDecl() to find the decl matching the deduced type instead. This changes tests, e.g. 'variable' -> class for auto on lambdas. I think this is better, but the motivation was to avoid depending on the internals of DeducedTypeVisitor. This functionality is removed from the visitor. Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70357
* [clang-tidy] modernize-use-override new option AllowOverrideAndFinalMitchell Balan2019-11-195-4/+63
| | | | | | | | | | | | | | | | | | | Summary: In addition to adding `override` wherever possible, clang-tidy's `modernize-use-override` nicely removes `virtual` when `override` or `final` is specified, and further removes override when final is specified. While this is great default behavior, when code needs to be compiled with gcc at high warning levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, clang-tidy's removal of the redundant `override` keyword causes gcc to emit a warning or error. This discrepancy / conflict has been noted by others including a comment on Stack Overflow and by Mozilla's Firefox developers. This patch adds an AllowOverrideAndFinal option defaulting to 0 - thus preserving current behavior - that when enabled allows both `override` and `final` to co-exist, while still fixing all other issues. The patch includes a test file verifying all combinations of virtual/override/final, and mentions the new option in the release notes. Reviewers: alexfh, djasper, JonasToth Patch by: poelmanc Subscribers: JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70165
* [clang-tidy] Fix readability-redundant-string-init for c++17/c++2aMitchell Balan2019-11-193-9/+18
| | | | | | | | | | | | | | | | | | | Summary: `readability-redundant-string-init` was one of several clang-tidy checks documented as failing for C++17. (The failure mode in C++17 is that it changes `std::string Name = ""`; to `std::string Name = Name;`, which actually compiles but crashes at run-time.) Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer `CXXConstructExprs` that previously held the correct SourceRange were being elided in C++17/2a, but the containing `VarDecl` expressions still had all the relevant information. So this patch changes the fix to get its source ranges from `VarDecl`. It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to confirm proper warnings and fixit replacements in a single `DeclStmt` where some strings require replacement and others don't. The readability-redundant-string-init.cpp and readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a. Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2 Patch by: poelmanc Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D69238
* Revert "[clang-tidy] modernize-use-override new option AllowOverrideAndFinal"Mitchell Balan2019-11-193-18/+9
| | | | This reverts commit 50e99563fb0459f5160572eef3c4e6062b8ad3f2.
OpenPOWER on IntegriCloud