Commit Graph

6267 Commits

Author SHA1 Message Date
njames93 7fc533a1d8 [clangd] Fix windows builds failing on check-clangd 2020-06-14 13:29:17 +01:00
Sam McCall 4160f4c376 Reland [clangd] Parse std::make_unique, and emit template diagnostics at expansion.
This was originally 658af94350 and reverted in 665dbe91f2.
The clang bug this triggered was fixed in 05ed3efc2a.
2020-06-12 16:18:26 +02:00
Haojian Wu 58ea1059df [AST][RecoveryExpr] Build recovery expressions by default for C++.
Reland https://reviews.llvm.org/D76696
All known crashes have been fixed, another attemption.

We have rolled out this to all internal users for a while, didn't see
big issues, we consider it is stable enough.

Reviewed By: sammccall

Subscribers: rsmith, hubert.reinterpretcast, ebevhan, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78350
2020-06-12 15:21:38 +02:00
Kadir Cetinkaya f44d2424f8
[clangd] Set CWD in semaCodeComplete
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81691
2020-06-11 23:35:47 +02:00
Sam McCall 4e3a44d42e [clangd] Disable new errs()-tie behavior, it's racy.
Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81538
2020-06-10 16:08:37 +02:00
Sam McCall f2c8f6e16d [clangd] Log rather than assert on bad UTF-8.
Summary:
I don't love this behavior, but it prevents crashing when indexing boost
headers, and I can't think of a better practical alternative.

Fixes https://reviews.llvm.org/D81530

Based on a patch by AnakinZheng!

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits, AnakinZheng

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81530
2020-06-10 11:40:23 +02:00
Sam McCall 2a3ac01b68 Reland [clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.
This reverts commit f25e3c2d0e.
Added workaround for tempdir being a symlink on mac.
2020-06-09 23:07:28 +02:00
Tridacnid ce5fecb7d0 Assignment and Inc/Dec operators wouldn't register as a mutation when Implicit Paren Casts were present
Add ignoringParenImpCasts to assignment and inc/dec mutation checks in ExprMutationAnalyzer to fix clang-tidy bug PR45490.
https://bugs.llvm.org/show_bug.cgi?id=45490

Reviewed By: njames93, aaron.ballman, gribozavr2

Differential Revision: https://reviews.llvm.org/D79912
2020-06-09 19:45:57 +01:00
Kadir Cetinkaya 406ac49fb0
[clangd][NFC] Explode ReceivedPreamble into a CV
Summary:
Instead of a notification, we make use of a CV and store the boolean on
LatestPreamble by converting it into an optional.

Depends on D80293.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80784
2020-06-09 17:54:32 +02:00
Sam McCall 665dbe91f2 Revert "[clangd] Parse std::make_unique, and emit template diagnostics at expansion."
This reverts commit 658af94350.
Breaks tests on windows: http://45.33.8.238/win/17229/step_9.txt

I think this is uncovering a latent bug when a late-parsed preamble is
used with an eagerly-parsed file.
2020-06-09 15:42:22 +02:00
Kirill Bobyrev 348364bffd
[clangd] Don't produce snippets when completion location is followed by parenthesis
Summary:
Prevent a second pair of parenthesis from being added when there already is one
right after cursor.

Related issue and more context: https://github.com/clangd/clangd/issues/387

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81380
2020-06-09 13:59:29 +02:00
Sam McCall 658af94350 [clangd] Parse std::make_unique, and emit template diagnostics at expansion.
Summary:
Parsing std::make_unique is an exception to the usual non-parsing of function
bodies in the preamble. (A hook is added to PreambleCallbacks to allow this).
This allows us to diagnose make_unique<Foo>(wrong arg list), and opens the door
to providing signature help (by detecting where the arg list is forwarded to).
This function is trivial (checked libc++ and libstdc++) and doesn't result in
any extra templates being instantiated, so this should be cheap.

This uncovered a second issue (already visible with class templates)...

Errors produced by template instantiation have primary locations within the
template, with instantiation stack reported as notes.
For templates defined in headers, these end up reported at the #include
directive, which isn't terribly helpful as the header itself is probably fine.
This patch reports them at the instantiation site (the first location in the
instantiation stack that's in the main file). This in turn required a bit of
refactoring in Diagnostics so we can delay relocating the diagnostic until all
notes are available.

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

Reviewers: hokein, aaron.ballman

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81351
2020-06-09 12:47:27 +02:00
Nico Weber f25e3c2d0e Revert "[clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH."
This reverts commit 806342b8ef.
Breaks check-clangd on macOS, https://reviews.llvm.org/D75414#2080076
2020-06-08 15:20:16 -04:00
Kadir Cetinkaya d26721776f
[clangd] Drop unnecessary FS modifications in FindSymbolsTests 2020-06-08 18:36:18 +02:00
Sam McCall 806342b8ef [clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.
Summary:
This fixes a reported bug: if clang and libc++ are installed under
/usr/lib/llvm-11/...  but there'- a symlink /usr/bin/clang++-11, then a
compile_commands.json with "/usr/bin/clang++-11 -stdlib=libc++" would previously
look for libc++ under /usr/include instead of /usr/lib/llvm-11/include.
The PATH change makes this work if the compiler is just "clang++-11" too.

As this is now doing IO potentially on every getCompileCommand(), we cache
the results for each distinct driver.

While here:
- Added a Memoize helper for this as multithreaded caching is a bit noisy.
- Used this helper to simplify QueryDriverDatabase and reduce blocking there.
  (This makes use of the fact that llvm::Regex is now threadsafe)

Reviewers: kadircet

Subscribers: jyknight, ormris, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75414
2020-06-08 17:24:52 +02:00
Sam McCall 615673f3a1 [Preamble] Invalidate preamble when missing headers become present.
Summary:
To avoid excessive extra stat()s, only check the possible locations of
headers that weren't found at all (leading to a compile error).
For headers that *were* found, we don't check for files earlier on the
search path that could override them.

Reviewers: kadircet

Subscribers: javed.absar, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77942
2020-06-08 14:03:08 +02:00
Kadir Cetinkaya f693ce4aa9
[clangd] Change ParseInputs to store FSProvider rather than VFS
Summary: This ensures ParseInputs provides a read-only access to FS.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81173
2020-06-08 13:23:55 +02:00
Zinovy Nis c063b4a72b Fix crash on misc-redundant-expression
Differential Revision: https://reviews.llvm.org/D80896
2020-06-05 18:43:57 +03:00
Haojian Wu a7534dc819 [clangd] Populate the parse options to CodeCompletion/SignatureHelp.
Summary: A followup of D79938.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81066
2020-06-05 10:32:07 +02:00
Nathan James e21c3f223a [clang-tidy] ignore builtin varargs from pro-type-vararg-check
Disables the check from warning on some built in vararg functions, Address [[ https://bugs.llvm.org/show_bug.cgi?id=45860 | Clang-tidy should not consider __builtin_constant_p a variadic function. ]]

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D80887
2020-06-04 17:58:23 +01:00
Zinovy Nis 6271b96bef [clang-tidy][modernize-loop-convert] Make loop var type human readable
Differential Revision: https://reviews.llvm.org/D80536
2020-06-04 19:51:45 +03:00
Kadir Cetinkaya 4f4a8ae72e
[clangd] Fix build for gcc 7.4 2020-06-04 12:02:49 +02:00
Kadir Cetinkaya 49cbe56a65
[clangd] Fix forgotten propagation of AsnycPreamble flag 2020-06-03 23:56:49 +02:00
Konrad Kleine e636e6b79a [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro
Summary:
This check finds macro expansions of `DISALLOW_COPY_AND_ASSIGN(Type)` and
replaces them with a deleted copy constructor and a deleted assignment operator.

Before the `delete` keyword was introduced in C++11 it was common practice to
declare a copy constructor and an assignment operator as a private members. This
effectively makes them unusable to the public API of a class.

With the advent of the `delete` keyword in C++11 we can abandon the
`private` access of the copy constructor and the assignment operator and
delete the methods entirely.

Migration example:

```
lang=dif
class Foo {
  private:
  -  DISALLOW_COPY_AND_ASSIGN(Foo);
  +  Foo(const Foo &) = delete;
  +  const Foo &operator=(const Foo &) = delete;
  };
```

Reviewers: alexfh, hokein, aaron.ballman, njames93

Reviewed By: njames93

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D80531
2020-06-03 16:56:03 -04:00
Nathan James 6780be4c63 second attempt to fix build after add51e1 2020-06-03 15:16:36 +01:00
Martin Boehme a3220dffcb [clangd] Add std::move() to a return statement to please some compilers.
This has been causing build errors in Swift CI.

Differential Revision: https://reviews.llvm.org/D81079
2020-06-03 15:40:01 +02:00
Dmitri Gribenko c1911fcb06 Replaced C++2a with C++20 in clang-tools-extra
Reviewers: hlopko, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: wuzish, aaron.ballman, nemanjai, kbarton, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81087
2020-06-03 14:54:10 +02:00
Nico Weber fd2740143e attempt to fix build after add51e152a 2020-06-03 06:49:50 -04:00
Matthias Gehre add51e152a [clang-tidy] add new check readability-use-anyofallof
Summary:
Finds range-based for loops that can be replaced by a call to ``std::any_of`` or
``std::all_of``. In C++ 20 mode, suggests ``std::ranges::any_of`` or
``std::ranges::all_of``.
For now, no fixits are produced.

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77572
2020-06-03 12:19:06 +02:00
Nathan James 65fa0a9f7f [clang-tidy] Added MacroDefiniton docs for readability-identifier-naming
Updates the docs to include `MacroDefinition` documentation. The docs are still missing `ObjCIVar` however I don't have a clue about how that looks in code. If someone wants to show the code block needed for the example I'll add that in too.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D80877
2020-06-03 09:23:32 +01:00
Kadir Cetinkaya 8506877c87
[clangd] Copy existing includes in ReplayPreamble
Summary:
ReplayPreamble was just grabbing the reference of IncludeStructure
passed to it and then replayed any includes seen so while exiting
built-in file.

This implies any include seen in built-in files being replayed as part
of preamble, even though they are not. This wasn't an issue until we've
started patching preambles, as includes from built-in files were not
mapped back to main-file.

This patch copies over existing includes at the time of
ReplayPreamble::attach and only replies those to prevent any includes
from the preamble patch getting mixed-in.

Reviewers: sammccall, jkorous

Subscribers: ilya-biryukov, MaskRay, dexonsmith, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80988
2020-06-02 14:31:45 +02:00
Kadir Cetinkaya a0f13b3374
Revert "[clangd] Copy existing includes in ReplayPreamble"
This reverts commit bff0c56ff9. I've
pushed the earlier version of the patch by mistake.
2020-06-02 14:31:45 +02:00
Kadir Cetinkaya bff0c56ff9
[clangd] Copy existing includes in ReplayPreamble
ReplayPreamble was just grabbing the reference of IncludeStructure
passed to it and then replayed any includes seen so while exiting
built-in file.

This implies any include seen in built-in files being replayed as part
of preamble, even though they are not. This wasn't an issue until we've
started patching preambles, as includes from built-in files were not
mapped back to main-file.

This patch copies over existing includes at the time of
ReplayPreamble::attach and only replies those to prevent any includes
from the preamble patch getting mixed-in.
2020-06-02 13:34:40 +02:00
Nathan James 5952125691 clang-tidy and clang-query wont crash with invalid command line options
Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]]

Reviewed By: aaron.ballman, thakis

Differential Revision: https://reviews.llvm.org/D80879
2020-05-31 17:41:29 +01:00
Nathan James f4b0ebb89b Revert "clang-tidy and clang-query wont crash with invalid command line options"
This reverts commit f23ddbe3c3.
2020-05-31 16:40:09 +01:00
Nathan James f23ddbe3c3 clang-tidy and clang-query wont crash with invalid command line options
Summary: Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]]

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80879
2020-05-31 16:01:41 +01:00
Nathan James 44119626de [clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros
Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42635 | readability-identifier-naming option MacroDefinitionCase should ignore macros passed as parameters. ]]

Reviewers: aaron.ballman, alexfh, gribozavr2, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80631
2020-05-30 20:49:33 +01:00
Jan Korous 1a5c97f3a4 [ASTMatchers] Matchers related to C++ inheritance
Differential Revision: https://reviews.llvm.org/D79063
2020-05-29 12:38:01 -07:00
Kadir Cetinkaya 20b2af3e55
[clangd][NFC] Add traces for PreamblePatch::create 2020-05-29 14:00:08 +02:00
Kadir Cetinkaya 1f4ba66ecc
[clangd] Run PreambleThread in async mode behind a flag
Summary: Depends on D80198.

This patch implies ASTs might be built with stale preambles without
blocking for a fresh one. It also drops any guarantees on every preamble
version being built. In case of multiple preamble build requests, in
addition to being debounced.

Any preamble requested with a WantDiags::Yes will always be built, this
is ensured by blocking enqueueing of any subsequent reqest.

AST worker will still block for initial preamble to reduce duplicate
work.

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80293
2020-05-29 13:20:46 +02:00
Kadir Cetinkaya 538c2753f3
[clangd] locateMacroAt handles patched macros
Summary: Depends on D79992.

This patch changes locateMacroAt to perform #line directive substitution
for macro identifier locations.

We first check whether a location is inside a file included through
built-in header. If so we check whether line directive maps it back to
the main file, and afterwards use TokenBuffers to find exact location of
the identifier on the line.

Instead of performing the mapping in locateMacroAt, we could also store
a mapping inside the ParsedAST whenever we use a patched preamble. But
that would imply adding more responsibility to ParsedAST and paying for
the mapping even when it is not going to be used.

====

Go-To-Definition:

Later on these locations are used for serving go-to-definition requests,
this enables jumping to definition inside the preamble section in
presence of patched macros.

=====

Go-To-Refs:

Macro references in main file are collected separetely and stored as a
map from macro's symbol id to reference ranges. Those ranges are
computed inside PPCallbacks, hence we don't have access to TokenBuffer.

In presence of preamble patch, any reference to a macro inside the
preamble section will unfortunately have the wrong range. They'll point
into the patch rather than the main file. Hence during findReferences,
we won't get any ranges reported for those.

Fixing those requires:
- Lexing the preamble section to figure out "real range" of a patched
  macro definition
- Postponing range/location calculations until a later step in which we
  have access to tokenbuffers.

This patch trades some accuracy in favor of code complexity. We don't do
any patching for references inside the preamble patch but get any
reference inside the main file for free.

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80198
2020-05-29 12:46:54 +02:00
Kadir Cetinkaya fcde3d5b04
[clangd] Patch PP directives to use stale preambles while building ASTs
Summary:
Depends on D79930.

This enables more accurate parsing of the AST, by making new macro
definitions in preamble section visible. This is handled by injecting
define directives into preamble patch.

This patch doesn't handle any location mappings yet, so features like go-to-def,
go-to-refs and hover might not work as expected. These will be addressed in a
follow-up patch.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79992
2020-05-29 12:46:53 +02:00
Kadir Cetinkaya 1772adb059
[clangd] Preserve extra args in PreambleTests::IncludeParsing to fix windows build bots 2020-05-29 12:35:25 +02:00
Kadir Cetinkaya 478f6fb200
[clangd] Add buildPreamble to TestTU
Summary: Depends on D77644.

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79930
2020-05-29 12:20:23 +02:00
Kadir Cetinkaya b742eaa321
[clangd] Handle additional includes while parsing ASTs
Summary:
Enables building ASTs with stale preambles by handling additional preamble
includes. Sets the correct location information for those imaginary includes so
that features like gotodef/documentlink keeps functioning propoerly.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77644
2020-05-29 12:20:23 +02:00
Yitzhak Mandelbaum a1b88afe46 [clang-tidy] Fix build broken by commit 7cfdff7b4a (D80023) 2020-05-28 13:39:58 -04:00
Tom Lokovic 7cfdff7b4a [clang-tidy] Add abseil-string-find-str-contains checker.
Summary: This adds a checker which suggests replacing string.find(...) == npos with absl::StrContains.

Reviewers: alexfh, hokein, aaron.ballman, njames93, ymandel

Reviewed By: ymandel

Subscribers: ymandel, Eugene.Zelenko, xazax.hun, mgorny, Charusso, phosek, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D80023
2020-05-28 12:35:57 -04:00
Sam McCall 8e325cfc14 [clangd] Work around PS4 -fno-exceptions, easier than disabling tests? 2020-05-28 17:14:23 +02:00
Sam McCall a56141b8f9 [clangd] Highlight related control flow.
Summary:
This means e.g. highlighting "return" will show other returns/throws
from the same function, highlighting a case will show all the
return/breaks etc.

This is a bit of an abuse of textDocument/highlight, but seems useful.

Reviewers: adamcz

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78454
2020-05-28 13:25:11 +02:00
Daniel Martín 6407aa9d2e
[clangd] Add access specifier information to hover contents
Summary:
For https://github.com/clangd/clangd/issues/382

This commit adds access specifier information to the hover
contents. For example, the hover information of a class field or
member function will now indicate if the field or member is private,
public, or protected. This can be particularly useful when a developer
is in the implementation file and wants to know if a particular member
definition is public or private.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80472
2020-05-27 19:36:46 +02:00
Sam McCall 1abb883a04 [clangd] Don't traverse the AST within uninteresting files during indexing
Summary:
We already skip function bodies from these files while parsing, and drop symbols
found in them. However, traversing their ASTs still takes a substantial amount
of time.

Non-scientific benchmark on my machine:
  background-indexing llvm-project (llvm+clang+clang-tools-extra), wall time
  before: 7:46
  after: 5:13
  change: -33%

Indexer.cpp libclang should be updated too, I'm less familiar with that code,
and it's doing tricky things with the ShouldSkipFunctionBody callback, so it
needs to be done separately.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80296
2020-05-26 10:27:28 +02:00
Kadir Cetinkaya 34e39eb2ad
[clangd] Change PreambleOnlyAction with content truncation
Summary:
Lexing until the token location is past preamble bound could be wrong
in some cases as preprocessor lexer can lex multiple tokens in a single call.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79426
2020-05-26 07:37:03 +02:00
Kadir Cetinkaya eeedbd0336
[clangd] Make use of SourceOrder to find first initializer in DefineOutline
Summary:
Constructors can have implicit initializers, this was crashing define
outline. Make sure we find the first "written" ctor initializer to figure out
`:` location.

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

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80521
2020-05-26 07:32:07 +02:00
Haojian Wu 72c5ea1d73 [clangd] Enable cross-file-rename by default.
Summary:
The cross-file rename feature is stable enough to enable it (has been
rolled out internally for a few weeks).

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80507
2020-05-25 10:46:57 +02:00
Sam McCall b752a2743a [clangd] Log use of heuristic go-to-def. NFC
Generally:
 - found results using this method -> log
 - no results using this method -> vlog
 - method wasn't applied because ineligible -> no log
2020-05-25 10:19:34 +02:00
Stephen Kelly 2be92b7f7e Fix ignore-traversal to call correct method
As is done by ignoreParenImpCasts(). We were not previously calling the
correct internal method.  Adjust tests to account for this.
2020-05-24 22:33:10 +01:00
Nathan James 4c5818dd8c [clang-tidy] Fix potential assert in use-noexcept check
Summary: Fix a potential assert in use-noexcept check if there is an issue getting the `TypeSourceInfo` as well as a small clean up.

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80371
2020-05-24 14:40:58 +01:00
Stephen Kelly 5e9392deaf Add explicit traversal mode to matchers for implicit constructors 2020-05-24 12:36:15 +01:00
Stephen Kelly 10f0f98eac Add a way to set traversal mode in clang-query
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73037
2020-05-23 14:57:10 +01:00
Stephen Kelly 8d62eba105 Add some explicit use of TK_AsIs 2020-05-23 01:04:44 +01:00
Joe Ranieri e4bb3e25e4 [clang-tidy] Expand the list of functions in bugprone-unused-return-value
This change adds common C, C++, and POSIX functions to the clang-tidy unused return value checker.

Differential Revision: https://reviews.llvm.org/D76083
2020-05-22 12:57:58 -04:00
Stephen Kelly a72307c3a6 Set traversal explicitly where needed in clang-tidy
Reviewers: aaron.ballman

Subscribers: nemanjai, kbarton, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72530
2020-05-21 22:34:37 +01:00
Kirill Bobyrev c6b2b78429 [clangd-remote] Replace YAML serialization with proper Protobuf messages
Summary:
YAML serialization was used in the Proof of Concept for simplicity.
This patch replaces implements Protobuf (de) serialization of almost all
types that need to be transferred over the protocol.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79862
2020-05-19 17:07:38 +02:00
Sam McCall 5bc0c8f009 [clangd] Avoid StringRef entirely with gmock 2020-05-19 16:50:35 +02:00
Sam McCall b0d94964da [clangd] findExplicitReferences supports goto labels
Summary:
This means they're renamable and textDocument/highlight works

This fell out of D78454

Reviewers: adamcz

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80170
2020-05-19 16:50:35 +02:00
Sam McCall 7ebf7d91e6 [clangd] Delete regex assertion, breaking on windows too... 2020-05-19 16:07:01 +02:00
Haojian Wu fcf0764998 [AST] Fix an assertion violation in FieldDecl::getParent.
Summary:
FieldDecl::getParent assumes that the FiledDecl::getDeclContext returns a
RecordDecl, this is true for C/C++, but not for ObjCIvarDecl:

The Decls hierarchy is like following

FieldDecl <-- ObjCIvarDecl

DeclContext <-- ObjCContainerDecl <-- ObjCInterfaceDecl
         ^
         |----- TagDecl <-- RecordDecl

calling getParent() on ObjCIvarDecl will:
1. invoke getDeclContext(), which returns a DeclContext*, which points to an ObjCInterfaceDecl;
2. then downcast the "DeclContext" pointer to a RecordDecl*, and we will hit
the "is_a<RecordDecl>" assertion in llvm::cast (undefined behavior
in release build without assertion enabled);

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

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: rsmith, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79627
2020-05-19 15:35:04 +02:00
Haojian Wu 0320ce8916 [clangd] Add a flag to preserve type for recovery expression.
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79938
2020-05-19 15:21:57 +02:00
Simon Pilgrim 6e99199419 Fix "not all control paths return a value" warning on MSVC builds.
Use llvm_unreachable as typeName(Metric::MetricType T) should handle all enum values.
2020-05-19 13:16:24 +01:00
Sam McCall 61559d0458 [clangd] Squash GCC error with StringRef + gtest MatchesRegex() 2020-05-19 13:58:23 +02:00
Sam McCall 9b88a190b4 [clangd] Add CSV export for trace metrics
Summary: Example: https://docs.google.com/spreadsheets/d/1VZKGetSUTTDe9p4ooIETmdcwUod1_aE3vgD0E9x7HhI/edit

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79678
2020-05-19 13:35:31 +02:00
Sam McCall 032727f4f8 [clangd] Complete filenames after < / ".
Summary:
Extract prefix filters to CodeComplete so it can be easily tested.

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

Reviewers: adamcz

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79456
2020-05-19 13:32:26 +02:00
Mikael Holmen e408b54290 [clangd] Fix gcc compiler warning by removing extra ";" [NFC]
gcc complained with:

/data/repo/master/clang-tools-extra/clangd/index/Ref.h:189:2: warning: extra ';' [-Wpedantic]
 }; // namespace llvm
  ^
2020-05-19 11:57:15 +02:00
Sam McCall e3e15836af [clangd] Tidy up SelectionTree dumps with newlines 2020-05-19 01:48:01 +02:00
Sam McCall d19265b31e [clangd] Avoid wasteful data structures in RefSlab::Builder
Summary: This is worth another 10% or so on InedxBenchmark.DexBuild.

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79950
2020-05-18 22:34:59 +02:00
Kirill Bobyrev 968d293063 [clang-tidy] NFC: Cleanup Python scripts
Summary: Silence few PEP8 warnings.

Reviewers: hokein

Reviewed By: hokein

Subscribers: Eugene.Zelenko, xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78985
2020-05-18 12:21:27 +02:00
Nathan James 4f0cc10bf5 [NFC][clang-tidy] use hasOperands in place of hasEitherOperand 2020-05-18 10:11:22 +01:00
Nathan James 7af0c8559b [clang-tidy] Transformer checks now store IncludeStyle option 2020-05-16 01:14:55 +01:00
Nathan James aef778d4d3 [clang-tidy] Fix assertion in RenamerClangTidyChecks 2020-05-15 12:15:35 +01:00
Alex Lorenz 10b49315fa [test] NFC, add missing declarations and include to test files to avoid 'implicit-function-declaration' diagnostics in the tests 2020-05-14 10:01:50 -07:00
Haojian Wu 0e5706d018 [clangd] Correct the elog message, NFC. 2020-05-14 14:15:21 +02:00
Sam McCall 17ba631d13 [clangd] Remove extra qualification 2020-05-14 14:06:05 +02:00
Sam McCall 735ab46cb4 [clangd] Don't create as much garbage while building Dex index.
Summary:
The Token objects are relatively expensive and we were spending a lot of
CPU creating them for each trigram emitted. Instead, use a tiny trigram
structure until we're ready to finalize the index.

This improves the new BuildDex benchmark by 20%. This code is hot and on
the critical path in clangd: it runs after a new preamble is built.

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79918
2020-05-14 13:35:44 +02:00
Haojian Wu 2045189043 [clangd] Setting recovery-ast flag in buildCompilerInvocation, NFC.
This saves some duplicated code (in buildPreamble and buildAST).
2020-05-14 13:16:59 +02:00
Haojian Wu dbc9e1c39a [clangd] Only emit default error/fatal diagnostices from included files.
Summary:
This would avoid adding too much noise when there is a "-Wall" in the
compile command.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79923
2020-05-14 11:09:06 +02:00
Haojian Wu 774acdfb8c [clangd] Add metrics for selection tree and recovery expressions.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79701
2020-05-12 16:14:48 +02:00
Nathan Ridge 5a7276b354 [clangd] Have suppression comments take precedence over warning-as-error
Summary: This matches the clang-tidy behaviour.

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

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79691
2020-05-12 02:29:03 -04:00
Kadir Cetinkaya cc9fefec43
[clangd] Make version in PublishDiagnosticsParams optional
Summary: We were serializing it no matter what, which was against the spec

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79692
2020-05-11 10:31:10 +02:00
Richard Smith c7ebf00670 Fix clangd test that depended on a diagnostic removed in Clang. 2020-05-10 14:13:25 -07:00
Kadir Cetinkaya 35d867a790
[clangd] Filter pch related flags coming from the user
Summary:
PCH format is unstable, hence using a preamble built with a different
version of clang (or even worse, a different compiler) might result in
unexpected behaviour.

PCH creation on the other hand is something clangd wouldn't want to perform, as
it doesn't generate any output files.

This patch makes sure clangd drops any PCH related compile commands after
parsing the command line args.

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

Reviewers: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79669
2020-05-10 13:03:59 +02:00
Sylvestre Ledru a832fc4b0c Revert two patches, not ready to be shared
Revert "clang-tidy doc: add a note for checkers with an autofix"

This reverts commit dc0f79ea5b.

Revert "add_new_check.py: Update of the template to add an autofix section"

This reverts commit f97f92e5b0.
2020-05-10 11:27:13 +02:00
Sylvestre Ledru b0828135db clang-tidy doc: Fix the syntax to use rst list type 2020-05-10 11:25:20 +02:00
Sylvestre Ledru dc0f79ea5b clang-tidy doc: add a note for checkers with an autofix
Summary:
Currently, when looking at a checker documentation, we have to go back
to the whole list or look at the sources to figure out if an autofix
is available or not.

Reviewers: alexfh, aaron.ballman

Subscribers: wuzish, Eugene.Zelenko, nemanjai, kbarton, arphaman, Charusso, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77983
2020-05-10 11:25:19 +02:00
Sylvestre Ledru f97f92e5b0 add_new_check.py: Update of the template to add an autofix section
Summary: As discussed here: https://reviews.llvm.org/D77983

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78052
2020-05-10 11:25:19 +02:00
Nathan James 0e49ac73ea [NFC] Small rework to RenamerClangTidyCheck addUsage 2020-05-09 18:57:05 +01:00
Kadir Cetinkaya c746781f50
[clangd] Fix data race in BackgroundIndex test
MockFSProvider is not thread-safe. Make sure we don't modify it while
background index is working.
2020-05-09 18:15:27 +02:00
Nathan James 82ddae061b [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved
Summary:
Sometimes in templated code Member references are reported as `DependentScopeMemberExpr` because that's what the standard dictates, however in many trivial cases it is easy to resolve the reference to its actual Member.
Take this code:
```
template<typename T>
class A{
  int value;
  A& operator=(const A& Other){
    value = Other.value;
    this->value = Other.value;
    return *this;
  }
};
```
When ran with `clang-tidy file.cpp -checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.MemberPrefix, value: m_}]}" -fix`
Current behaviour:
```
template<typename T>
class A{
  int m_value;
  A& operator=(const A& Other){
    m_value = Other.value;
    this->value = Other.value;
    return *this;
  }
};
```
As `this->value` and `Other.value` are Dependent they are ignored when creating the fix-its, however this can easily be resolved.
Proposed behaviour:
```
template<typename T>
class A{
  int m_value;
  A& operator=(const A& Other){
    m_value = Other.m_value;
    this->m_value = Other.m_value;
    return *this;
  }
};
```

Reviewers: aaron.ballman, JonasToth, alexfh, hokein, gribozavr2

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D73052
2020-05-09 16:21:49 +01:00
Kadir Cetinkaya 84cbd472e5
[clangd] Fix a data race in RecordsLatencies test 2020-05-09 15:42:21 +02:00
Nico Weber e20fcf0504 Unbreak clang-tidy tests after D79599 / e9b4113902. 2020-05-08 12:37:33 -04:00
Haojian Wu ad811a2728 [clangd] Update the new clangd url, NFC. 2020-05-08 15:11:44 +02:00
Adam Czachorowski 8e7bb37dfb [clangd] Fix crash in AddUsing tweak due to non-identifier DeclName
Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79582
2020-05-08 14:26:21 +02:00
Kirill Bobyrev 9c198b550e
[clangd] NFC: Use deprecated grpc++ headers for compatibility
Summary:
Ubuntu 18.04 and older versions do not provide latest gRCP packages and the
ones that are in the repository use deprecated headers. Use these headers to
make builds possible.

https://packages.ubuntu.com/bionic/amd64/libgrpc++-dev/filelist

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79487
2020-05-08 11:04:52 +02:00
Adam Czachorowski 9108715321 [clangd] Fix AddUsing tweak for out-of-line functions.
Summary:
We used getEnclosingNamespaceContext(), which calls getParent() rather
than getLexicalParent(), so we would end up adding the "using" line in
places that do not affect the cursor location, or just return an error
when declaration was in another file.

Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79496
2020-05-07 12:50:04 +02:00
Kadir Cetinkaya 717bef6623
[clangd] Preserve line information while build PreamblePatch
Summary: Depends on D78740.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78743
2020-05-07 12:24:28 +02:00
Haojian Wu 2a3498e24f [clang-tidy] Exclude function calls in std namespace for bugprone-argument-comment.
Reviewers: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79494
2020-05-07 09:00:49 +02:00
Kadir Cetinkaya 6d6d48add8
[clangd] Reland 'Handle PresumedLocations in IncludeCollector'
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 17:57:03 +02:00
Adam Czachorowski 319787315d [clangd] Do not offer "Add using" tweak in header files.
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79488
2020-05-06 15:50:54 +02:00
Kadir Cetinkaya 9b509bca85
Revert "[clangd] Handle PresumedLocations in IncludeCollector"
This reverts commit 4f7917c269 as it is
breaking windows build bots.
2020-05-06 13:17:08 +02:00
Kadir Cetinkaya 4f7917c269
[clangd] Handle PresumedLocations in IncludeCollector
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 13:06:49 +02:00
Tamás Zolnai fedd52682e [clang-tidy]: Add cert-str34-c alias for bugprone-signed-char-misuse.
Summary:
Added `DiagnoseSignedUnsignedCharComparisons` option to
filter out unrelated use cases. The SEI cert catches explicit
integer casts (two use cases), while in the case of
`signed char` \ `unsigned char` comparison, we have implicit
conversions.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79334
2020-05-06 12:36:01 +02:00
Dmitri Gribenko 3adaa97f01 Fix ForRangeCopyCheck not triggering on iterators returning elements by value in C++17.
Summary:
The AST is different in C++17 in that there is no MaterializeTemporaryExpr for in the AST for a loop variable that is initialized from an iterator that returns its elements by value.

Account for this by checking that the variable is not initialized by an operator* call that returns a value type.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79440
2020-05-06 09:42:13 +02:00
Konrad Kleine 24b4965ce6 [clang/clang-tools-extra] Fix BZ44437 - add_new_check.py does not work with Python 3
Summary:
This fixes https://bugs.llvm.org/show_bug.cgi?id=44437.

Thanks to Arnaud Desitter for providing the patch in the bug report!

A simple example program to reproduce this error is this:

```lang=python

import sys

with open(sys.argv[0], 'r') as f:
  lines = f.readlines()
lines = iter(lines)
line = lines.next()
print(line)
```

which will error with this in python python 3:

```
Traceback (most recent call last):
  File "./mytest.py", line 8, in <module>
    line = lines.next()
AttributeError: 'list_iterator' object has no attribute 'next'
```

Here's the same strategy applied to my test program as applied to the `add_new_check.py` file:

```lang=python

import sys

with open(sys.argv[0], 'r') as f:
  lines = f.readlines()
lines = iter(lines)
line = next(lines)
print(line)
```

The built-in function `next()` is new since Python 2.6: https://docs.python.org/2/library/functions.html#next

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79419
2020-05-05 17:22:50 -04:00
Yitzhak Mandelbaum c5b1a03525 [clang-tidy] In TransformerClangTidyCheck, support option IncludeStyle.
Summary:
The new option allows the user to specify which file naming convention is used
by the source code ('llvm' or 'google').

Reviewers: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79380
2020-05-05 10:38:31 -04:00
Kadir Cetinkaya d870016bfc
[clangd] Get rid of Inclusion::R
Summary:
This is only used by documentlink and go-to-definition. We are pushing
range detection logic from Inclusion creation to users. This would make using
stale preambles easier.

For document links we make use of the spelledtokens stored in tokenbuffers to
figure out file name range.

For go-to-def, we keep storing the line number we've seen the include directive.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79315
2020-05-05 12:23:58 +02:00
Kirill Bobyrev 07f8ca6ab1 [clangd] NFC: Cleanup unused headers and libraries
Summary: Extended version of D78843.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79313
2020-05-05 11:46:28 +02:00
Hans Wennborg 3c2c7760d9 Fix building with GCC5 after e64f99c51a
It was failing with:

  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp: In lambda function:
  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp:374:75:
  error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
                                                  trace::Metric::Distribution);
                                                                             ^
2020-05-04 11:12:39 +02:00
Sam McCall 6fe20a44fd [clangd] Fix yet-another gratuitous llvm::Error crash 2020-05-03 22:13:58 +02:00
Kadir Cetinkaya 81e48ae2b4
[clangd] Reland LSP latency test 2020-05-03 21:06:57 +02:00
Kadir Cetinkaya 7016043d0d
[clangd] Change include to be relative to current directory 2020-05-03 18:09:50 +02:00
Kadir Cetinkaya af28c74e8f
[clangd] Drop duplicate header 2020-05-03 15:20:20 +02:00
Kadir Cetinkaya 6c24b59ca1
[clangd] Fix name hiding in TestTracer and disable racy test for now 2020-05-03 11:51:23 +02:00
Kadir Cetinkaya e64f99c51a
[clangd] Metric tracking through Tracer
Summary: Introduces an endpoint to Tracer for tracking metrics on
internal events.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78429
2020-05-03 10:50:32 +02:00
Sam McCall d10c995b4d std::isspace -> llvm::isSpace (where locale should be ignored)
I've left out some cases where I wasn't totally sure this was right or
whether the include was ok (compiler-rt) or idiomatic (flang).
2020-05-02 15:36:04 +02:00
Sam McCall b283ae7af8 [ADT] Add locale-independent isSpace() to StringExtras. NFC
Use this in clangd, will follow up with replacements for isspace where
locale-dependent is clearly not intended.
2020-05-02 15:20:05 +02:00
Sam McCall fa1f4cf843 [clangd] Rename FormattedString -> Markup, move to support. NFC 2020-05-02 14:53:47 +02:00
Sam McCall ec170b7ccd [clangd] Fix whitespace between chunks in markdown paragraphs.
Summary:
Old model: chunks are always separated by one space.
           This makes it impossible to render "Foo `bar`." correctly.

New model: chunks are separated by space if the left had trailing space, or
           the right had leading space, or space was explicitly requested.
           (Only leading/trailing space in plaintext chunks count, not code)

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79139
2020-05-02 14:39:54 +02:00
Tamás Zolnai 030ff901f4 [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.
Summary:
To cover STR34-C rule's second use case, where ``signed char`` is
used for array subscript after an integer conversion. In the case
of non-ASCII character this conversion will result in a value
in excess of UCHAR_MAX.

There is another clang-tidy check which catches these cases.
cppcoreguidelines-pro-bounds-constant-array-index catches any
indexing which is not integer constant. I think this check is
very strict about the index (e.g. constant), so it's still useful
to cover the ``signed char`` use case in this check, so we
can provide a way to catch the SEI cert rule's use cases on a
codebase, where this CPP guideline is not used.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D78904
2020-05-02 14:05:05 +02:00
Sam McCall 2cf93ef9fe [clangd] Render doc-comment code spans with `backticks` in plaintext mode
Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79142
2020-04-30 20:16:51 +02:00
Sam McCall 54d7db165d [clangd] Move inserted include from detail -> documentation.
Summary: Many clients try to display all the detail inline, with poor results.

See https://github.com/clangd/clangd/issues/284

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79106
2020-04-30 19:58:53 +02:00
Sam McCall a3a27a7aee [clangd] Render code complete documentation as plaintext/markdown.
Summary:
Structure is parsed from the raw comment using the existing heuristics used
for hover.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79157
2020-04-30 19:00:49 +02:00
Kadir Cetinkaya ad2da0521a
[clangd] Get rid of move semantics to unbreak windows build bots 2020-04-30 16:43:50 +02:00
Kadir Cetinkaya 594be179c9
[clangd] Second attempt at fixing VS2019 build bots 2020-04-30 15:37:33 +02:00
Kadir Cetinkaya 932a2b8264
[clangd] Fix VS2019 build bots too 2020-04-30 14:01:09 +02:00
Kadir Cetinkaya 7a3be975b9
[clangd][Hover] Get rid of unused private field in Paragraph 2020-04-30 12:13:18 +02:00
Kadir Cetinkaya 0dedb43153
[clangd] Fix windows build bots without rvalue refs 2020-04-30 10:25:22 +02:00
Kadir Cetinkaya 97c407db77
[clangd] Make use of URIs in FileShardedIndex
Summary:
This makes FileShardedIndex more robust and gets rid of the need for a
URIToFileCache, as it is done by the callers now and it is only once per file,
rather than once per symbol.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79079
2020-04-30 09:47:59 +02:00
Sam McCall 30d17d8852 [clangd] Parse `foo` in documentation comments and render as code.
Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77456
2020-04-30 00:22:15 +02:00
Sam McCall e7a7deb60a [clangd] Fix BUILD_SHARED_LIBS build more. 2020-04-29 22:46:41 +02:00
Sam McCall bc029fa6c5 [clangd] Still need pthreads in clangDaemon. 2020-04-29 21:41:12 +02:00
Kirill Bobyrev 4645ef17ff
[clangd] Add CMake dependencies for Protobuf-generated files
Summary:
Dependencies ensure that Protobufs are generated before all libraries
depending on the headers are **built**, not linked.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79085
2020-04-29 17:01:03 +02:00
Sam McCall ad97ccf6b2 [clangd] Move non-clang base pieces into separate support/ lib. NFCI
Summary:
This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.

Reviewers: kbobyrev

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79014
2020-04-29 15:57:12 +02:00
Richard Smith c35f3f8679 Fix up clangd after clang commit llvmorg-11-init-13375-g0a088ead85f.
It's not clear whether clangd should really consider #import to mark a
header as self-contained or not, but this change preserves the old (and
unit-tested) behavior.
2020-04-28 23:49:35 -07:00
Saleem Abdulrasool 216833b32b Revert "Temporarily revert "build: use `find_package(Python3)` if available""
This reverts commit 35edd704e0.

Revert the revert and extend the patch further to account for the use of
the `PYTHONINTERP_FOUND`.
2020-04-29 01:38:08 +00:00
Paula Toth 8683f5de53 [clang-tidy] Add check callee-namespace.
Summary:
This check will ensure that all calls to functions resolve to one inside the `__llvm_libc` namespace.

This is done to ensure that if we include a public header then we don't accidentally call into the a function within the global namespace.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits, sivachandra

Tags: #clang-tools-extra, #libc-project, #clang

Differential Revision: https://reviews.llvm.org/D78890
2020-04-28 17:22:23 -07:00
Eric Christopher 35edd704e0 Temporarily revert "build: use `find_package(Python3)` if available"
as it seems to be causing multiple people problems with running tests
and building.

This reverts commit c4c3883b00.
2020-04-28 16:41:22 -07:00
Sam McCall 4e769e93b9 Reland "Add a facility to get system cache directory and use it in clangd"
This reverts commit faf2dce1dd.
2020-04-29 00:56:36 +02:00
Eric Christopher faf2dce1dd Temporarily revert "Add a facility to get system cache directory and use it in clangd"
This reverts commit ad38f4b371.

As it broke building the unittests:

.../sources/llvm-project/llvm/unittests/Support/Path.cpp:334:5: error: use of undeclared identifier 'set'
    set(Value);
    ^
1 error generated.
2020-04-28 15:49:46 -07:00
Vojtěch Štěpančík ad38f4b371 Add a facility to get system cache directory and use it in clangd
Summary:
This patch adds a function that is similar to `llvm::sys::path::home_directory`, but provides access to the system cache directory.

For Windows, that is %LOCALAPPDATA%, and applications should put their files under %LOCALAPPDATA%\Organization\Product\.

For *nixes, it adheres to the XDG Base Directory Specification, so it first looks at the XDG_CACHE_HOME environment variable and falls back to ~/.cache/.

Subsequently, the Clangd Index storage leverages this new API to put index files somewhere else than the users home directory.

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

Reviewers: sammccall, chandlerc, Bigcheese

Reviewed By: sammccall

Subscribers: hiraditya, ilya-biryukov, MaskRay, jkorous, dexonsmith, arphaman, kadircet, ormris, usaxena95, cfe-commits, llvm-commits

Tags: #clang-tools-extra, #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78501
2020-04-28 23:18:31 +02:00
Kirill Bobyrev 9ff3f339e8
[clangd] Fix remote index build without shared libs mode
Summary:
Generated Protobuf library has to be in CLANG_EXPORTS and should also be
installed appropriately. The easiest way to do that is via CMake's
add_clang_library. That unfortunately applies "one directory - one
clang_(library|tool)" policy so .proto files should be in a separate directory
and complicates the layout.

This setup works both in shared and static libs mode.

Resolves: https://github.com/clangd/clangd/issues/351

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78885
2020-04-28 19:16:37 +02:00
Saleem Abdulrasool c4c3883b00 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 09:24:27 -07:00
Saleem Abdulrasool be884b7935 Revert "build: use `find_package(Python3)` if available"
This reverts commit cd84bfb814.  Although
this passed the CI in phabricator, some of the bots are missing python3
packages, revert it temporarily.
2020-04-27 20:03:32 -07:00
Saleem Abdulrasool cd84bfb814 build: use `find_package(Python3)` if available
This is primarily motivated by the desire to move from Python2 to
Python3.  `PYTHON_EXECUTABLE` is ambiguous.  This explicitly identifies
the python interpreter in use.  Since the LLVM build seems to be able to
completed successfully with python3, use that across the build.  The old
path aliases `PYTHON_EXECUTABLE` to be treated as Python3.
2020-04-28 01:33:10 +00:00
Matthias Gehre 145dcef8bd [clang-tidy] modernize-use-using: Fix broken fixit with InjectedClassName
Summary:
Before this PR, `modernize-use-using` would transform the typedef in
```
template <int A>
struct InjectedClassName {
  typedef InjectedClassName b;
};
```
into `using b = InjectedClassName<A>;` and
```
template <int>
struct InjectedClassNameWithUnnamedArgument {
  typedef InjectedClassNameWithUnnamedArgument b;
};
```
into `using b = InjectedClassNameWithUnnamedArgument<>;`.
The first fixit is surprising because its different than the code
before, but the second fixit doesn't even compile.

This PR adds an option to the TypePrinter to print InjectedClassNameType without
template parameters (i.e. as written).

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77979
2020-04-27 14:23:23 +02:00
Arthur Eubanks 8000d506af [clangd] Strip /showIncludes in clangd compile commands
In command lines with /showIncludes, clangd would output includes to stdout, breaking clients.

Summary: Fixes https://github.com/clangd/clangd/issues/322.

Reviewers: sammccall, kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78836
2020-04-26 18:57:39 -07:00
Sam McCall 6880c4dfa3 [clangd] Fold buildAST into ParsedAST::build. NFCI 2020-04-27 00:14:03 +02:00
Benjamin Kramer c758181525 [clang-tidy] Use StringSwitch in a bunch of places. NFCI. 2020-04-26 17:24:47 +02:00
Sam McCall 6d7637dc46 [clangd] Disable delayed template parsing in the main file
Summary:
This is on by default in windows and breaks most features in template bodies.
We'd already disabled it in code completion, now disable it for building ASTs.

Potential regressions:
 - we may give spurious errors where files with templates relying on delayed
   parsing are directly opened
 - we may misparse such template bodies that are instantiated (and therefore
   *were* previously parsed)

Still *probably* a win overall. Avoiding the regressions entirely would be
substantial work and we don't have plans for it now.

Fixes https://github.com/clangd/clangd/issues/302 (again)

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78848
2020-04-26 14:29:38 +02:00
Nathan Ridge 230cae89db [clangd] Enable textual fallback for go-to-definition on dependent names
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76451
2020-04-26 00:38:38 -04:00
Kadir Cetinkaya a940a246f5
[clangd] Disable dependency-output lit test on windows 2020-04-25 13:55:38 +02:00
Kadir Cetinkaya 294b9d43ca
[clangd] Disable all dependency outputs
Summary: Fixes https://github.com/clangd/clangd/issues/322

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78833
2020-04-25 13:51:33 +02:00
Sam McCall 226b045b1f [clangd] Look for compilation database in `build` subdirectory of parents.
Summary:
This matches the conventional location of cmake build directories.
It also allows creating a `build` symlink, which seems more flexible than the
compile_commands.json symlinks.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78629
2020-04-25 02:18:17 +02:00
Kirill Bobyrev 9774c34a84 [clangd] NFC: Omit deduced template parameters
Related revision: D78521
2020-04-24 14:27:39 +02:00
Kirill Bobyrev 1ccfe475a7 [clangd] Fix build when CLANGD_REMOTE is not enabled 2020-04-24 14:07:39 +02:00
Kirill Bobyrev 67b2dbd5a3 [clangd] Extend dexp to support remote index
Summary:
* Merge clangd-remote-client into dexp
* Implement `clangd::remote::IndexClient` that is derived from `SymbolIndex`
* Upgrade remote mode-related CMake infrastructure

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78521
2020-04-24 13:59:21 +02:00
Haojian Wu a466e4be38 [clangd] Fix modernize-loop-convert "multiple diag in flight" crash.
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

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

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715
2020-04-24 11:16:36 +02:00
Kadir Cetinkaya 89cb5d5588
[clangd] Delete remapped buffers in tests
These buffers normally get freed after being used in a CompilerInstance.
but tests don't make use of those, so we need to free them explicitly.
2020-04-23 16:31:35 +02:00
Andi-Bogdan Postelnicu bbb7921da9 [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`
Summary: Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`.

Reviewers: JonasToth

Subscribers: xazax.hun, baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, Charusso, ASDenysPetrov, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77882
2020-04-23 11:36:50 +03:00
Haojian Wu 7d1ee639cb [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.
Summary: Fixes https://github.com/clangd/clangd/issues/347.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78626
2020-04-22 21:00:20 +02:00
Sam McCall 3f1c2bf171 [clangd] go-to-def on names in comments etc that are used nearby.
Summary:
This is intended as a companion to (and is inspired by) D72874 which attempts to
resolve these cases using the index.
The intent is we'd try this strategy after the AST-based approach but before the
index-based (I think local usages would be more reliable than index matches).

Reviewers: nridge

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75479
2020-04-22 19:46:41 +02:00
Sam McCall 161afc0106 [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd
Summary:
Moving this out of the monorepo for consistency with other editor plugins.
There's no version lock with clangd itself, and we never ran tests with lit.

The first version from the new repo has been published.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78598
2020-04-22 11:11:13 +02:00
Aaron Ballman 6a30894391 C++2a -> C++20 in some identifiers; NFC. 2020-04-21 15:37:19 -04:00
Sam McCall f5b0591552 [clangd] Bump VSCode version number to allow republish (icon-only change). 2020-04-21 16:09:26 +02:00
Sam McCall 5a68138403 [clangd] Add icon to VSCode extension, and fix URLs 2020-04-21 13:40:47 +02:00
Kadir Cetinkaya 4ccafab076
[clangd] Change field name to prevent shadowing 2020-04-21 11:57:59 +02:00
Kadir Cetinkaya 6b3168f8cd
[clangd] Fix windows buildbots for #import statements 2020-04-21 10:56:34 +02:00
Kadir Cetinkaya 2214b9076f
[clangd] Make signatureHelp work with stale preambles
Summary:
This is achieved by calculating newly added includes and implicitly
parsing them as if they were part of the main file.

This also gets rid of the need for consistent preamble reads.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77392
2020-04-21 10:27:26 +02:00
Kadir Cetinkaya 6e017188b7
[clangd] Store ppdirective in Inclusion
Summary:
This will enable PreamblePatching proposed in D77392 craft a more
informed patch.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78235
2020-04-21 10:27:26 +02:00
Sam McCall 6529b0c48a [clangd] Enable diagnostic fixes within macro argument expansions.
Summary: This seems like a pretty safe case, and common enough to be useful.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78338
2020-04-20 21:18:31 +02:00
Sam McCall ee12edcb76 [Preamble] Allow recursive inclusion of header-guarded mainfile.
Summary:
This is guaranteed to be a no-op without the preamble, so should be a
no-op with it too.

Partially fixes https://github.com/clangd/clangd/issues/337
This doesn't yet work for #ifndef guards, which are not recognized in preambles.
see D78038

I can't for the life of me work out how to test this outside clangd.
The original reentrant preamble diagnostic was untested, I added a test
to clangd for that too.

Reviewers: kadircet

Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78366
2020-04-20 17:28:42 +02:00
Michael Forster b36b889a3b Explicitly move from llvm::json Array/Object to Value
Summary: The implicit conversion fails under Clang 3.8.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78487
2020-04-20 15:18:52 +02:00
Kadir Cetinkaya 3be73dfde7
[clangd][test] Make sed git bash compliant 2020-04-20 08:27:15 +02:00
Sam McCall 098e40eac5 [clangd] Add index export to dexp
Summary: Add a command to dexp that exports index data in chosen format (e.g. YAML).

Reviewers: sammccall

Subscribers: kbobyrev, mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D77385
2020-04-19 14:34:46 +02:00
Sam McCall 8c68de2d63 [clangd] Extend YAML Serialization
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D77938
2020-04-19 14:32:31 +02:00
Kadir Cetinkaya 66b54d586f
[clangd] Fix memory leak in FileIndexTest 2020-04-17 14:00:34 +02:00
Kadir Cetinkaya 4503cf5f23
[clangd] Drop dangling relations while sharding
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78359
2020-04-17 13:57:32 +02:00
Matthias Gehre 0642e5e7a7 [clang-tidy] modernize-use-using: Fix broken fixit with 'template' keyword
Summary:
Before this PR, `modernize-use-using` would transform the typedef in
```

template <typename a> class TemplateKeyword {
  typedef typename a::template f<> e;
  typedef typename a::template f<>::d e2;
};
```
into
```
template <typename a> class TemplateKeyword {
  using d = typename a::b<>;
  using d2 = typename a::template a::b<>::c;
};
```
The first one is missing the `template` keyword,
the second one has an extra `a::` scope. Both result
in compilation errors.

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78139
2020-04-17 10:37:24 +02:00
Sam McCall 63725df1d6 [clangd] Remove unused and underused helpers. NFC 2020-04-17 01:08:32 +02:00
Sam McCall b0c4dfb3b1 [clangd] Print PID on windows too 2020-04-17 01:00:42 +02:00
Chris Lattner 39c9c12b76 [clang-tools-extra] reimplement PreprocessorTracker in terms of StringSet.
Summary:
PreprocessorTracker is the last user of the old StringPool class, which
isn't super loved and isn't a great improvement over a plan StringSet.
Once this goes in we can remove StringPool entirely.

This is as discussed on cfe-dev.

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78273
2020-04-16 12:57:43 -07:00
Kirill Bobyrev cee80c0489 [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)
Summary:
This patch allows using installed gRPC to build two simple tools which
currently provide the functionality of looking up the symbol by name.
remote-index-client is a simplified version of dexp which connects to
remote-index-server passes lookup requests.

I also significantly reduced the scope of this patch to prevent large changelist
and more bugs. The next steps would be:

* Extending Protocol for deep copies of Symbol and inherit RemoteIndex from
  Index to unify the interfaces
* Make remote-index-server more generic and merge the remote index client with
  dexp
* Modify Clangd to allow using remote index instead of the local one for all
  global index requests

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77794
2020-04-16 13:55:08 +02:00
Haojian Wu 6a78c55e3a [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78181
2020-04-15 21:42:27 +02:00
Kim Viggedal b2d8c89ea4 Remove false positive in AvoidNonConstGlobalVariables.
Addresses post-commit review feedback from https://reviews.llvm.org/D70265
2020-04-15 14:48:06 -04:00
Nico Weber 99e4061bd8 Try to fix clang-tidy/infrastructure/config-files.cpp on Win after cb1ee34e9d.
See also r267736.
2020-04-15 13:38:03 -04:00
Dmitry Polukhin cb1ee34e9d [clang-tidy] Optional inheritance of file configs from parent directories
Summary:
Without this patch clang-tidy stops finding file configs on the nearest
.clang-tidy file. In some cases it is not very convenient because it
results in common parts duplication into every child .clang-tidy file.
This diff adds optional config inheritance from the parent directories
config files.

Test Plan:

Added test cases in existing config test.

Reviewers: alexfh, gribozavr2, klimek, hokein

Subscribers: njames93, arphaman, xazax.hun, aheejin, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75184
2020-04-15 06:41:31 -07:00
Kirill Bobyrev f058673397 [dexp] NFC: Change positional argument format
Summary:
Before:

  USAGE: dexp [options] --index-path Path to the index

After:

  USAGE: dexp [options] <INDEX FILE>

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78089
2020-04-15 13:28:07 +02:00
Kadir Cetinkaya 2cd0be02b9
[clangd] Fix MSVC compile error, attempt 2 2020-04-15 09:33:12 +02:00
Kadir Cetinkaya 6d53897554
[clangd] Fix MSVC builds 2020-04-15 09:24:58 +02:00
Kadir Cetinkaya dffa9dfbda
[clangd] Shard preamble symbols in dynamic index
Summary:
This reduces memory usage by dynamic index from more than 400MB to 32MB
when all files in clang-tools-extra/clangd/*.cpp are active in clangd.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77732
2020-04-15 09:10:10 +02:00
Nathan Ridge d83541d1b8 [clangd] Color dependent names based on their heuristic target if they have one
Summary: Fixes https://github.com/clangd/clangd/issues/297

Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76896
2020-04-15 00:57:08 -04:00
Sam McCall 808c2855e1 [clangd] Add tests that no-op changes are cheap
Summary:
We want to be sure they don't cause AST rebuilds or evict items from the cache.
D77847 is going to start sending spurious no-op changes (in case the preamble
was invalidated), this is cheap enough but we shouldn't regress that in future.

Reviewers: kadircet

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78048
2020-04-14 16:15:23 +02:00