Commit Graph

7887 Commits

Author SHA1 Message Date
Zinovy Nis 19d7a0b47b [clang-tidy] [bugprone-assert-side-effect] Ignore list for functions/methods
A semicolon-separated list of the names of functions or methods to be considered as not having side-effects was added for bugprone-assert-side-effect. It can be used to exclude methods like iterator::begin/end from being considered as having side-effects.

Differential Revision: https://reviews.llvm.org/D116478
2022-01-25 21:04:07 +03:00
Balázs Kéri 9d8c3ad94f [clang-tidy] Change code of SignalHandlerCheck (NFC).
Using clang::CallGraph to get the called functions.
This makes a better foundation to improve support for
C++ and print the call chain.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D118016
2022-01-25 15:52:38 +01:00
Jim Lin f3314e3747 [clang-tidy] Pop Files only if FileChangeReason is ExitFile
enum FileChangeReason has four possible type EnterFile, ExitFile,
SystemHeaderPragma and RenameFile,
It should pop the back element of Files only if FileChangeReason is ExitFile.
2022-01-25 22:46:12 +08:00
Christian Kühnel c0e3c893aa [NFC][clangd] cleaning up llvm-qualified-auto
This is a cleanup of all llvm-qualified-auto findings.
This patch was created by automatically applying the fixes from
clang-tidy.

Differential Revision: https://reviews.llvm.org/D113898
2022-01-25 13:26:33 +00:00
Richard 810f13f0eb [clang-tools-extra] Fix documentation build (NFC) 2022-01-24 20:19:03 -07:00
Yuanfang Chen 3b64ab574d [NFC][clangd] Use table to collect option aliases
* Suppress a lot of `-Wtautological-compare` warning
* Speed up file build a little bit

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D98110
2022-01-24 14:27:14 -08:00
serge-sans-paille a0d5e938fe Add missing include llvm/ADT/STLExtras 2022-01-24 14:41:24 +01:00
Adrian Vogelsgesang 3696c70e67 [clang-tidy] Add `readability-container-contains` check
This commit introduces a new check `readability-container-contains` which finds
usages of `container.count()` and `container.find() != container.end()` and
instead recommends the `container.contains()` method introduced in C++20.

For containers which permit multiple entries per key (`multimap`, `multiset`,
...), `contains` is more efficient than `count` because `count` has to do
unnecessary additional work.

While this this performance difference does not exist for containers with only
a single entry per key (`map`, `unordered_map`, ...), `contains` still conveys
the intent better.

Reviewed By: xazax.hun, whisperity

Differential Revision: http://reviews.llvm.org/D112646
2022-01-24 12:57:18 +01:00
Kazu Hirata ee591a64a7 [clang] Forward-declare DynTypedNode (NFC)
This patch adds a forward declaraiton of DynTypedNode.

DumpAST.h is relying on the forward declaration of DynTypedNode in
ASTContext.h, which is undesirable.
2022-01-23 13:28:04 -08:00
Richard d2e8fb3318 [clang-tidy] Add readability-duplicate-include check
Looks for duplicate includes and removes them.

Every time an include directive is processed, check a vector of filenames
to see if the included file has already been included.  If so, it issues
a warning and a replacement to remove the entire line containing the
duplicated include directive.

When a macro is defined or undefined, the vector of filenames is cleared.
This enables including the same file multiple times, but getting
different expansions based on the set of active macros at the time of
inclusion.  For example:

  #undef NDEBUG
  #include "assertion.h"
  // ...code with assertions enabled

  #define NDEBUG
  #include "assertion.h"
  // ...code with assertions disabled

Since macros are redefined between the inclusion of assertion.h,
they are not flagged as redundant.

Differential Revision: https://reviews.llvm.org/D7982
2022-01-23 09:23:04 -07:00
Carlos Galvez eb3f20e8fa [clang-tidy] Remove gsl::at suggestion from cppcoreguidelines-pro-bounds-constant-array-index
Currently the fix hint is hardcoded to gsl::at(). This poses
a problem for people who, for a number of reasons, don't want
or cannot use the GSL library (introducing a new third-party
dependency into a project is not a minor task).

In these situations, the fix hint does more harm than good
as it creates confusion as to what the fix should be. People
can even misinterpret the fix "gsl::at" as e.g. "std::array::at",
which can lead to even more trouble (e.g. when having guidelines
that disallow exceptions).

Furthermore, this is not a requirement from the C++ Core Guidelines.
simply that array indexing needs to be safe. Each project should
be able to decide upon a strategy for safe indexing.

The fix-it is kept for people who want to use the GSL library.

Differential Revision: https://reviews.llvm.org/D117857
2022-01-23 15:52:42 +00:00
Simon Pilgrim df0fd1c301 [clangd] Use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr
2022-01-23 13:24:36 +00:00
Simon Pilgrim 86497026a2 [clang-tidy] Use cast<>/castAs<> instead of dyn_cast<>/getAs<> to avoid dereference of nullptr
The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr
2022-01-23 12:57:12 +00:00
John Ericson 7c16647c36 [clang-tools-extra][cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

Differential Revision: https://reviews.llvm.org/D99484
2022-01-22 20:57:21 +00:00
Benjamin Kramer b8102449a7 [clang-tidy] Avoid binding nullptr to a reference
That's undefined behavior. Found by -fsanitize=null.
2022-01-21 15:55:17 +01:00
Jan Svoboda 622354a522 [llvm][ADT] Implement `BitVector::{pop_,}back`
LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

Currently, some users of `std::vector<bool>` cannot switch to `llvm::BitVector` because it doesn't implement the `pop_back()` and `back()` functions.

To enable easy transition of `std::vector<bool>` users, this patch implements `llvm::BitVector::pop_back()` and `llvm::BitVector::back()`.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D117115
2022-01-21 14:50:53 +01:00
Kadir Cetinkaya 825a3cd6b6
[clangd] Fail inlayHints requests on content changes
This should improve the overall UX by making the labels less jumpy.

Differential Revision: https://reviews.llvm.org/D117776
2022-01-21 12:40:49 +01:00
Kadir Cetinkaya 597eae998a
[clangd][Background] Make index validation logs verbose
These errors are non-harmful and should be transient. They either
imply:
- compilation database returned stale results for TUs and it'll be fixed once
  it's updated to match project state.
- a TUs dependencies has changed and some headers no longer exist. this should
  be fixed with the next indexing cycle.

In either case the user will have some stale symbols in their index until clangd
restarts and the underlying issue is resolved. On the downside these logs are
confusing users when there's another issue.

Differential Revision: https://reviews.llvm.org/D117792
2022-01-21 12:37:20 +01:00
Sockke a7f8aea714 [clang-tidy] Fix wrong FixIt in performance-move-const-arg
There are incorrect Fixit and missing warnings:
case :
A trivially-copyable object wrapped by std::move is passed to the function with rvalue reference parameters. Removing std::move will cause compilation errors.
```
void showInt(int&&) {}
void testInt() {
    int a = 10;
    // expect: warning + nofix
    showInt(std::move(a));  // showInt(a) <--- wrong fix
}

struct Tmp {};
void showTmp(Tmp&&) {}
void testTmp() {
    Tmp t;
    // expect: warning + nofix
    showTmp(std::move(t));  // showTmp(t) <--- wrong fix
}
```

Reviewed By: aaron.ballman, Quuxplusone

Differential Revision: https://reviews.llvm.org/D107450
2022-01-21 14:23:52 +08:00
Fabian Wolff d3b188a2d7 [clang-tidy] Include constructor initializers in `bugprone-exception-escape` check
Fixes PR#52435.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D113507
2022-01-21 00:53:57 +01:00
CJ Johnson a568411444 [clang-tidy] Update bugprone-stringview-nullptr to consistently prefer the empty string when passing arguments to constructors/functions
Previously, function(nullptr) would have been fixed with function({}). This unfortunately can change overload resolution and even become ambiguous. T(nullptr) was already being fixed with T(""), so this change just brings function calls in line with that.

Differential Revision: https://reviews.llvm.org/D117840
2022-01-20 18:08:40 -05:00
Nathan James 39f779afb3
[clang-tidy][NFC] Remove redundant string creation for comparison 2022-01-20 22:20:10 +00:00
Richard baa08d1ec3 [clang-tidy] Revert documentation change (NFC)
Restore a fix to the list of checks that was undone by a recent commit.
2022-01-20 01:27:23 -07:00
Richard 058d212379 [clang-tidy] Use literal block instead of code block (NFC)
I used a C++ code block in check documentation to show example
output from clang-tidy, but since the example output isn't
kosher C++, sphinx didn't like that when it went to syntax
highlight the block.  So switch to a literal block instead
and forego any highlighting.

Fixes build error
<https://lab.llvm.org/buildbot/#/builders/115/builds/21145>
2022-01-19 15:23:48 -07:00
Richard d83ecd77cc [clang-tidy] Narrow cppguidelines-macro-usage to actual constants
Previously, any macro that didn't look like a varargs macro
or a function style macro was reported with a warning that
it should be replaced with a constexpr const declaration.
This is only reasonable when the macro body contains constants
and not expansions like ",", "[[noreturn]]", "__declspec(xxx)",
etc.

So instead of always issuing a warning about every macro that
doesn't look like a varargs or function style macro, examine the
tokens in the macro and only warn about the macro if it contains
only comment and constant tokens.

Differential Revision: https://reviews.llvm.org/D116386

Fixes #39945
2022-01-19 12:28:22 -07:00
Nathan James a4bdeb9a56
[clang-tidy][NFC] replace some redundant std::string creations 2022-01-19 18:36:35 +00:00
Haojian Wu 55b702c37b [clangd] NFC, emit source ranges in selection debug messages.
It will make the output more versbose, but I found that these are useful
information when debugging selection tree.

Differential Revision: https://reviews.llvm.org/D117475
2022-01-19 16:06:58 +01:00
Haojian Wu 6c78703e3a [AST] Fix the incorrect auto-keyword loc for constrained auto type loc.
E.g.  `Concept auto Func();`

The nameLoc for the constained auto type loc pointed to the concept name
loc, it should be the auto token loc. This patch fixes it, and remove
a relevant hack in clang-tidy check.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117009
2022-01-19 14:18:38 +01:00
Kadir Cetinkaya cae932b6c6
[clangd] Sort targets before printing for tests
Targets are not necessarily inserted in the order they appear in source
code. For example we could traverse overload sets, or selectively insert
template patterns after all other decls.
So order the targets before printing to make sure tests are not dependent on
such implementation details. We can also do it in production, but that might be
wasteful as we haven't seen any complaints in the wild around these orderings
yet.

Differential Revision: https://reviews.llvm.org/D117549
2022-01-19 14:06:53 +01:00
Fabian Wolff f7b7138a62 [clang-tidy] Make `readability-container-data-pointer` more robust
Fixes PR#52245. I've also added a few test cases beyond PR#52245 that would also fail with the current implementation, which is quite brittle in many respects (e.g. it uses the `hasDescendant()` matcher to find the container that is being accessed, which is very easy to trick, as in the example in PR#52245).

I have not been able to reproduce the second issue mentioned in PR#52245 (namely that using the `data()` member function is suggested even for containers that don't have it), but I've added a test case for it to be sure.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D113863
2022-01-18 21:08:59 +01:00
Jan Svoboda c6fb636667 [clangd][clang-tidy] Remove uses of `std::vector<bool>`
LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch does just that for clangd and clang-tidy.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D117119
2022-01-18 17:59:40 +01:00
Richard e598913a47 [clang-tidy] Force LF newlines when writing files
The recommendation on Windows is to checkout from git with
core.autolf=false in order to preserve LF line endings on
test files.  However, when creating a new check this results
in modified files as having switched all the line endings on
Windows.  Write all files with explicit LF line endings to
prevent this.

Fixes #52968

Differential Revision: https://reviews.llvm.org/D117535
2022-01-18 09:39:42 -07:00
Jan Svoboda 105c913156 [clang][lex] NFC: Simplify calls to `LookupFile`
The `{HeaderSearch,Preprocessor}::LookupFile()` functions take an out-parameter `const DirectoryLookup *&`. Most callers end up creating a `const DirectoryLookup *` variable that's otherwise unused.

This patch changes the out-parameter from reference to a pointer, making it possible to simply pass `nullptr` to the function without the ceremony.

Reviewed By: ahoppen

Differential Revision: https://reviews.llvm.org/D117312
2022-01-18 16:02:18 +01:00
Haojian Wu fd598e1859 [clangd] Bring back early-claim approach to fix a selection-tree regression.
The early-claim hack was removed in 96f5cc1ee4,
we see a regression about captured var-decl in lambda.

Fixes https://github.com/clangd/clangd/issues/990.

Differential Revision: https://reviews.llvm.org/D117472
2022-01-18 10:22:26 +01:00
Kirill Bobyrev 2d9198cec9
[clangd] Remove redundant check for renamed symbol origin
This is a follow-up on D116643. `isInSystemHeader` check already detects
symbols coming from the Standard Library, so searching for the qualified name
in StdSymbolMap.inc is no longer necessary.

The tests filtering out purely based on the symbol qualified names are removed.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D117491
2022-01-18 09:43:53 +01:00
Fabian Wolff 2cd2accc61 [clang-tidy] Fix false positives involving type aliases in `misc-unconventional-assign-operator` check
clang-tidy currently reports false positives even for simple cases such as:
```
struct S {
    using X = S;
    X &operator=(const X&) { return *this; }
};
```
This is due to the fact that the `misc-unconventional-assign-operator` check fails to look at the //canonical// types. This patch fixes this behavior.

Reviewed By: aaron.ballman, mizvekov

Differential Revision: https://reviews.llvm.org/D114197
2022-01-17 21:16:17 +01:00
Fabian Wolff 42bc3275d3 [clang-tidy] Fix `readability-redundant-declaration` false positive for template friend declaration
Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=48086 | PR#48086 ]]. The problem is that the current matcher uses `hasParent()` to detect friend declarations, but for a template friend declaration, the immediate parent of the `FunctionDecl` is a `FunctionTemplateDecl`, not the `FriendDecl`. Therefore, I have replaced the matcher with `hasAncestor()`.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D114299
2022-01-17 20:50:32 +01:00
Sam McCall 4dedd82cc9 Re-land [clangd] Elide even more checks in SelectionTree.
This reverts commit 1093b9f2e9.

Fix added for implicit-include case.
2022-01-17 15:26:28 +01:00
Haojian Wu 192f8d9700 [clangd] Don't rename on symbols from system headers.
Fixes https://github.com/clangd/clangd/issues/963.

Differential Revision: https://reviews.llvm.org/D116643
2022-01-17 15:08:53 +01:00
Nathan James 8b88ff0803
[clangd] Add option to use dirty file contents when building preambles.
Adds a option `use-dirty-preambles` to enable using unsaved in editor contents when building pre-ambles.
This enables a more seamless user experience when switching between header and implementation files and forgetting to save inbetween.
It's also in line with the LSP spec that states open files in the editor should be used instead of on the contents on disk - https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/
For now the option is defaulted to off and hidden, Though I have a feeling it should be moved into the `.clangd` config and possibly defaulted to true.

Addresses https://github.com/clangd/clangd/issues/488

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D95046
2022-01-17 10:55:35 +00:00
Haojian Wu ab3f100bec Reland (2) "[AST] Add RParen loc for decltype AutoTypeloc.""
The patch was reverted because it caused a crash during PCH build -- we
missed to update the RParenLoc in TreeTransform<Derived>::TransformAutoType.

This relands 55d96ac and 37ec65e with a test and fix.
2022-01-17 11:33:11 +01:00
Haojian Wu 884832407e [clangd] Avoid a code completion crash
This is a workaround (adding a newline to the eof) in clangd to avoid the code
completion crash, see https://github.com/clangd/clangd/issues/332.

In principle, this is a clang bug, we should fix it in clang, but it is not
trivial.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117456
2022-01-17 10:35:55 +01:00
Haojian Wu 64c108c9e4 [clangd] Better handling `\n` in the synthesized diagnostic message.
The newline-eof fix was rendered as "insert '...'", this patch
special-case it.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117294
2022-01-17 09:27:58 +01:00
John Ericson da77db58d7 Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
https://lab.llvm.org/buildbot/#/builders/46/builds/21146 Still have
this odd error, not sure how to reproduce, so I will just try breaking
up my patch.

This reverts commit 4a678f8072.
2022-01-16 05:48:30 +00:00
John Ericson 4a678f8072 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

Differential Revision: https://reviews.llvm.org/D99484
2022-01-16 05:33:07 +00:00
John Ericson 6e52bfe09d Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
Sorry for the disruption, I will try again later.

This reverts commit efeb501970.
2022-01-15 07:35:02 +00:00
John Ericson efeb501970 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

Differential Revision: https://reviews.llvm.org/D99484
2022-01-15 01:08:35 +00:00
Kadir Cetinkaya 1093b9f2e9
Revert "[clangd] Elide even more checks in SelectionTree."
This reverts commit 07f9fb8b51.
2022-01-14 14:32:43 +01:00
Sam McCall 07f9fb8b51 [clangd] Elide even more checks in SelectionTree.
During pop() we convert nodes into spans of expanded syntax::Tokens.
If we precompute a range of plausible (expanded) tokens, then we can do an
extremely cheap approximate hit-test against it, because syntax::Tokens are
ordered by pointer.

This would seem not to buy anything (we don't enter nodes unless they overlap
the selection), but in fact the spans we have are for *newly* claimed ranges
(i.e. those unclaimed by any child node).

So if you have:
   { { [[2+2]]; } }
then all of the CompoundStmts pass the hit test and are pushed, but we skip
full hit-testing of the brackets during pop() as they lie outside the range.

This is ~10x average speedup for selectiontree on a bad case I've seen
(large gtest file).

Differential Revision: https://reviews.llvm.org/D117107
2022-01-13 22:27:51 +01:00
Sam McCall 004acbb47d [clangd] Suppress warning about system_header pragma when editing headers
Not sure it's OK to suppress this in clang itself - if we're building a PCH
or module, maybe it matters?

Differential Revision: https://reviews.llvm.org/D116925
2022-01-13 22:24:05 +01:00
Sam McCall 71a082f726 [clangd] Implement textDocument/typeDefinition
This reuses the type=>decl mapping from go-to-definition on auto.
(Which could stand some improvement, but that can happen later).

Fixes https://github.com/clangd/clangd/issues/367

Differential Revision: https://reviews.llvm.org/D116443
2022-01-13 22:15:10 +01:00
Sam McCall fc7a9f36a9 [clangd] Ignore cvr-qualifiers in selection.
The AST doesn't track their locations, and the default behavior of attributing
them to the lexically-enclosing node is sloppy and often inaccurate.

Also add a couple of passing test cases for declarators that weren't obvious.

Differential Revision: https://reviews.llvm.org/D117185
2022-01-13 15:08:50 +01:00
Sam McCall 2b2dbe6126 [clangd] Selection: Prune gtest TEST()s earlier
When searching for AST nodes that may overlap the selection, mayHit() was only
attempting to prune nodes whose begin/end are both in the main file.

While failing to prune never gives wrong results, it hurts performance.
In GTest unit-tests, `TEST()` macros at the top level declare classes.
These were never pruned and we traversed *every* such class for any selection.

We fix this by reasoning about what tokens such a node might claim.
They must lie within its ultimate macro expansion range, so if this doesn't
overlap with the selection, we can prune the node.

Differential Revision: https://reviews.llvm.org/D116978
2022-01-13 13:58:42 +01:00
Kirill Bobyrev a9bf32763d [clangd] Fix build after D115243
The api for loadIndex changed but was not updated everywhere due to
differences in the build configuration.
2022-01-13 13:44:19 +01:00
Sam McCall 54eb70886c [clangd] Remove --inlay-hints flag
Differential Revision: https://reviews.llvm.org/D117036
2022-01-13 10:02:28 +01:00
Sam McCall 9c9119ab36 [clangd] Extend SymbolOrigin, stop serializing it
New values:
- Split Dynamic into Open/Preamble
- Add Background (previously was just Unknown)
- Soon: stdlib index

This requires extending to 16 bits, which fits within the padding of Symbol.
Unfortunately we're also *serializing* SymbolOrigin as a fixed 8 bits.

Stop serializing SymbolOrigin:
- conceptually, the source is whoever indexes or *deserializes* a symbol
- deserialization takes SymbolOrigin as a parameter and stamps it on each sym
- this is a breaking format change

Differential Revision: https://reviews.llvm.org/D115243
2022-01-13 08:26:12 +01:00
Sam McCall d8716cd7d3 [CodeCompletion] (mostly) fix completion in incomplete C++ ctor initializers.
C++ member function bodies (including ctor initializers) are first captured
into a buffer and then parsed after the class is complete. (This allows
members to be referenced even if declared later).

When the boundary of the function body cannot be established, its buffer is
discarded and late-parsing never happens (it would surely fail).
For code completion this is the wrong tradeoff: the point of the parse is to
generate completions as a side-effect.
Today, when the ctor body wasn't typed yet there are no init list completions.
With this patch we parse such an init-list if it contains the completion point.

There's one caveat: the parser has to decide where to resume parsing members
after a broken init list. Often the first clear recovery point is *after* the
next member, so that member is missing from completion/signature help etc. e.g.
  struct S {
    S() m  //<- completion here
    int maaa;
    int mbbb;
  }
Here "int maaa;" is treated as part of the init list, so "maaa" is not available
as a completion. Maybe in future indentation can be used to recognize that
this is a separate member, not part of the init list.

Differential Revision: https://reviews.llvm.org/D116294
2022-01-13 08:06:35 +01:00
CJ Johnson 81c330e23d Filter string_view from the nullptr diagnosis of bugprone-string-constructor to prevent duplicate warnings with bugprone-stringview-nullptr
Updates the check and tests to not diagnose the null case for string_view (but retains it for string). This prevents the check from giving duplicate warnings that are caught by bugprone-stringview-nullptr ([[ https://reviews.llvm.org/D113148 | D113148 ]]).

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D114823
2022-01-12 17:04:44 -05:00
CJ Johnson 7e29da875c Add support for return values in bugprone-stringview-nullptr
bugprone-stringview-nullptr was not initially written with tests for return statements. After landing the check, the thought crossed my mind to add such tests. After writing them, I realized they needed additional handling in the matchers.

Differential Revision: https://reviews.llvm.org/D115121
2022-01-12 16:53:13 -05:00
Richard fff59f4817 [clang-tidy] Improve modernize-redundant-void-arg to recognize macro uses
Sometimes a macro invocation will look like an argument list
declaration.  Improve the check to detect this situation and not
try to modify the macro invocation.

Thanks to Nathan James for the fix.

- Ignore implicit typedefs (e.g. compiler builtins)
- Improve lexing state machine to locate void argument tokens
- Add additional return_t() macro tests
- clang-format control in the test case file
- remove braces around single statements per LLVM style guide

Fixes #43791

Differential Revision: https://reviews.llvm.org/D116425
2022-01-12 13:51:50 -07:00
Simon Pilgrim dcc20143e1 [clang-tidy] UseDefaultMemberInitCheck::checkDefaultInit - Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is always dereferenced immediately below, so assert the cast is correct instead of returning nullptr
2022-01-12 15:35:37 +00:00
Kadir Cetinkaya c490f8feb7
[clangd][StdSymbolMap] Prefer std::remove from algorithm
std::remove from algorithm is a lot more common than the overload from
the cstdio (which deletes files). This patch introduces a set of symbols
for which we should prefer the overloaded versions.

Differential Revision: https://reviews.llvm.org/D114724
2022-01-12 15:25:42 +01:00
serge-sans-paille 35cca45b09 Misleading bidirectional detection
This patch implements detection of incomplete bidirectional sequence withing
comments and string literals within clang-tidy.

It detects the bidi part of https://www.trojansource.codes/trojan-source.pdf

Differential Revision: https://reviews.llvm.org/D112913
2022-01-12 11:38:36 +01:00
Florian Hahn eadb4cfeef
Revert (2) "[AST] Add RParen loc for decltype AutoTypeloc."
This reverts commit 41fbdfa4d5.

The commit breaks stage 2 builds with debug info, e.g.
https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/5088/console

Clang crashes with the following assertion when building
llvm-project/llvm/lib/Support/Timer.cpp

/usr/local/bin/sccache /Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/host-compiler/bin/clang++  -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/lib/Support -Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/include -fno-stack-protector -fno-common -Wno-profile-instr-unprofiled -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/clang-build/Build/module.cache -fcxx-modules -Xclang -fmodules-local-submodule-visibility -gmodules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -flto=thin  -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk   -std=c++14  -fno-exceptions -fno-rtti -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/lib/Support/Timer.cpp
Assertion failed: (((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow"), function getLocWithOffset, file /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/clang/include/clang/Basic/SourceLocation.h, line 135.
2022-01-12 10:09:37 +00:00
Carlos Galvez c4db521cea [clang] Introduce support for disabling warnings in system macros
Often we run into situations where we want to ignore
warnings from system headers, but Clang will still
give warnings about the contents of a macro defined
in a system header used in user-code.

Introduce a ShowInSystemMacro option to be able to
specify which warnings we do want to keep raising
warnings for. The current behavior is kept in this patch
(i.e. warnings from system macros are enabled by default).
The decision as to whether this should be an opt-in or opt-out
feature can be made in a separate patch.

To put the feature to test, replace duplicated code for
Wshadow and Wold-style-cast with the SuppressInSystemMacro tag.
Also disable the warning for C++20 designators, fixing #52944.

Differential Revision: https://reviews.llvm.org/D116833
2022-01-12 08:18:19 +00:00
Elvis Stansvik 36af073342 Accept string literal decay in conditional operator
The cppcoreguidelines-pro-bounds-array-to-pointer-decay check currently
accepts:

const char *b = i ? "foo" : "foobar";

but not

const char *a = i ? "foo" : "bar";

This is because the AST is slightly different in the latter case (see
https://godbolt.org/z/MkHVvs).

This eliminates the inconsistency by making it accept the latter form
as well.

Fixes https://github.com/llvm/llvm-project/issues/31155.
2022-01-11 15:05:30 -05:00
Haojian Wu 41fbdfa4d5 Reland "[AST] Add RParen loc for decltype AutoTypeloc."
Reland 55d96ac and 37ec65e with a clang-tidy fix.
2022-01-11 12:06:18 +01:00
Sam McCall 1e9b837585 [clangd] Save more getFileID in Selection
This saves about 10% of SelectionVisitor::pop().
2022-01-11 11:01:54 +01:00
Sam McCall 22ac067b2d [clangd] Small optimization in SelectionTree
This seems to be strictly faster in all cases. Before fixing D116978 it
was one of the hot paths, and may become one again.
2022-01-11 10:18:44 +01:00
Sam McCall 4258d68dc7 [Tooling] When transferring compile commands between files, always use '--'
"driver <flags> -- <input>" is a particularly convenient form of the
compile command to manipulate, with fewer special cases to handle.

Guaranteeing that the output command is of that form is cheap and makes
it easier to consume the result in some cases.

Differential Revision: https://reviews.llvm.org/D116721
2022-01-11 01:41:42 +01:00
Richard a2c33b0ec9 [clang-tidy] Refactor: Extract Class CheckRunner on check_clang_tidy.py
Break up the huge function by extracting a class, storing intermediate
state as class members and breaking up the big function into a group
of class methods all at the same level of abstraction.

Differential Revision: https://reviews.llvm.org/D56343
2022-01-10 15:44:12 -07:00
Logan Smith 988c3f5f96 [clang-tidy] Fix RenamerClangTidyChecks suggesting invalid macro identifiers
This behavior was fixed for regular identifiers in
9f3edc323a, but the same fix was not applied to
macro fixits. This addresses https://github.com/llvm/llvm-project/issues/52895.

Differential Revision: https://reviews.llvm.org/D116824
2022-01-10 10:35:04 -08:00
Nico Weber cf90b3cf7e Revert "[clangd] Enable expand-auto for decltype(auto)."
This reverts commit 37ec65e1d7.

Its prerequisite 55d96ac3dc wsa
reverted in c2293bc17d. c2293bc's
patch description claimed that it reverted 37ec65 as well,
but it apparently didn't.

See https://reviews.llvm.org/D116921#3231802
2022-01-10 12:01:42 -05:00
Haojian Wu c2293bc17d Revert "[AST] Add RParen loc for decltype AutoTypeloc."
This breaks a clang-tidy check, needs to investigate and fix. Revert
them to bring the buildbot back.

This reverts commit 55d96ac3dc and
37ec65e1d7
2022-01-10 15:18:41 +01:00
Haojian Wu 37ec65e1d7 [clangd] Enable expand-auto for decltype(auto).
Based on https://reviews.llvm.org/D116919.

Fixes https://github.com/clangd/clangd/issues/121

Differential Revision: https://reviews.llvm.org/D116921
2022-01-10 13:46:56 +01:00
Haojian Wu 55d96ac3dc [AST] Add RParen loc for decltype AutoTypeloc.
Differential Revision: https://reviews.llvm.org/D116919
2022-01-10 12:46:27 +01:00
Sam McCall 1ab13793be [clangd] Include fixer for missing functions in C
A function call `unresolved()` in C will generate an implicit declaration
of the missing function and warn `ext_implicit_function_decl` or so.
(Compared to in C++ where we get `err_undeclared_var_use`).
We want to try to resolve these names.

Unfortunately typo correction is disabled in sema for performance
reasons unless this warning is promoted to error.
(We need typo correction for include-fixer.)
It's not clear to me where a switch to force this correction on should
go, include-fixer is kind of a hack. So hack more by telling sema we're
promoting them to error.

Fixes https://github.com/clangd/clangd/issues/937

Differential Revision: https://reviews.llvm.org/D115490
2022-01-10 12:17:19 +01:00
Sam McCall 16fd5c2784 [clangd] Support configuration of inlay hints.
The idea is that the feature will always be advertised at the LSP level, but
depending on config we'll return partial or no responses.

We try to avoid doing the analysis for hints we're not going to return.

Examples of syntax:
```
InlayHints:
  Enabled: No
---
InlayHints:
  ParameterNames: No
---
InlayHints:
  ParameterNames: Yes
  DeducedTypes: Yes
```

Differential Revision: https://reviews.llvm.org/D116713
2022-01-10 10:49:35 +01:00
Haojian Wu 4a4b8e4f99 [AST] Add more source information for DecltypeTypeLoc.
Adds the paren source location, and removes the hack in clangd.

Differential Revision: https://reviews.llvm.org/D116793
2022-01-10 09:34:18 +01:00
Kazu Hirata 8afcfbfb8f Use true/false instead of 1/0 (NFC)
Identified by modernize-use-bool-literals.
2022-01-09 12:21:06 -08:00
Kazu Hirata b12fd13812 Fix bugprone argument comments.
Identified by bugprone-argument-comment.
2022-01-09 12:21:02 -08:00
Vitaly Buka 244dd2913a Don't pass uninitialized QueryKind
Even if findImplementors does not use
uninitialized parameter it's still UB and
it's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

Differential Revision: https://reviews.llvm.org/D116827
2022-01-07 17:14:08 -08:00
Vitaly Buka 669eb60046 Initialize HighlightingsBuilder::Resolver
Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

Differential Revision: https://reviews.llvm.org/D116828
2022-01-07 15:21:22 -08:00
Kazu Hirata e56a9c9b5b Remove redundant return statements (NFC)
Identified by readability-redundant-control-flow.
2022-01-07 07:42:35 -08:00
Sam McCall 7c19fdd599 [clangd] Polish clangd/inlayHints and expose them by default.
This means it's a "real feature" in clangd 14, albeit one that requires special
client support.

- remove "preview" from the flag description
- expose the `clangdInlayHints` capability by default
- provide `position` as well as `range`
- support `InlayHintsParams.range` to restrict the range retrieved
- inlay hint list is in document order (sorted by position)

Still to come: control feature via config rather than flag.

Fixes https://github.com/clangd/clangd/issues/313
Protocol doc is in https://github.com/llvm/clangd-www/pull/56/files

Differential Revision: https://reviews.llvm.org/D116699
2022-01-07 15:12:43 +01:00
Qiu Chaofan c2cc70e4f5 [NFC] Fix endif comments to match with include guard 2022-01-07 15:52:59 +08:00
Carlos Galvez 670de10f9d Disable clang-tidy warnings from system macros
Currently, it's inconsistent that warnings are disabled if they
come from system headers, unless they come from macros.
Typically a user cannot act upon these warnings coming from
system macros, so clang-tidy should ignore them unless the
user specifically requests warnings from system headers
via the corresponding configuration.

This change broke the ProTypeVarargCheck check, because it
was checking for the usage of va_arg indirectly, expanding it
(it's a system macro) to detect the usage of __builtin_va_arg.
The check has been fixed by checking directly what the rule
is about: "do not use va_arg", by adding a PP callback that
checks if any macro with name "va_arg" is expanded. The old
AST matcher is still kept for compatibility with Windows.

Add unit test that ensures warnings from macros are disabled
when not using the -system-headers flag. Document the change
in the Release Notes.

Differential Revision: https://reviews.llvm.org/D116378
2022-01-06 20:27:28 +00:00
Chuanqi Xu bbce75e352 Update Bug report URL to Github Issues
Although we moved to Github Issues. The bug report message refers to
Bugzilla still. This patch tries to update these URLs.

Reviewed By: MaskRay, Quuxplusone, jhenderson, libunwind, libc++

Differential Revision: https://reviews.llvm.org/D116351
2022-01-06 17:33:25 +08:00
Richard d7b6574c3b [clang-tidy] Recognize transformer checks as providing fixits
- Recognize older checks that might not end with Check.cpp
- Update list of checks based on improvements to add_new_check
- Fix spelling error in TransformerClangTidyCheck.h

Fixes #52962

Differential Revision: https://reviews.llvm.org/D116550
2022-01-05 16:13:52 -07:00
Nico Weber 085f078307 Revert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""
This reverts commit 859ebca744.
The change contained many unrelated changes and e.g. restored
unit test failes for the old lld port.
2022-01-05 13:10:25 -05:00
David Salinas 859ebca744 Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."
This reverts commit 640beb38e7.

That commit caused performance degradtion in Quicksilver test QS:sGPU and a functional test failure in (rocPRIM rocprim.device_segmented_radix_sort).
Reverting until we have a better solution to s_cselect_b64 codegen cleanup

Change-Id: Ibf8e397df94001f248fba609f072088a46abae08

Reviewed By: kzhuravl

Differential Revision: https://reviews.llvm.org/D115960

Change-Id: Id169459ce4dfffa857d5645a0af50b0063ce1105
2022-01-05 17:57:32 +00:00
Sam McCall 055d8090d1 [clangd] Don't index __reserved_names in headers.
Main use of these is in the standard library, where they generally clutter up
the index.

Certain macros are also common, we don't touch indexing of macros in this patch.

Differential Revision: https://reviews.llvm.org/D115301
2022-01-05 16:34:04 +01:00
Sam McCall bb10e03fba
[clangd] Refine comment on declarator ranges 2022-01-05 16:00:13 +01:00
Haojian Wu 7632d19ada [clangd] Fix typos in the SelectionTree comment. 2022-01-05 15:50:07 +01:00
Sam McCall 96f5cc1ee4 [clangd] Handle declarators more consistently in Selection.
Because declarators nest inside-out, we logically need to claim tokens for
parent declarators logically before child ones.
This is the ultimate reason we had problems with DeclaratorDecl, ArrayType etc.

However actually changing the order of traversal is hard, especially for nodes
that have both declarator and non-declarator children.
Since there's only a few TypeLocs corresponding to declarators, we just
have them claim the exact tokens rather than rely on nesting.

This fixes handling of complex declarators, like
`int (*Fun(OuterT^ype))(InnerType);`.

This avoids the need for the DeclaratorDecl early-claim hack, which is
removed.
Unfortunately the DeclaratorDecl early-claims were covering up an AST
anomaly around CXXConstructExpr, so we need to fix that up too.

Based on D116623 and D116618

Differential Revision: https://reviews.llvm.org/D116630
2022-01-05 15:40:47 +01:00
Clement Courbet ed8ff29aa6 [clang-tidy] Fix false positive in modernize-pass-by-value
The check should not trigger on lvalue/rvalue overload pairs:

```
struct S {
  S(const A& a) : a(a) {}
  S(A&& a) : a(std::move(a)) {}

  A a;
}
```

Differential Revision: https://reviews.llvm.org/D116535
2022-01-05 14:33:40 +01:00
Sam McCall 0683a1e588 [clangd] Adjust compile flags so they work when applied to other file(type)s.
It's reasonable to want to use the command from one file to compile another.
In particular, the command from a translation unit to parse a related header:
  {"file": "foo.h", "command": "clang foo.cpp"}

This is largely what InterpolatingCompilationDatabase tries to do.
To do this correctly can require nontrivial changes to the argv, because the
file extension affects semantics.  e.g. here we must add "-x c++header".

When external tools compile commands for different files, we should apply the
same adjustments. This is better than telling people to "fix their tools":
 - simple e.g. python scripts shouldn't have to interpret clang argv
 - this is a good way to represent the intent "parse header X in the context of
   file Y", which can work even if X is not self-contained. clangd does not
   support this today, but some other tools do, and we may one day.

This issue is discussed in https://github.com/clangd/clangd/issues/519

Differential Revision: https://reviews.llvm.org/D116167
2022-01-04 16:10:27 +01:00
Sam McCall 229c95ab66 [CodeCompletion] Signature help for aggregate initialization.
The "parameter list" is the list of fields which should be initialized.
We introduce a new OverloadCandidate kind for this.
It starts to become harder for CC consumers to handle all the cases for
params, so I added some extra APIs on OverloadCandidate to abstract them.

Includes some basic support for designated initializers.
The same aggregate signature is shown, the current arg jumps after the
one you just initialized. This follows C99 semantics for mixed
designated/positional initializers (which clang supports in C++ as an extension)
and is also a useful prompt for C++ as C++ designated initializers must be
in order.

Related bugs:
 - https://github.com/clangd/clangd/issues/965
 - https://github.com/clangd/clangd/issues/306

Differential Revision: https://reviews.llvm.org/D116326
2022-01-04 16:00:22 +01:00
Oleg Smolsky 051847cfec Improve the 'modernize-use-default-member-init'
We want to deal with non-default constructors that just happen to
contain constant initializers. There was already a negative test case,
it is now a positive one. We find and refactor this case:

struct PositiveNotDefaultInt {
  PositiveNotDefaultInt(int) : i(7) {}
  int i;
};
2022-01-04 07:27:02 -05:00
Haojian Wu cb9ccd38c5 [clangd] Move the selection decltype hack to getSourceRange.
Previously, it was in canSafelySkipNode, which is only used to decide
whether we should descend into it and its children, and we still used
the incomplete Decltypeloc.getSourceRange() to claim tokens, which will
cause some tokens were not claimed correctly.

Separate a change of https://reviews.llvm.org/D116536

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D116586
2022-01-04 12:11:58 +01:00
Haojian Wu 20f8f46c60 [clangd] Fix selection on multi-dimensional array.
This involves separating out the concepts of "which tokens should we
descend into this node for" vs "which tokens should this node claim".

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D116218
2022-01-04 11:53:42 +01:00
Sam McCall f2b3e25f86 [clangd] Add CompileFlags.Compiler option to override argv0
This is separate from --query-driver but can combine with it.

Fixes https://github.com/clangd/clangd/issues/642

Differential Revision: https://reviews.llvm.org/D116196
2022-01-04 11:38:27 +01:00
Sam McCall a61f34ea25 [clangd] Fix windows build after 478863ef58
http://45.33.8.238/win/51774/step_4.txt

MS extension causes the wrong class to be friended.
2022-01-03 20:17:20 +01:00
Sam McCall 92417eaf33 [CodeCompletion] Signature help for braced constructor calls
Implementation is based on the "expected type" as used for
designated-initializers in braced init lists. This means it can deduce the type
in some cases where it's not written:

  void foo(Widget);
  foo({ /*help here*/ });

Only basic constructor calls are in scope of this patch, excluded are:
 - aggregate initialization (no help is offered for aggregates)
 - initializer_list initialization (no help is offered for these constructors)

Fixes https://github.com/clangd/clangd/issues/306

Differential Revision: https://reviews.llvm.org/D116317
2022-01-03 20:14:59 +01:00
Sam McCall 478863ef58 [clangd] Basic IncludeCleaner support for c/c++ standard library
There are some limitations here, so this is behind a flag for now (in addition
to the config setting for the overall feature).

- symbols without exactly one associated header aren't handled right
- no macro support
- referencing std::size_t usually doesn't leave any trace in the AST that the
  alias in std was used, so we associate with stddef.h instead of cstddef.
  (An AST issue not specific to stdlib, but much worse there)

Differential Revision: https://reviews.llvm.org/D114077
2022-01-03 18:19:56 +01:00
Sam McCall fe68088d44 [clangd] Helper for determining member insertion point.
To be used in D116490 and D116385, and an upcoming patch to generate C++
constructors.

Differential Revision: https://reviews.llvm.org/D116502
2022-01-03 17:59:45 +01:00
Sam McCall 9e6f88b31a [clangd] Respect .clang-tidy ExtraArgs (-Wfoo only) when producing diagnostics
This mechanism is used almost exclusively to enable extra warnings in clang-tidy
using ExtraArgs=-Wfoo, Checks="clang-diagnostic-foo".
Its presence is a strong signal that these flags are useful.

We choose not to actually emit them as clang-tidy diagnostics, but under their
"main" name - this ensures we show the same diagnostic in a consistent way.

We don't add the ExtraArgs to the compile command in general, but rather just
handle the -W<group> flags, which is the common case and avoids unexpected
side-effects.
And we only do this for the main file parse, when producing diagnostics.

Differential Revision: https://reviews.llvm.org/D116147
2022-01-03 17:58:41 +01:00
Sam McCall cd45e8c7bc [CodeCompletion] Signature help for template argument lists
Provide signature while typing template arguments: Foo< ^here >
Here the parameters are e.g. "typename x", and the result type is e.g.
"struct" (class template) or "int" (variable template) or "bool (std::string)"
(function template).

Multiple overloads are possible when a template name is used for several
overloaded function templates.

Fixes https://github.com/clangd/clangd/issues/299

Differential Revision: https://reviews.llvm.org/D116352
2022-01-03 16:28:16 +01:00
Kazu Hirata e47a224ccf [clang-tidy] Use nullptr instead of 0 or NULL (NFC)
Identified with modernize-use-nullptr.
2021-12-31 13:54:34 -08:00
Kazu Hirata 255ee643a8 [clang-tools-extra] Remove unused using (NFC)
Identified by misc-unused-using-decls.
2021-12-31 10:51:10 -08:00
Kazu Hirata 0542d15211 Remove redundant string initialization (NFC)
Identified with readability-redundant-string-init.
2021-12-26 09:39:26 -08:00
Kazu Hirata 2d303e6781 Remove redundant return and continue statements (NFC)
Identified with readability-redundant-control-flow.
2021-12-24 23:17:54 -08:00
Kazu Hirata 3cfe375ae4 Use StringRef::contains (NFC) 2021-12-24 22:05:34 -08:00
Kazu Hirata 62e48ed10f Use isa instead of dyn_cast (NFC) 2021-12-24 21:22:27 -08:00
Salman Javed d840f3edf0 Resolve -Wdocumentation warning in ClangTidyDiagnosticConsumer (NFC)
Change to comments only; NFC.

```
ClangTidyDiagnosticConsumer.h:245:6: warning: '\param' command used in a
comment that is not attached to a function declaration [-Wdocumentation]
```

See this build for an example:
https://lab.llvm.org/buildbot/#/builders/109/builds/27293/steps/5/logs/warnings__702_
2021-12-23 10:25:05 +13:00
Salman Javed 86618e37bd Resolve lint warning about converting unsigned to signed (NFC)
FileOffset is unsigned while getLocWithOffset() requires a signed value.
2021-12-23 09:46:14 +13:00
Ivan Gerasimov fd8fc5e8d9 [clang-tidy] abseil-string-find-startswith: detect `s.rfind(z, 0) == 0`
Suggest converting `std::string::rfind()` calls to `absl::StartsWith()`
where possible.
2021-12-22 16:45:51 +01:00
Kadir Cetinkaya 1a929525e8
[clangd] Return error for textdocument/outgoingCalls rather than success 2021-12-21 17:06:59 +01:00
Sam McCall 6f1a501fdd [clangd] Fix typo in test. NFC 2021-12-21 14:17:25 +01:00
Sam McCall af27466c50 Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit cc56c66f27.
Fixed a bad assertion, the target of a UsingShadowDecl must not have
*local* qualifiers, but it can be a typedef whose underlying type is qualified.
2021-12-20 18:03:15 +01:00
Sam McCall cc56c66f27 Revert "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit e1600db19d.

Breaks sanitizer tests, at least on windows:
https://lab.llvm.org/buildbot/#/builders/127/builds/21592/steps/4/logs/stdio
2021-12-20 17:53:56 +01:00
Kadir Cetinkaya 81967b4fa7
[clangd] Don't trim xrefs references if we overran the limit
This preserves all the results we've processed already rather than
throwing them away in the end.
It has some performance implications on the edge cases, in the worst case we
might issue 1 relations and 2 xrefs requests in extra to deduce `HasMore`
correctly.

Fixes https://github.com/clangd/clangd/issues/204.

Differential Revision: https://reviews.llvm.org/D116043
2021-12-20 17:22:24 +01:00
Sam McCall e1600db19d [AST] Add UsingType: a sugar type for types found via UsingDecl
Currently there's no way to find the UsingDecl that a typeloc found its
underlying type through. Compare to DeclRefExpr::getFoundDecl().

Design decisions:
- a sugar type, as there are many contexts this type of use may appear in
- UsingType is a leaf like TypedefType, the underlying type has no TypeLoc
- not unified with UnresolvedUsingType: a single name is appealing,
  but being sometimes-sugar is often fiddly.
- not unified with TypedefType: the UsingShadowDecl is not a TypedefNameDecl or
  even a TypeDecl, and users think of these differently.
- does not cover other rarer aliases like objc @compatibility_alias,
  in order to be have a concrete API that's easy to understand.
- implicitly desugared by the hasDeclaration ASTMatcher, to avoid
  breaking existing patterns and following the precedent of ElaboratedType.

Scope:
- This does not cover types associated with template names introduced by
  using declarations. A future patch should introduce a sugar TemplateName
  variant for this. (CTAD deduced types fall under this)
- There are enough AST matchers to fix the in-tree clang-tidy tests and
  probably any other matchers, though more may be useful later.

Caveats:
- This changes a fairly common pattern in the AST people may depend on matching.
  Previously, typeLoc(loc(recordType())) matched whether a struct was
  referred to by its original scope or introduced via using-decl.
  Now, the using-decl case is not matched, and needs a separate matcher.
  This is similar to the case of typedefs but nevertheless both adds
  complexity and breaks existing code.

Differential Revision: https://reviews.llvm.org/D114251
2021-12-20 17:15:38 +01:00
Danila Kutenin cff192739b [clang-include-fixer] Fix incorrect ranking because of dangling references
SymbolAndSignals stores SymbolInfo which stores two std::strings. Then
the values are stored in a llvm::DenseMap<llvm::StringRef, double>. When
the sorting is happening, SymbolAndSignals are swapped and thus because
of small string optimization some strings may become invalid. This
results in incorrect ranking.

This was detected when running new std::sort algorithm against llvm
toolchain. This could have been prevented with running llvm::sort and
EXPENSIVE_CHECKS. Unfortunately, no sanitizer yelled.

I don't have commit rights, kutdanila@yandex.ru Danila Kutenin

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D116037
2021-12-20 15:56:57 +01:00
Aleksandr Platonov 555eacf75f [clangd] Fix undefined behavior when generating error message at rename with an invalid name
`Message()` lambda uses `Reason.Details` as an input parameter for `llvm::formatv()`, but `Reason` in `Message()` is a local object.
Return value of `llvm::formatv()` contains references to its input arguments, thus `Message()` returns an object which contains a reference to `Details` field of the local object `Reason`.
This patch fixes this behavior by passing `Reason` as a reference to `Message()` to ensure that return value of `Message()` contains references to alive object and also prevents copying of `InvalidName` structure at passing it to `makeError()`.

Provided test passes on Linux+GCC with or without this patch, but fails on Windows+VisualStudio without this patch.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D115959
2021-12-19 22:28:26 +03:00
Paul Altin 9198d04c06 Allow disabling integer to floating-point narrowing conversions for cppcoreguidelines-narrowing-conversions
This change adds an option to disable warnings from the
cppcoreguidelines-narrowing-conversions check on integer to floating-
point conversions which may be narrowing.

An example of a case where this might be useful:
```
std::vector<double> v = {1, 2, 3, 4};
double mean = std::accumulate(v.cbegin(), v.cend(), 0.0) / v.size();
```
The conversion from std::size_t to double is technically narrowing on
64-bit systems, but v almost certainly does not have enough elements
for this to be a problem.

This option would allow the cppcoreguidelines-narrowing-conversions
check to be enabled on codebases which might otherwise turn it off
because of cases like the above.
2021-12-16 08:24:09 -05:00
Markus Böck b7d55771ce [clang-tidy][#51939] Exempt placement-new expressions from 'bugprone-throw-keyword-missing'
The purpose of this checker is to flag a missing throw keyword, and does so by checking for the construction of an exception class that is then unused.
This works great except that placement new expressions are also flagged as those lead to the construction of an object as well, even though they are not temporary (as that is dependent on the storage).
This patch fixes the issue by exempting the match if it is within a placement-new.

Fixes https://github.com/llvm/llvm-project/issues/51939

Differential Revision: https://reviews.llvm.org/D115576
2021-12-15 16:59:14 +01:00
Kadir Cetinkaya 517f1d9e5c
[clangd] Add ) to signature-help triggers
It is important for nested function calls.

Differential Revision: https://reviews.llvm.org/D115799
2021-12-15 14:56:27 +01:00
Haojian Wu b7d2d14747 [clangd] Disable the NOLINTBBEGIN testcase in clangd.
NOLINTBEGIN is disabled, in 529833377c
2021-12-15 11:32:27 +01:00
Sam McCall 529833377c [clangd] Disable support for clang-tidy suppression blocks (NOLINTBEGIN)
The implementation is very inefficient and we pay the cost even when the feature is not used

Differential Revision: https://reviews.llvm.org/D115650
2021-12-15 10:58:30 +01:00
Sam McCall 6917f87b3c [clangd] Cleanup unneeded use of shared_ptr. NFC 2021-12-15 02:13:50 +01:00
Stephan T. Lavavej 8bd106a891 [NFC] Fix typos in release notes.
Reviewed By: ldionne, Mordante, MaskRay

Differential Revision: https://reviews.llvm.org/D115685
2021-12-14 14:19:42 -08:00
Kadir Cetinkaya a47af1ac34
[clangd][Dex] Fix crashes when building trigrams for empty identifier 2021-12-13 15:58:33 +01:00
Sam McCall ac431fc2cd [clangd] ... and mark a new test as -fno-ms-compatibility too 2021-12-11 02:41:39 +01:00
Sam McCall 1a68c14b57 [clangd] Restore -fno-ms-compatibility to tests
Turns out these weren't obsolete after all...
http://45.33.8.238/win/50653/step_9.txt
2021-12-11 02:31:26 +01:00
Sam McCall c25ea488a3 [clangd] Include-fixer: handle more "incomplete type" diags.
I started adding tests for all diags but found there were just too many cases.

Differential Revision: https://reviews.llvm.org/D115484
2021-12-11 01:46:35 +01:00
Sam McCall a8bf389f41 [clangd] Clean up some include-fixer tests. NFC 2021-12-11 01:31:03 +01:00
Kadir Cetinkaya d3606a3375
[clangd] Provide documentation as MarkupContent in signaturehelp
This unifies the behaviour we have in code completion item
documentations and signaturehelp. Providing better line wrapping and detection
of inline code blocks in comments to be renedered appropriately in markdown.

Differential Revision: https://reviews.llvm.org/D115442
2021-12-10 12:58:08 +01:00
CJ Johnson a1968d5341 Prevent abseil-cleanup-ctad check from stomping on surrounding context
This change applies two fixes to the abseil-cleanup-ctad check. It uses hasSingleDecl() to ensure only declStmt()s with one varDecl() are matched (leaving compount declStmt()s unchanged). It also addresses a bug in the handling of comments that surround the absl::MakeCleanup() calls by switching to the callArgs() combinator from Clang Transformer.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D115452
2021-12-09 17:41:12 +00:00
lh123 53219009aa [clang][clangd] Desugar array type.
Desugar array type.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D115107
2021-12-09 20:12:48 +08:00
Adrian Vogelsgesang 5d3b8956e8 Don't offer partial fix-its for `modernize-pass-by-value`
This commit improves the fix-its of modernize-pass-by-value by
no longer proposing partial fixes. In the presence of using/typedef,
we failed to rewrite the function signature but still adjusted the
function body. This led to incorrect, partial fix-its. Instead, the
check now simply doesn't offer any fixes at all in such a situation.
2021-12-08 13:31:30 -05:00
Kirill Bobyrev b673bc36ea [clangd] Suppress IncludeCleaner warnings for headers behind pragma keep
D114072 allows filtering out the warnings for headers behind `// IWYU pragma:
keep`. This is the first step towards more useful IWYU pragmas support and
fine-grained control over the IncludeCleaner warnings.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D115345
2021-12-08 18:07:40 +01:00
Sam McCall 2676759bf2 [clangd] Add fixes for clang "include <foo.h>" diagnostics
Clang doesn't offer these fixes I guess for a couple of reasons:
 - where to insert includes is a formatting concern, and clang shouldn't
   depend on clang-format
 - the way clang prints diagnostics, we'd show a bunch of basically irrelevant
   context of "this is where we'd want to insert the include"

Maybe it's possible to hack around 1, but 2 is still a concern.
Meanwhile, bolting this onto include-fixer gets the job done.

Fixes https://github.com/clangd/clangd/issues/355
Fixes https://github.com/clangd/clangd/issues/937

Differential Revision: https://reviews.llvm.org/D114667
2021-12-08 16:16:53 +01:00
Kirill Bobyrev eecfc73ae4
[clangd] Record IWYU pragma keep in the IncludeStructure
This will allow the IncludeCleaner to suppress warnings on the lines with "IWYU
pragma: keep".

Clang APIs are not very convinient, so the code has to navigate around it.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D114072
2021-12-08 15:55:50 +01:00
lh123 6fe577b1c1 [clangd] Make a.k.a printing configurable.
Currently, a.k.a printing is closed by default.

Reviewed By: sammccall, kadircet

Differential Revision: https://reviews.llvm.org/D114665
2021-12-08 14:17:01 +08:00
lh123 ec64d10340 [clangd] Add desugared type to hover
Add desugared type to hover when the desugared type and the pretty-printed type are different.

```c++
template<typename T>
struct TestHover {
  using Type = T;
};

int main() {
  TestHover<int>::Type a;
}
```

```
variable a

Type: TestHover<int>::Type (aka int)
```

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114522
2021-12-08 13:28:12 +08:00
lh123 51dc466642 [clangd] Print type for VarTemplateDecl in hover.
Print type for VarTemplateDecl in hover.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D115108
2021-12-08 01:20:14 +08:00
Kirill Bobyrev 976a74d7d2 [clangd] Dex Trigrams: Improve query trigram generation
These are the trigrams for queries right now:

- "va" -> {Trigram("va")}
- "va_" -> {} (empty)

This is suboptimal since the resulting query will discard the query information
and return all symbols, some of which will be later be scored expensively
(fuzzy matching score). This is related to
https://github.com/clangd/clangd/issues/39 but does not fix it. Accidentally,
because of that incorrect behavior, when user types "tok::va" there are no
results (the issue is that `tok::kw___builtin_va_arg` does not have "va" token)
but when "tok::va_" is typed, expected result (`tok::kw___builtin_va_arg`)
shows up by accident. This is because the dex query transformer will only
lookup symbols within the `tok::` namespace. There won't be many, so the
returned results will contain symbol we need; this symbol will be filtered out
by the expensive checks and that will be displayed in the editor.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D113995
2021-12-07 15:46:13 +01:00
Aaron Ballman 6c75ab5f66 Introduce _BitInt, deprecate _ExtInt
WG14 adopted the _ExtInt feature from Clang for C23, but renamed the
type to be _BitInt. This patch does the vast majority of the work to
rename _ExtInt to _BitInt, which accounts for most of its size. The new
type is exposed in older C modes and all C++ modes as a conforming
extension. However, there are functional changes worth calling out:

* Deprecates _ExtInt with a fix-it to help users migrate to _BitInt.
* Updates the mangling for the type.
* Updates the documentation and adds a release note to warn users what
is going on.
* Adds new diagnostics for use of _BitInt to call out when it's used as
a Clang extension or as a pre-C23 compatibility concern.
* Adds new tests for the new diagnostic behaviors.

I want to call out the ABI break specifically. We do not believe that
this break will cause a significant imposition for early adopters of
the feature, and so this is being done as a full break. If it turns out
there are critical uses where recompilation is not an option for some
reason, we can consider using ABI tags to ease the transition.
2021-12-06 12:52:01 -05:00
Carlos Galvez 946eb7a037 [clang-tidy][NFC] Move CachedGlobList to GlobList.h
Currently it's hidden inside ClangTidyDiagnosticConsumer,
so it's hard to know it exists.

Given that there are multiple uses of globs in clang-tidy,
it makes sense to have these classes publicly available
for other use cases that might benefit from it.

Also, add unit test by converting the existing tests
for GlobList into typed tests.

Reviewed By: salman-javed-nz

Differential Revision: https://reviews.llvm.org/D113422
2021-12-04 08:50:49 +00:00
Balázs Kéri 1cefe91d40 [clang-tidy][docs][NFC] Improve documentation of bugprone-unhandled-exception-at-new
Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D114602
2021-12-03 16:53:08 +01:00
Kirill Bobyrev bab7a30ab6 [clangd] IncludeCleaner: Do not require forward declarations of RecordDecls when definition is available
This makes IncludeCleaner more useful in the presense of a large number of
forward declarations. If the definition is already in the Translation Unit and
visible to the Main File, forward declarations have no effect.

The original patch D112707 was split in two: D114864 and this one.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D114949
2021-12-03 09:36:50 +01:00
lh123 7bb785cc33 [clangd] Show parameters for construct.
Show parameters for construct.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D114621
2021-12-03 13:20:41 +08:00
Vy Nguyen aba8f320cc [clang-tidy][objc] Finds and fixes improper usages of XCTAssertEquals and XCTAssertNotEquals.
Using XCTAssertEqual on NSString* objects is almost always  wrong.

Unfortunately, we have seen a lot of tests doing this and reyling on pointer equality for strings with the same values (which happens to work sometimes - depending on the linker, but this assumption is not guaranteed by the language)

These fixes would make tests less brittle.

Differential Revision: https://reviews.llvm.org/D114975
2021-12-02 18:32:16 -05:00
Yitzhak Mandelbaum 081074e1ea [clang-tidy] Allow disabling support for NOLINTBEGIN/NOLINTEND blocks.
This patch parameterizes the clang-tidy diagnostic consumer with a boolean that
controls whether to honor NOLINTBEGIN/NOLINTEND blocks. The current support for
scanning these blocks is very costly -- O(n*m) in the size of files (n) and
number of diagnostics found (m), with a large constant factor.  So, the patch
allows clients to disable it.

Future patches should make the feature more efficient, but this will mitigate in
the interim.

Differential Revision: https://reviews.llvm.org/D114981
2021-12-02 22:19:05 +00:00
Christian Kühnel 5bd643d31d [clangd] cleanup of header guard names
Renaming header guards to match the LLVM convention.
This patch was created by automatically applying the fixes from
clang-tidy.

I've removed the [NFC]  tag from the title, as we're adding header guards in some files and thus might trigger behavior changes.

Differential Revision: https://reviews.llvm.org/D113896
2021-12-02 15:58:35 +00:00
Yitzhak Mandelbaum c006ea6bde [clang-tidy] Fix build broken by commit 6a9487df73 (D113148) 2021-12-02 14:41:00 +00:00
CJ Johnson 6a9487df73 Add new clang-tidy check for string_view(nullptr)
Checks for various ways that the `const CharT*` constructor of `std::basic_string_view` can be passed a null argument and replaces them with the default constructor in most cases. For the comparison operators, braced initializer list does not compile so instead a call to `.empty()` or the empty string literal are used, where appropriate.

This prevents code from invoking behavior which is unconditionally undefined. The single-argument `const CharT*` constructor does not check for the null case before dereferencing its input. The standard is slated to add an explicitly-deleted overload to catch some of these cases: wg21.link/p2166

https://reviews.llvm.org/D114823 is a companion change to prevent duplicate warnings from the `bugprone-string-constructor` check.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D113148
2021-12-02 13:25:28 +00:00
Kirill Bobyrev d3a4ef3568 [clangd] IncludeClenaer: Don't mark forward declarations of a class if it's declared in the main file
This will mark more headers that are unrelated to used symbol but contain its
forawrd declaration. E.g. the following are examples of headers forward
declaring `llvm::StringRef`:

- clang/include/clang/Basic/Cuda.h
- llvm/include/llvm/Support/SHA256.h
- llvm/include/llvm/Support/TrigramIndex.h
- llvm/include/llvm/Support/RandomNumberGenerator.
- ... and more (~50 in total)

This patch is a reduced version of D112707 which was controversial.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D114864
2021-12-02 10:26:08 +01:00
Fabian Wolff 987a21522f [clang-tidy] Use `hasCanonicalType()` matcher in `bugprone-unused-raii` check
Fixes PR#52217.

Reviewed By: simon.giesecke

Differential Revision: https://reviews.llvm.org/D113429
2021-12-02 01:53:12 +01:00
Fabian Wolff 844a8d3cec Fix false positives in `fuchsia-trailing-return` check involving deduction guides
Fixes PR#47614. Deduction guides, implicit or user-defined, look like
function declarations in the AST. They aren't really functions, though,
and they always have a trailing return type, so it doesn't make sense
to issue this warning for them.
2021-12-01 15:28:01 -05:00
Michael Jones 155f5a6dac [libc][clang-tidy] fix namespace check for externals
Up until now, all references to `errno` were marked with `NOLINT`, since
it was technically calling an external function. This fixes the lint
rules so that `errno`, as well as `malloc`, `calloc`, `realloc`, and
`free` are all allowed to be called as external functions. All of the
relevant `NOLINT` comments have been removed, and the documentation has
been updated.

Reviewed By: sivachandra, lntue, aaron.ballman

Differential Revision: https://reviews.llvm.org/D113946
2021-11-30 11:44:24 -08:00
Kadir Cetinkaya 3356d8837e
[clangd] Make std symbol generation script python3 friendly
Differential Revision: https://reviews.llvm.org/D114723
2021-11-30 10:15:36 +01:00
Carlos Galvez 5bbe50148f [clang-tidy] Warn on functional C-style casts
The google-readability-casting check is meant to be on par
with cpplint's readability/casting check, according to the
documentation. However it currently does not diagnose
functional casts, like:

float x = 1.5F;
int y = int(x);

This is detected by cpplint, however, and the guidelines
are clear that such a cast is only allowed when the type
is a class type (constructor call):

> You may use cast formats like `T(x)` only when `T` is a class type.

Therefore, update the clang-tidy check to check this
case.

Differential Revision: https://reviews.llvm.org/D114427
2021-11-30 07:31:17 +00:00
Salman Javed c7aa358798 [clang-tidy] Fix pr48613: "llvm-header-guard uses a reserved identifier"
Fixes https://bugs.llvm.org/show_bug.cgi?id=48613.

llvm-header-guard is suggesting header guards with leading underscores
if the header file path begins with a '/' or similar special character.
Only reserved identifiers should begin with an underscore.

Differential Revision: https://reviews.llvm.org/D114149
2021-11-30 12:43:35 +13:00
Zhuo Zhang d96f92ff16 fix typos in comments 2021-11-29 14:06:33 +01:00
Balazs Benics a8120a7711 [clang-tidy] Ignore narrowing conversions in case of bitfields
Bitfields are special. Due to integral promotion [conv.prom/5] bitfield
member access expressions are frequently wrapped by an implicit cast to
`int` if that type can represent all the values of the bitfield.

Consider these examples:
  struct SmallBitfield { unsigned int id : 4; };
  x.id & 1;             (case-1)
  x.id & 1u;            (case-2)
  x.id << 1u;           (case-3)
  (unsigned)x.id << 1;  (case-4)

Due to the promotion rules, we would get a warning for case-1. It's
debatable how useful this is, but the user at least has a convenient way
of //fixing// it by adding the `u` unsigned-suffix to the literal as
demonstrated by case-2. However, this won't work for shift operators like
the one in case-3. In case of a normal binary operator, both operands
contribute to the result type. However, the type of the shift expression is
the promoted type of the left operand. One could still suppress this
superfluous warning by explicitly casting the bitfield member access as
case-4 demonstrates, but why? The compiler already knew that the value from
the member access should safely fit into an `int`, why do we have this
warning in the first place? So, hereby we suppress this specific scenario,
when a bitfield's value is implicitly cast to int (likely due to integral
promotion).

Note that the bitshift operation might invoke unspecified/undefined
behavior, but that's another topic, this checker is about detecting
conversion-related defects.

Example AST for `x.id << 1`:
  BinaryOperator 'int' '<<'
  |-ImplicitCastExpr 'int' <IntegralCast>
  | `-ImplicitCastExpr 'unsigned int' <LValueToRValue>
  |   `-MemberExpr 'unsigned int' lvalue bitfield .id
  |     `-DeclRefExpr 'SmallBitfield' lvalue ParmVar 'x' 'SmallBitfield'
  `-IntegerLiteral 'int' 1

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D114105
2021-11-29 09:56:43 +01:00
Balazs Benics e1d0673aee [clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls
Reviewed-By: martong

Differential Revision: https://reviews.llvm.org/D114256
2021-11-29 09:56:43 +01:00
Balazs Benics 0540485436 [libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges
Invalid SourceRanges can occur generally if the code does not compile,
thus we expect clang error diagnostics.
Unlike `clang`, `clang-tidy` did not swallow invalid source ranges, but
tried to highlight them, and blow various assertions.

The following two examples produce invalid source ranges, but this is
not a complete list:

  void test(x); // error: unknown type name 'x'
  struct Foo {
    member; // error: C++ requires a type specifier for all declarations
  };

Thanks @whisperity helping me fix this.

Reviewed-By: xazax.hun

Differential Revision: https://reviews.llvm.org/D114254
2021-11-29 09:56:43 +01:00
Balazs Benics 0685e83534 Fix cppcoreguidelines-virtual-base-class-destructor in macros
The `cppcoreguidelines-virtual-base-class-destructor` checker crashed on
this example:

  #define DECLARE(CLASS) \
  class CLASS {          \
  protected:             \
    virtual ~CLASS();    \
  }
  DECLARE(Foo); // no-crash

The checker will hit the following assertion:

  clang-tidy: llvm/include/llvm/ADT/Optional.h:196: T &llvm::optional_detail::OptionalStorage<clang::Token, true>::getValue() & [T = clang::Token]: Assertion `hasVal' failed."

It turns out, `Lexer::findNextToken()` returned `llvm::None` within the
`getVirtualKeywordRange()` function when the `VirtualEndLoc`
SourceLocation represents a macro expansion.
To prevent this from happening, I decided to propagate the `llvm::None`
further up and only create the removal of `virtual` if the
`getVirtualKeywordRange()` succeeds.

I considered an alternative fix for this issue:
I could have checked the `Destructor.getLocation().isMacroID()` before
doing any Fixit calculation inside the `check()` function.
In contrast to this approach my patch will preserve the diagnostics and
drop the fixits only if it would have crashed.

Reviewed By: whisperity

Differential Revision: https://reviews.llvm.org/D113558
2021-11-29 09:56:43 +01:00
Kirill Bobyrev 34cc210aa8
[clangd] IncludeCleaner: Attribute symbols from non self-contained headers to their parents
When a symbol comes from the non self-contained header, we recursively uplift
the file we consider used to the first includer that has a header guard. We
need to do this while we still have FileIDs because every time a non
self-contained header is included, it gets a new FileID but is later
deduplicated by HeaderID and it's not possible to understand where it was
included from.

Based on D114370.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114623
2021-11-26 16:20:48 +01:00
Kirill Bobyrev cd0ca5a0ea
[clangd] Record information about non self-contained headers in IncludeStructure
This will be useful for IncludeCleaner.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114370
2021-11-26 14:12:54 +01:00
Quinn Pham c3dc6b081d [NFC][clang-tools-extra] Inclusive language: replace master with main
[NFC] As part of using inclusive language within the llvm project, this patch
replaces master with main in `SubModule2.h`.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114100
2021-11-25 11:01:16 -06:00
Kirill Bobyrev 59e4a67081
[clangd] Move IncludeCleaner tracer to the actual computation
This way we won't get results with 0 ms for all the users with disabled
IncludeCleaner.
2021-11-25 13:19:01 +01:00
Sheldon Neuberger e2cad4df22
[clangd] Add ObjC method support to prepareCallHierarchy
This fixes "textDocument/prepareCallHierarchy" in clangd for ObjC methods. Details at https://github.com/clangd/vscode-clangd/issues/247.

clangd uses Decl::isFunctionOrFunctionTemplate to check if the decl given in a prepareCallHierarchy request is eligible for prepareCallHierarchy. We change to use isFunctionOrMethod which includes functions and ObjC methods.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D114058
2021-11-25 11:23:24 +01:00
Kadir Cetinkaya cdd37e2e47
[clangd] Disable hicpp-invalid-access-moved inside clangd 2021-11-25 10:27:45 +01:00
Clement Courbet 3b72448084 [clang-tidy] Add unit tests for `DeclRefExprUtils`.
In preparation for D114539.
2021-11-24 16:47:55 +01:00
Clement Courbet ba4411e7c6 [clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.
`isConstRefReturningMethodCall` should be considering
`CXXOperatorCallExpr` in addition to `CXXMemberCallExpr`. Clang considers
these to be distinct (`CXXOperatorCallExpr` derives from `CallExpr`, not
`CXXMemberCallExpr`), but we don't care in the context of this
check.

This is important because of
`std::vector<Expensive>::operator[](size_t) const`.

Differential Revision: https://reviews.llvm.org/D114249
2021-11-24 08:07:21 +01:00
Salman Javed a82942dd07 Add missing clang-tidy args in index.rst (NFC)
The RST docs have gone out of sync with the command-line args that the
clang-tidy program actually supports.
2021-11-22 22:50:05 +13:00
Kirill Bobyrev b5f20372a8
[clangd] IncludeCleaner: Mark possible expr resolutions as used
Fixes: https://github.com/clangd/clangd/issues/934

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D114287
2021-11-22 10:44:24 +01:00
Salman Javed 83484f8472 Fix nits in clang-tidy's documentation (NFC)
Add commas, articles, and conjunctions where missing.
2021-11-22 21:10:24 +13:00
Felix Berger fefe20b993 [clang-tidy] performance-unnecessary-copy-initialization: Correctly match the type name of the thisPointertype.
The matching did not work correctly for pointer and reference types.

Differential Revision: https://reviews.llvm.org/D114212

Reviewed-by: courbet
2021-11-20 15:13:41 -05:00
Sam McCall f764a1a5bd [clangd] Avoid possible crash: apply configuration after binding methods
The configuration may kick off indexing, which may involve sending LSP
messages.
The crash is fiddly to reproduce in a hermetic test (we need background
indexing on without disk storage, and to handle server->client messages
in LSPClient...)

Fixes https://github.com/clangd/clangd/issues/926
2021-11-20 01:13:38 +01:00
Fabian Wolff 6259016361 [clang-tidy] Fix false positive in readability-identifier-naming check involving override attribute
Overriding methods should not get a readability-identifier-naming
warning because the issue can only be fixed in the base class; but the
current check for whether a method is overriding does not take the
override attribute into account.

Differential Revision: https://reviews.llvm.org/D113830
2021-11-19 22:31:11 +13:00
Matt Beardsley 85e03cb7eb [clang-tidy] fix debug-only test failure
The clang-tidy/infrastructure/pr37091.cpp test inherits the top-level .clang-tidy configuration because it doesn't specify its own checks. It'd be a more stable test if it operates independently of the top-level .clang-tidy settings.

I've made the clang-tidy/infrastructure/pr37091.cpp test independent of the top-level .clang-tidy (picked an arbitrary check that I saw another clang-tidy/infrastructure test was also using: clang-tidy/infrastructure/temporaries.cpp)

Reviewed By: kbobyrev

Differential Revision: https://reviews.llvm.org/D114034
2021-11-19 10:19:07 +01:00
Adam Czachorowski 55a79318c6 [clang][clangd] Improve signature help for variadic functions.
This covers both C-style variadic functions and template variadic w/
parameter packs.

Previously we would return no signatures when working with template
variadic functions once activeParameter reached the position of the
parameter pack (except when it was the only param, then we'd still
show it when no arguments were given). With this commit, we now show
signathure help correctly.

Additionally, this commit fixes the activeParameter value in LSP output
of clangd in the presence of variadic functions (both kinds). LSP does
not allow the activeParamter to be higher than the number of parameters
in the active signature. With "..." or parameter pack being just one
argument, for all but first argument passed to "..." we'd report
incorrect activeParameter value. Clients such as VSCode would then treat
it as 0, as suggested in the spec) and highlight the wrong parameter.

In the future, we should add support for per-signature activeParamter
value, which exists in LSP since 3.16.0. This is not part of this
commit.

Differential Revision: https://reviews.llvm.org/D111318
2021-11-18 15:50:47 +01:00
Christian Kühnel 7aa2ce0fab [NFC][clangd] fix clang-tidy finding on isa_and_nonnull
This is a cleanup of the only llvm-prefer-isa-or-dyn-cast-in-conditionals finding in the clangd code base. This patch was created by automatically applying the fixes from clang-tidy.

Differential Revision: https://reviews.llvm.org/D113899
2021-11-18 09:16:54 +00:00
Kadir Cetinkaya e76e572989
[clangd] Dont include file version in task name
This will drop file version information from span names, reducing
overall cardinality and also effect logging when skipping actions in scheduler.

Differential Revision: https://reviews.llvm.org/D113390
2021-11-17 19:10:09 +01:00
Christian Kühnel ec4a2c9565 [NFC][clangd] cleanup llvm-else-after-return findings
Cleanup of clang-tidy findings: removing "else" after a return statement
to improve readability of the code.

This patch was created by applying the clang-tidy fixes automatically.

Differential Revision: https://reviews.llvm.org/D113892
2021-11-17 14:37:03 +00:00
Haojian Wu 4ea066acc9 [clangd] Fix assertion crashes on unmatched NOLINTBEGIN comments.
The overload shouldSuppressDiagnostic seems unnecessary, and it is only
used in clangd.

This patch removes it and use the real one (suppression diagnostics are
discarded in clangd at the moment).

Fixes https://github.com/clangd/clangd/issues/929

Differential Revision: https://reviews.llvm.org/D113999
2021-11-17 15:31:38 +01:00
Christian Kühnel 75a078455f [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h
The file follows the LSP syntax, so we're intentially deviating
from the LLVM coding standard.

Differential Revision: https://reviews.llvm.org/D113889
2021-11-16 15:25:43 +00:00
Christian Kühnel 274f12a44c [NFC][clangd] fix llvm-namespace-comment finding
Fixing the clang-tidy finding.

Differential Revision: https://reviews.llvm.org/D113895
2021-11-16 15:10:32 +00:00
Christian Kühnel d2da1a2f40 [NFC][clangd] cleaning up unused "using"
Cleaning up unused "using" declarations.
This patch was generated from automatically applyning clang-tidy fixes.

Differential Revision: https://reviews.llvm.org/D113891
2021-11-16 13:09:49 +00:00
Fabian Wolff 738e7f1231 Fix false positive in `bugprone-throw-keyword-missing` check
Fixes PR#52400. The tests for bugprone-throw-keyword-missing actually
already contain exceptions as class members, but not as members with
initializers, which was probably just an oversight.
2021-11-16 07:09:17 -05:00
Carlos Galvez 9699c0fea3 [clang-tidy][NFC] Simplify ClangTidyStats
- Use NSDMI and remove constructor.

Differential Revision: https://reviews.llvm.org/D113847
2021-11-16 07:36:05 +00:00
Matheus Izvekov c9e46219f3
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110216
2021-11-15 23:07:45 +01:00
Kirstóf Umann d896c9f40a Fix an unused variable warning 2021-11-15 15:45:43 +01:00
Kristóf Umann 29a8d45c5a [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators
modernize-loop-convert checks and fixes when a loop that iterates over the
elements of a container can be rewritten from a for(...; ...; ...) style into
the "new" C++11 for-range format. For that, it needs to parse the elements of
that loop, like its init-statement, such as ItType it = cont.begin().
modernize-loop-convert checks whether the loop variable is initialized by a
begin() member function.

When an iterator is initialized with a conversion operator (e.g. for
(const_iterator it = non_const_container.begin(); ...), attempts to retrieve the
name of the initializer expression resulted in an assert, as conversion
operators don't have a valid IdentifierInfo.

I fixed this by making digThroughConstructors dig through conversion operators
as well.

Differential Revision: https://reviews.llvm.org/D113201
2021-11-15 13:11:29 +01:00
Fabian Wolff c3e3c76209 [clang-tidy] Fix `bugprone-use-after-move` check to also consider moves in constructor initializers
Fixes PR#38187. Constructors are actually already checked,
but only as functions, i.e. the check only looks at the
constructor body and not at the initializers, which misses
the (common) case where constructor parameters are moved
as part of an initializer expression.

One remaining false negative is when both the move //and//
the use-after-move occur in constructor initializers.
This is a lot more difficult to handle, though, because
the `bugprone-use-after-move` check is currently based on
a CFG that only takes the body into account, not the
initializers, so e.g. initialization order would have to
manually be considered. I will file a follow-up issue for
this once PR#38187 is closed.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D113708
2021-11-15 07:41:35 +00:00
Shao-Ce SUN 0c660256eb [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
Matheus Izvekov 6438a52df1
Revert "[clang] retain type sugar in auto / template argument deduction"
This reverts commit 4d8fff477e.
2021-11-15 00:29:05 +01:00
Sam McCall 8ac9d2ae58 [clangd] Fix function-arg-placeholder suppression with macros.
While here, unhide function-arg-placeholders flag. It's reasonable to want and
maybe we should consider making it default.

Fixes https://github.com/clangd/clangd/issues/922

Differential Revision: https://reviews.llvm.org/D113765
2021-11-13 20:50:51 +01:00
Matheus Izvekov 4d8fff477e
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110216
2021-11-13 03:35:22 +01:00
Sam McCall 4fb62e1383 [clangd] Mark completions as plain-text when there's no snippet part
This helps nvim support the "repeat" action

Fixes https://github.com/clangd/clangd/issues/922
2021-11-12 18:44:20 +01:00
Kadir Cetinkaya ebda5e1e52
[clangd] Fix use-after-free in test 2021-11-12 14:50:23 +01:00
Kadir Cetinkaya 7d668ae38d
[clangd] Mark macros from preamble for code completion
If the main file is a header, mark the marcos defined in its preamble
section as code-completion ready.

Fixes https://github.com/clangd/clangd/issues/921.

Differential Revision: https://reviews.llvm.org/D113555
2021-11-12 14:01:14 +01:00
Adrian Kuegel 1d7fdbbc18 Revert "[clang] retain type sugar in auto / template argument deduction"
This reverts commit 9b6036deed.
Breaks two libc++ tests.
2021-11-12 13:21:59 +01:00
Salman Javed 9089a1dff0 [clang-tidy] Re-apply 0076957 with fix for failing ASan tests
Re-apply "Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
with fixes for the failing ASan tests.

This reverts commit 74add1b6d6.
2021-11-13 00:01:12 +13:00
Salman Javed 379935e5a4 Re-land commit 735e433 after fixing buildbot issue
This reverts commit d73e27d.
2021-11-12 22:59:50 +13:00
Salman Javed d73e27d91f Revert "Make minor fixes to docs based on post-commit review of commit 5de69e1"
Sphinx buildbot failing.
This reverts commit 735e4332e2.
2021-11-12 22:42:38 +13:00
Salman Javed 735e4332e2 Make minor fixes to docs based on post-commit review of commit 5de69e1
- Jaro–Winkler and Sørensen–Dice should use en-dashes not regular
  dashes. In reStructuredText this is typed as `--`.
- Letters at the beginning of a sentence should be capitalized.
2021-11-12 22:39:16 +13:00
Matheus Izvekov 9b6036deed
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110216
2021-11-12 01:16:31 +01:00
Aaron Ballman ac8c813b89 Fix Sphinx build diagnostics
This won't parse as either C or C++ according to Sphinx, so switched to
text to appease Sphinx.
2021-11-11 14:38:11 -05:00
Adrian Vogelsgesang 8188484daa [clang-apply-replacements] Correctly handle relative paths
The fixes from the YAML file can refer to relative paths.
Those relative paths are meant to be resolved relative to the
corresponding `build directory`.
However, `clang-apply-replacements` currently interprets all
paths relative to its own working directory. This causes issues,
e.g., when `clang-apply-replacements` is run from outside of
the original build directory.

This commit adjusts `clang-apply-replacements` to take the build
directory into account when resolving relative file paths.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D112647
2021-11-11 18:28:43 +00:00
serge-sans-paille 26d195d8b3 Replace include by forward declaration in test case
This should fix the remaining buildbot issue for the misleading identifier
detection pass.

Differential Revision: https://reviews.llvm.org/D112914
2021-11-10 20:34:05 +01:00
Adam Czachorowski 7a2b1bdb4c [clang] Do not crash in APValue::prettyPrint() on forward-decl structs.
The call to getTypeSizeInChars() is replaced with
getTypeSizeInCharsIfKnown(), which does not crash on forward declared
structs. This only affects printing.

Differential Revision: https://reviews.llvm.org/D113570
2021-11-10 17:17:00 +01:00
Whisperity 164ee457a0 [NFC][clang-tidy] Fixup documentation file names for 'readability-container-data-pointer' 2021-11-10 10:25:54 +01:00
serge-sans-paille a35efc4dcb Misleading unicode identifier detection pass
Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

Example of misleading source:

    short int א = (short int)0;
    short int ג = (short int)12345;

    int main() {
      int א = ג; // a local variable, set to zero?
      printf("ג is %d\n", ג);
      printf("א is %d\n", א);
    }

This is a recommit of 299aa4dfa1 with missing
option registration fixed.

Differential Revision: https://reviews.llvm.org/D112914
2021-11-10 10:21:27 +01:00
Sam McCall 63667c1896 [clangd] Trace per-token time in clangd --check 2021-11-10 08:22:48 +01:00
Salman Javed b4f6f1c936 [clang-tidy] Fix llvm-header-guard so that it works with Windows paths
Fixes pr40372 (https://bugs.llvm.org/show_bug.cgi?id=40372).

The llvm-header-guard check does not take into account that the path
separator on Windows is `\`, not `/`.

This means that instead of suggesting a header guard in the form of:
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FOO_H

it incorrectly suggests:
C:\LLVM_PROJECT\CLANG_TOOLS_EXTRA\CLANG_TIDY\FOO_H

Differential Revision: https://reviews.llvm.org/D113450
2021-11-10 18:35:57 +13:00
serge-sans-paille c178ada3c3 Revert "Misleading unicode identifier detection pass"
This reverts commit 7f92a1a84b.

It triggers an assert, see http://45.33.8.238/linux/60293/step_9.txt

"AST/Decl.h:277: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed."
2021-11-09 22:40:18 +01:00
serge-sans-paille 7f92a1a84b Misleading unicode identifier detection pass
Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

This is a recommit of 299aa4dfa1 with missing
option registration fixed.

Differential Revision: https://reviews.llvm.org/D112914
2021-11-09 21:46:35 +01:00
Jorge Gorbe Moya 74add1b6d6 Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
The change causes multiple clang-tidy tests to fail under ASan.

This reverts commit 0076957202.
2021-11-09 11:28:48 -08:00
Simon Pilgrim 5338629333 Revert rG299aa4dfa1d8c120648b1404b481d858b76c8173 "Misleading unicode identifier detection pass"
This is failing on various buildbots: https://lab.llvm.org/buildbot/#/builders/109/builds/25932
2021-11-09 18:25:55 +00:00
serge-sans-paille 299aa4dfa1 Misleading unicode identifier detection pass
Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

Differential Revision: https://reviews.llvm.org/D112914
2021-11-09 16:01:28 +01:00
Salman Javed 0076957202 [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)
Calling clang-tidy on ClangTidyDiagnosticConsumer.cpp gives a
"unmatched NOLINTBEGIN without a subsequent NOLINTEND" warning.

The "NOLINTBEGIN" and "NOLINTEND" string literals used in the
implementation of `createNolintError()` get mistaken for actual
NOLINTBEGIN/END comments used to suppress clang-tidy warnings.

Rewrite the string literals so that they can no longer be mistaken for
actual suppression comments.

Differential Revision: https://reviews.llvm.org/D113472
2021-11-10 01:09:35 +13:00
Martin Storsjö 98f0bf74ca [clang-move] Fix unit tests with forward slash as separator on windows
Also remove a comment that seems to be left behind.

Differential Revision: https://reviews.llvm.org/D113269
2021-11-08 22:21:31 +02:00
CJ Johnson 16b07c866a [clang-tidy] Add check for initialization of `absl::Cleanup`.
Suggests switching the initialization pattern of `absl::Cleanup` instances from the factory function to class template argument deduction (CTAD) in C++17 and higher.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D113195
2021-11-08 15:57:32 +00:00
Quinn Pham c3b15b71ce [NFC] Inclusive Language: change master to main for .chm files
[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113299
2021-11-08 08:23:04 -06:00
Serikzhan Kazi 0dc856ed20 [clang-tidy] run-clang-tidy.py: analyze unique files only
The files in compile-commands.json can potentially include duplicates.
Change run-clang-tidy.py so that it does not run on the duplicate entries.

Differential Revision: https://reviews.llvm.org/D112926
2021-11-06 19:53:18 +13:00
Quinn Pham c71fbdd87b [NFC] Inclusive language: Remove instances of master in URLs
[NFC] This patch fixes URLs containing "master". Old URLs were either broken or
redirecting to the new URL.

Reviewed By: #libc, ldionne, mehdi_amini

Differential Revision: https://reviews.llvm.org/D113186
2021-11-05 08:48:41 -05:00
Vitaly Buka 6c6ccc72a6 [NFC] Don't set rlimit in test with MSAN 2021-11-04 18:18:03 -07:00
Adam Czachorowski 97fbc975fa [clangd] Find definition of ClassTemplate without going through index.
I noticed that, while go-to-def works on cases like:

namespace ns {
  template<typename T> struct Foo {};
}
using ::ns::Fo^o;

it only works because of the FileIndex. We can get definition location
directly from AST too.

Differential Revision: https://reviews.llvm.org/D113029
2021-11-04 15:25:21 +01:00
Chuanqi Xu ec117158a3 [Coroutines] [Frontend] Lookup in std namespace first
Now in libcxx and clang, all the coroutine components are defined in
std::experimental namespace.
And now the coroutine TS is merged into C++20. So in the working draft
like N4892, we could find the coroutine components is defined in std
namespace instead of std::experimental namespace.
And the coroutine support in clang seems to be relatively stable. So I
think it may be suitable to move the coroutine component into the
experiment namespace now.

This patch would make clang lookup coroutine_traits in std namespace
first. For the compatibility consideration, clang would lookup in
std::experimental namespace if it can't find definitions in std
namespace. So the existing codes wouldn't be break after update
compiler.

And in case the compiler found std::coroutine_traits and
std::experimental::coroutine_traits at the same time, it would emit an
error for it.

The support for looking up std::experimental::coroutine_traits would be
removed in Clang16.

Reviewed By: lxfind, Quuxplusone

Differential Revision: https://reviews.llvm.org/D108696
2021-11-04 11:53:47 +08:00
Sam McCall 6a5e08cc4a [AST] injected-class-name is not a redecl, even in template specializations
Back in the mists of time, the CXXRecordDecl for the injected-class-name was
a redecl of the outer class itself.
This got changed in 470c454a61, but only for plain
classes: class template instantation was still detecting the injected-class-name
in the template body and marking its instantiation as a redecl.

This causes some subtle inconsistent behavior between the two, e.g.
hasDefinition() returns true for Foo<int>::Foo but false for Bar::Bar.
This is the root cause of PR51912.

Differential Revision: https://reviews.llvm.org/D112765
2021-11-02 14:37:45 +01:00
Balázs Kéri 4bcbb3d4d7 [clang-tidy] Add check 'cert-err33-c'.
The CERT rule ERR33-C can be modeled partially by the existing check
'bugprone-unused-return-value'. The existing check is reused with
a fixed set of checked functions.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D112409
2021-11-02 11:38:47 +01:00
Salman Javed ade0662c51 [clang-tidy] Fix lint warnings in clang-tidy source code (NFC)
Run clang-tidy on all source files under `clang-tools-extra/clang-tidy`
with `-header-filter=clang-tidy.*` and make suggested corrections.

Differential Revision: https://reviews.llvm.org/D112864
2021-11-02 20:14:25 +13:00
Kazu Hirata 4db2e4cebe Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC) 2021-10-30 19:00:19 -07:00
Kazu Hirata 972d4133e9 Use {DenseSet,SmallPtrSet}::contains (NFC) 2021-10-29 20:26:07 -07:00
Kirill Bobyrev f47564ea87
[clangd] IncludeCleaner: Skip non self-contained headers
Headers without include guards might have side effects or can be the files we
don't want to consider (e.g. tablegen ".inc" files). Skip them when translating
headers to the HeaderIDs that we will consider as unused.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D112695
2021-10-29 17:57:31 +02:00
Kirill Bobyrev 32f1029124
[clangd] Track performance of IncludeCleaner
Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D112783
2021-10-29 12:59:22 +02:00
Clement Courbet fc1b24d736 [clang-tidy]performance-unnecessary-copy-initialization: fix false negative
We're missing all cases where the return value is a type alias.

Unfortunately, this includes things we care about, such as
`std::vector<T>::operator[]` (return value is `const_reference`,
not `const T&`).

Match the canonical type instead.

Differential Revision: https://reviews.llvm.org/D112722
2021-10-29 08:41:03 +02:00
Kadir Cetinkaya 3d735480bd
[clangd] SelectionTree should prefer lexical declcontext
This is important especially for code that tries to traverse scopes as
written in code, which is the contract SelectionTree tries to satisfy.

Differential Revision: https://reviews.llvm.org/D112712
2021-10-28 17:39:35 +02:00
Kadir Cetinkaya fbf1745722
[clangd] Escape error message in AddUsing
Fixes https://github.com/clangd/clangd/issues/900
2021-10-28 14:52:12 +02:00
Kirill Bobyrev f9201c70ad
[clangd] NFC: Use more idiomatic way of checking for definition 2021-10-28 12:25:12 +02:00
Kirill Bobyrev 56a8aee100 [clangd] NFC: Match function signature in the header and source file 2021-10-28 12:13:18 +02:00
Sam McCall 73453e7ade [clangd] Avoid expensive checks of buffer names in IncludeCleaner
This changes the handling of special buffers (<command-line> etc) that
SourceManager treats as files but FileManager does not.

We now include them in findReferencedFiles() and drop them as part of
translateToHeaderIDs(). This pairs more naturally with the data representations
we're using, and so avoids a bunch of converting between representations for
filtering.

Differential Revision: https://reviews.llvm.org/D112652
2021-10-28 08:00:57 +02:00
Kirill Bobyrev 22079c61a8
[clangd] IncludeCleaner: Do not process locations in built-in files
Doing otherwise leads to crashing. Way to reproduce: open "gmock/gmock.h" in
the LLVM source tree.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D112608
2021-10-27 19:31:43 +02:00
Kirill Bobyrev 6edc509719 [clangd] NFC: Remove single-line braces in IncludeCleaner 2021-10-27 13:53:30 +02:00
Sam McCall 9cc08cb02f [clangd] Add integration test for crash handling
This replaces the test removed in 51be7061d0
It is more principled and tests more critical cases: a crash while parsing.

We need two pieces of plumbing:
 - a way to re-enable the crashing #pragmas via a flag, to test parse crashes
 - a bit of reshuffling around ASTWorker execution so that we set up the
   crash handler in both sync/async modes.
   Sync mode is useful for debugging, so I tested both.

Differential Revision: https://reviews.llvm.org/D112565
2021-10-27 11:52:31 +02:00
Kirill Bobyrev c4723785c1 [clangd] IncludeCleaner: Don't warn on system headers
This is a temporary hack to disable diagnostics for system headers. As of right
now, IncludeCleaner does not handle the Standard Library correctly and will
report most system headers as unused because very few symbols are defined in
top-level system headers. This will eventually be fixed, but for now we are
aiming for the most conservative approach with as little false-positive
warnings as possible. After the initial prototype and core functionality is
polished, I will turn back to handling the Standard Library as it requires
custom logic.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D112571
2021-10-27 11:51:08 +02:00
Salman Javed 897402e959 [clang-tidy] Correct typo in bugprone-easily-swappable-parameters
The string table `DefaultIgnoredParameterTypeSuffixes` has a typo:
`ForwardIt` is mistyped as `FowardIt`.

Correct typo and add test coverage.

Differential Revision: https://reviews.llvm.org/D112596
2021-10-27 22:38:52 +13:00
Kirill Bobyrev e3c6090e59 [clangd] IncludeCleaner: Support macros
Collect the macro definition locations for all the macros used in the main
file.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D112447
2021-10-27 10:30:04 +02:00
Kadir Cetinkaya e42f5d4b48
[clangd] Fix filename ranges while replaying preamble
Clangd used first token of filename as filename range rather than the
synthezied filename token. Unfortunately the former only contains `"` or `<` in
the raw lexing mode, resulting in wrong range information and breaking tidy
checks that relied on it.

Fixes https://github.com/clangd/clangd/issues/896.

Differential Revision: https://reviews.llvm.org/D112559
2021-10-27 09:34:17 +02:00
Adam Czachorowski 2174524116 [clangd] AddUsing: Fix support for template specializations.
Before this change, we would add "using std::vector<int>" instead of
just "using std::vector;", which would not even compile.

Fixes https://github.com/clangd/clangd/issues/904

Differential Revision: https://reviews.llvm.org/D112530
2021-10-26 17:32:33 +02:00
Adam Czachorowski e8f4a01189 [clangd] Fix a hover crash on templated spaceship operator.
We make assumption that:
getDeclForComment(getDeclForComment(X)) == getDeclForComment(X)
but this is not true if you have a template
instantionation of a template instantiation, which is the case when, for
example, you have a <=> operator in a templated class.

This fix makes getDeclForComment() call itself recursively to ensure
this property is always true.

Fixes https://github.com/clangd/clangd/issues/901

Differential Revision: https://reviews.llvm.org/D112527
2021-10-26 17:28:40 +02:00
Kirill Bobyrev 1c2e249f93
[clangd] IncludeCleaner: don't stop the traversal
I was under the impression that `return false;` in the
RecursiveASTVisitor stops the traversal for the subtree but it appears
that it stops the whole tree traversal, so this change introduces a bug
where `ReferencedLocationCrawler` will not collect any symbols past an
enum.

This is a follow-up on D112209.
2021-10-26 16:08:54 +02:00
Sam McCall 51be7061d0 [clangd] Remove tricky integration test that flakes/fails on some platforms.
This functionality is covered by unittests, will add a better
integration test soon.
2021-10-26 14:19:05 +02:00
Kirill Bobyrev 6d314ee570
[clangd] Add a way to enable IncludeCleaner through config
This is useful for dogfooding the feature and spotting bugs.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D111870
2021-10-26 12:53:05 +02:00
Kirill Bobyrev c521288ed3
[clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations
Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D111711
2021-10-26 10:37:10 +02:00
Carlos Galvez b43a2aee4e [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables
clang-tidy can be used to statically analyze CUDA code,
thanks to clang being able to compile CUDA code natively.
This makes clang-tidy the one and only open-source
static analyzer for CUDA.

However it currently warns for native CUDA built-in
variables, like threadIdx, due to the way they
are implemented in clang.

Users don't need to know the details of the clang
implementation, and they should continue to write
idiomatic code. Therefore, suppress the warning
if a CUDA built-in variable is encountered.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48758
2021-10-26 05:45:25 +00:00
Shoaib Meenai ba94b8bdff [clangd] Attempt to fix buildbots
http://45.33.8.238/win/47615/step_4.txt is a sample error; I believe it
just needs the right header to be included.
2021-10-25 20:16:59 -07:00
Sam McCall aa1ac2ae45 [clangd] Flush stderr after signal handlers run, so we always get the full stack/crash info 2021-10-26 01:08:36 +02:00
Emma Blink 045695f85c [clangd] Print current request context along with the stack trace
Motivation:

At the moment it is hard to attribute a clangd crash to a specific request out of all in-flight requests that might be processed concurrently. So before we can act on production clangd crashes, we have to do quite some digging through the log tables populated by our in-house VSCode extension or sometimes even directly reach out to the affected developer. Having all the details needed to reproduce a crash printed alongside its stack trace has a potential to save us quite some time, that could better be spent on fixing the actual problems.

Implementation approach:

* introduce `ThreadCrashReporter` class that allows to set a temporary signal handler for the current thread
* follow RAII pattern to simplify printing context for crashes occurring within a particular scope
* hold `std::function` as a handler to allow capturing context to print
* set local `ThreadCrashReporter` within `JSONTransport::loop()` to print request JSON for main thread crashes, and in `ASTWorker::run()` to print the file paths, arguments and contents for worker thread crashes

`ThreadCrashReporter` currently allows only one active handler per thread, but the approach can be extended to support stacked handlers printing context incrementally.

Example output for main thread crashes:

  ```
  ...
  #15 0x00007f7ddc819493 __libc_start_main (/lib64/libc.so.6+0x23493)
  #16 0x000000000249775e _start (/home/emmablink/local/llvm-project/build/bin/clangd+0x249775e)
  Signalled while processing message:
  {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///home/emmablink/test.cpp", "languageId": "cpp", "version": 1, "text": "template <typename>\nclass Bar {\n  Bar<int> *variables_to_modify;\n  foo() {\n    for (auto *c : *variables_to_modify)\n      delete c;\n  }\n};\n"}}}
  ```

Example output for AST worker crashes:

  ```
  ...
  #41 0x00007fb18304c14a start_thread pthread_create.c:0:0
  #42 0x00007fb181bfcdc3 clone (/lib64/libc.so.6+0xfcdc3)
  Signalled during AST action:
  Filename: test.cpp
  Directory: /home/emmablink
  Command Line: /usr/bin/clang -resource-dir=/data/users/emmablink/llvm-project/build/lib/clang/14.0.0 -- /home/emmablink/test.cpp
  Version: 1
  Contents:
  template <typename>
  class Bar {
    Bar<int> *variables_to_modify;
    foo() {
      for (auto *c : *variables_to_modify)
        delete c;
    }
  };
  ```

Testing:

The unit test covers the thread-localitity and nesting aspects of `ThreadCrashReporter`. There might be way to set up a lit-based integration test that would spawn clangd, send a message to it, signal it immediately and check the standard output, but this might be prone to raceconditions.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D109506
2021-10-26 00:58:09 +02:00
Nathan Ridge e6a971b1ba [clangd] Respect diagnostic suppression during preamble build
Fixes https://github.com/clangd/clangd/issues/906

Differential Revision: https://reviews.llvm.org/D112403
2021-10-25 17:39:32 -04:00
Kirill Bobyrev 593814a10c [clangd] IncludeCleaner: Complicated rules for enum usage
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D112209
2021-10-25 22:04:22 +02:00
Kadir Cetinkaya 9ab9caf214
[clang] Visit enum base specifiers in libIndex
Fixes https://github.com/clangd/clangd/issues/878.

Differential Revision: https://reviews.llvm.org/D111260
2021-10-25 13:16:14 +02:00
Kadir Cetinkaya 4e4511df8d
[clang] Traverse enum base specifier in RAV 2021-10-25 13:16:14 +02:00
Kazu Hirata 4ba9d9c84f Use StringRef::contains (NFC) 2021-10-23 20:41:46 -07:00
Kazu Hirata d8e4170b0a Ensure newlines at the end of files (NFC) 2021-10-23 08:45:29 -07:00
Salman Javed 5de69e16ea [clang-tidy] Tidy up spelling, grammar, and inconsistencies in documentation (NFC)
Differential Revision: https://reviews.llvm.org/D112356
2021-10-23 00:07:36 -07:00
David Blaikie aee4925507 Recommit: Compress formatting of array type names (int [4] -> int[4])
Based on post-commit review discussion on
2bd8493847 with Richard Smith.

Other uses of forcing HasEmptyPlaceHolder to false seem OK to me -
they're all around pointer/reference types where the pointer/reference
token will appear at the rightmost side of the left side of the type
name, so they make nested types (eg: the "int" in "int *") behave as
though there is a non-empty placeholder (because the "*" is essentially
the placeholder as far as the "int" is concerned).

This was originally committed in 277623f4d5

Reverted in f9ad1d1c77 due to breakages
outside of clang - lldb seems to have some strange/strong dependence on
"char [N]" versus "char[N]" when printing strings (not due to that name
appearing in DWARF, but probably due to using clang to stringify type
names) that'll need to be addressed, plus a few other odds and ends in
other subprojects (clang-tools-extra, compiler-rt, etc).
2021-10-21 11:34:43 -07:00
Kadir Cetinkaya 60e19f6752
[clangd] Fix use-after-free in HeaderIncluderCache
Includer cache could get into a bad state when a main file went bad and
added back afterwards. This patch adds a check to invalidate to prevent
that.

Differential Revision: https://reviews.llvm.org/D112130
2021-10-20 16:36:07 +02:00
Kadir Cetinkaya c959da9ef3
[clangd] Only publish preamble after rebuilds
Don't invoke parsing callback for preamble if clangd is using a
previously built one.

Differential Revision: https://reviews.llvm.org/D112137
2021-10-20 16:32:32 +02:00
Carlos Galvez 7812cb72a3 Use reference type in for loop
To fix failing build job.
2021-10-19 16:37:56 +00:00
Carlos Galvez bf6b0d1674 [clang-tidy] Support globbing in NOLINT* expressions
To simplify suppressing warnings (for example, for
when multiple check aliases are enabled).

The globbing format reuses the same code as for
globbing when enabling checks, so the semantics
and behavior is identical.

Differential Revision: https://reviews.llvm.org/D111208
2021-10-19 16:30:51 +00:00
Adam Czachorowski 8fbac4e88a [clangd] Add code completion of param name on /* inside function calls.
For example, if you have:
  void foo(int bar);
  foo(/*^
it should auto-complete to "bar=".

Because Sema callbacks for code completion in comments happen before we
have an AST we need to cheat in clangd by detecting completion on /*
before, moving cursor back by two characters, then running a simplified
verion of SignatureHelp to extract argument name(s) from possible
overloads.

Differential Revision: https://reviews.llvm.org/D110823
2021-10-19 12:49:46 +02:00
Carlos Galvez f0711106dc [clang-tidy] Fix false positive in cppcoreguidelines-virtual-class-destructor
Incorrectly triggers for template classes that inherit
from a base class that has virtual destructor.

Any class inheriting from a base that has a virtual destructor
will have their destructor also virtual, as per the Standard:

https://timsong-cpp.github.io/cppwp/n4140/class.dtor#9

> If a class has a base class with a virtual destructor,
> its destructor (whether user- or implicitly-declared) is virtual.

Added unit tests to prevent regression.

Fixes bug https://bugs.llvm.org/show_bug.cgi?id=51912

Differential Revision: https://reviews.llvm.org/D110614
2021-10-16 08:27:08 +00:00
Kirill Bobyrev 0ce3c7111e
[clangd] IncludeCleaner: Handle macros coming from ScratchBuffer
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D111698
2021-10-14 13:36:37 +02:00
liuke ea72b55b5c bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader
If the Node has an invalid location, it will trigger assert in
isInSystemHeader(...).

void test() {
  __builtin_va_list __args;
  // __builtin_va_list has no defination in any source file and its
  // CXXConstructorDecl has invalid sourcelocation
}
coredump with "Assertion `Loc.isValid() && "Can't get file
characteristic of invalid loc!"' failed." in
getFileCharacteristic(SourceLocation).
2021-10-13 12:31:02 -04:00
Adam Czachorowski fba563e92b [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args.
Previously we would call getAsTemplate() when kind == TemplateExpansion,
which triggers an assertion. The call is now replaced with
getAsTemplateOrTemplatePattern(), which is exactly the same as
getAsTemplate(), except it allows calls when kind == TemplateExpansion.

No change in behavior for no-assert builds.

Differential Revision: https://reviews.llvm.org/D111648
2021-10-13 13:15:36 +02:00
Balázs Kéri a76cfc2e84 [clang-tidy] Update documentation of check bugprone-unused-return-value [NFC].
The list of checked functions was incomplete in the description.

Reviewed By: aaron.ballman, steakhal

Differential Revision: https://reviews.llvm.org/D111623
2021-10-12 16:43:45 +02:00
Carlos Galvez 40546cb381 Remove 'IgnoreDestructors = true' from cppcoreguidelines-explicit-virtual-functions
This requirement was introduced in the C++ Core guidelines in 2016:

1894380d0a

Then clang-tidy got updated to comply with the rule.

However in 2019 this decision was reverted:

5fdfb20b76

Therefore we need to apply the correct configuration to
clang-tidy again.

This also makes this cppcoreguidelines check consistent
with the other 2 alias checks: hicpp-use-override and
modernize-use-override.

Additionally, add another RUN line to the unit test,
to make sure cppcoreguidelines-explicit-virtual-functions
is tested.
2021-10-12 10:08:08 -04:00
Kirill Bobyrev 6393c21d47 [clangd] IncludeCleaner: Stop crashing when included file is not found 2021-10-08 14:51:11 +02:00
Kirill Bobyrev b1309a1ed9 [clangd] Revert unwanted change from D108194
Left-overs from the review process were not deleted.
2021-10-08 10:42:30 +02:00
Simon Pilgrim b9b90bb542 [clang] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)
As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
2021-10-06 11:43:19 +01:00
Kirill Bobyrev 0c14e279c7
[clangd] Revert unwanted change from D108194 2021-10-05 18:44:43 +02:00
Matt Beardsley 32ab79ebc4 [clang-tidy] Fix add_new_check.py to generate correct list.rst autofix column from relative path
Previously, the code in add_new_check.py that looks for fixit keywords in check source files when generating list.rst assumed that the script would only be called from its own path. That means it doesn't find any source files for the checks it's attempting to scan for, and it defaults to writing out nothing in the "Offers fixes" column for all checks. Other parts of add_new_check.py work from other paths, just not this part.

After this fix, add_new_check.py's "offers fixes" column generation for list.rst will be consistent regardless of what path it's called from by using the caller path that's deduced elsewhere already from sys.argv[0].

Reviewed By: kbobyrev

Differential Revision: https://reviews.llvm.org/D110600
2021-10-05 18:09:53 +02:00
Kirill Bobyrev ebfcd06d42 [clangd] IncludeCleaner: Mark used headers
Follow-up on D105426.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D108194
2021-10-05 18:08:24 +02:00
Utkarsh Saxena 6831c1d868 [clangd] Include refs of base method in refs for derived method.
Addresses https://github.com/clangd/clangd/issues/881

Includes refs of base class method in refs of derived class method.
Previously we reported base class method's refs only for decl of derived
class method. Ideally this should work for all usages of derived class method.

Related patch:
fbeff2ec2b.

Differential Revision: https://reviews.llvm.org/D111039
2021-10-05 17:39:49 +02:00
David Goldman a90d57b6cc [clangd] Improve PopulateSwitch tweak
- Support enums in C and ObjC as their
  AST representations differ slightly.

- Add support for typedef'ed enums.

Differential Revision: https://reviews.llvm.org/D110954
2021-10-04 10:15:37 -04:00
Jay Foad d933adeaca [APInt] Stop using soft-deprecated constructors and methods in clang. NFC.
Stop using APInt constructors and methods that were soft-deprecated in
D109483. This fixes all the uses I found in clang.

Differential Revision: https://reviews.llvm.org/D110808
2021-10-04 09:38:11 +01:00
Kirill Bobyrev b06df22382
[clangd] Follow-up on rGdea48079b90d
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D110925
2021-10-04 08:39:24 +02:00
Kadir Cetinkaya 512aa84850
[clangd] Handle members of anon structs in SelectionTree
References to fields inside anon structs contain an implicit children
for the container, which has the same SourceLocation with the field.
This was resulting in SelectionTree always picking the anon-struct rather than
the field as the selection.

This patch prevents that by claiming the range for the field early.

https://github.com/clangd/clangd/issues/877.

Differential Revision: https://reviews.llvm.org/D110825
2021-10-01 12:38:18 +02:00
Kirill Bobyrev 38ec2292f0
[clangd] Update comment after dea48079b9 2021-09-30 16:45:10 +02:00
Kirill Bobyrev dea48079b9
[clangd] Land D110386 again
This time, use llvm::sys::fs::UniqueID instead of unstable
FileEntry::getName(), this should solve the problems on Windows and
elsewhere.
2021-09-30 14:41:27 +02:00
Kirill Bobyrev 230a6edb49 Revert "[clangd] Reland D110386"
This reverts commits

- dd13f45e04
- d084c42bdf
- 87817bc523
2021-09-30 11:37:07 +02:00
Kirill Bobyrev 87817bc523 Fix the build after d084c42bdf 2021-09-30 09:53:04 +02:00
Kirill Bobyrev d084c42bdf Investigate failure in rGdd13f45e04366cc4f648b57ec87d20a5569e27c3
https://lab.llvm.org/buildbot/#/builders/123/builds/6406/steps/8/logs/stdio
2021-09-30 09:50:14 +02:00
Kirill Bobyrev dd13f45e04
[clangd] Reland D110386
D110711 will fix the bug on Windows side and allows me to reland this
patch.

Also land e50771181b on top of it.
2021-09-30 08:25:31 +02:00