Commit Graph

3272 Commits

Author SHA1 Message Date
Kazu Hirata 3b7c3a654c Revert "Don't use Optional::hasValue (NFC)"
This reverts commit aa8feeefd3.
2022-06-25 11:56:50 -07:00
Kazu Hirata aa8feeefd3 Don't use Optional::hasValue (NFC) 2022-06-25 11:55:57 -07:00
Kazu Hirata b8df4093e4 [clang, clang-tools-extra] Don't use Optional::{hasValue,getValue} (NFC) 2022-06-25 11:55:33 -07:00
Nathan James fbf611ed2a
[clang-tidy] Extend spelling for CheckOptions
The current way to specify CheckOptions is pretty verbose and unintuitive.
Given that the options are a dictionary it makes much more sense to treat them as such in the config files.
Example:
```
CheckOptions: {SomeCheck.Option: true, SomeCheck.OtherOption: 'ignore'}
# Or
CheckOptions:
  SomeCheck.Option: true
  SomeCheck.OtherOption: 'ignore'
```

This change will still handle the old syntax with no issue, ensuring we don't screw up users current config files.

The only observable differences are support for the new syntax and `-dump=config` will emit using the new syntax.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D128337
2022-06-23 19:59:31 +01:00
Kazu Hirata ed8fceaa09 Don't use Optional::getValue (NFC) 2022-06-20 23:35:53 -07:00
Kazu Hirata 0916d96d12 Don't use Optional::hasValue (NFC) 2022-06-20 20:17:57 -07:00
Kazu Hirata 064a08cd95 Don't use Optional::hasValue (NFC) 2022-06-20 20:05:16 -07:00
Kazu Hirata 5413bf1bac Don't use Optional::hasValue (NFC) 2022-06-20 11:33:56 -07:00
Kadir Cetinkaya 1c92e06ded
[clangd] Handle initializers that contain =
Differential Revision: https://reviews.llvm.org/D128197
2022-06-20 16:42:54 +02:00
Kazu Hirata 30c675878c Use value_or instead of getValueOr (NFC) 2022-06-19 10:34:41 -07:00
Kazu Hirata 5dd171dcb5 [clang-tools-extra] Use value_or instead of getValueOr (NFC) 2022-06-19 00:13:38 -07:00
Tobias Ribizel e984e1cd61
[clangd] Don't add inlay hints on std::move/forward
This removes parameter inlay hints from a few builtin functions like std::move/std::forward

Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D127859
2022-06-16 12:24:16 +02:00
David Goldman bc1f24332a [clangd] Improve ObjC protocol suggestions from the index
When querying the index during an ObjC protocol name lookup for code
completion, we should only suggest ObjC protocols.

Differential Revision: https://reviews.llvm.org/D127125
2022-06-15 15:02:37 -04:00
Kadir Cetinkaya 0473530281
[clangd][NFC] Use the existing ASTContext from scope 2022-06-15 16:10:49 +02:00
Kadir Cetinkaya 7212977fbb
[clangd] Always desugar type aliases in hover
The alias itself is already included in the definition section of the
hover (it's printed as spelled in source code). So it doesn't provide any value
when we print the aliases as-is.
Fixes https://github.com/clangd/clangd/issues/1134.

Differential Revision: https://reviews.llvm.org/D127832
2022-06-15 16:10:49 +02:00
Furkan Usta 462def25ec
[clang] Use correct visibility parameters when following a Using declaration
Fixes https://github.com/clangd/clangd/issues/1137

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D127629
2022-06-15 15:52:59 +02:00
Kadir Cetinkaya a67beef3ac
[clangd] Enable AKA type printing by default
This has been tested on a large set of c++ developers for a long while,
without any crashes or complaints.

Differential Revision: https://reviews.llvm.org/D127833
2022-06-15 10:43:17 +02:00
Kadir Cetinkaya 3ecfeb4c2f
[clangd] Wire up compilation for style blocks
Differential Revision: https://reviews.llvm.org/D127749
2022-06-15 08:15:32 +02:00
Paul Pluzhnikov afbe3aed49 [clangd] Minor refactor of CanonicalIncludes::addSystemHeadersMapping.
Before commit b3a991df3c SystemHeaderMap used to be a vector.

Commit b3a991df3c changed it into a map, but neglected to remove
duplicate keys (e.g. "bits/typesizes.h", "include/stdint.h", etc.).

To prevent confusion, remove all duplicates, build HeaderMapping
one pair at a time and assert() that no duplicates are found.

Change by Paul Pluzhnikov (ppluzhnikov)!

Reviewed By: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D125742
2022-06-09 12:18:39 +02:00
Andrew Browne c7689fd552 [Clang] Fix memory leak due to TemplateArgumentListInfo used in AST node.
It looks like the leak is rooted at the allocation here:
1a155ee7de/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (L3857)

The VarTemplateSpecializationDecl is allocated using placement new which uses the AST structure for ownership: 1a155ee7de/clang/lib/AST/DeclBase.cpp (L99)

The problem is the TemplateArgumentListInfo inside 1a155ee7de/clang/include/clang/AST/DeclTemplate.h (L2721)
This object contains a vector which does not use placement new: 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L564)

Apparently ASTTemplateArgumentListInfo should be used instead 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L575)

https://reviews.llvm.org/D125802#3551305

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126944
2022-06-08 09:58:25 -07:00
Qingyuan Zheng c119a17e7f [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl
Fixes https://github.com/clangd/clangd/issues/1132
where clangd's semantic highlighting is missing for symbols of a template
specialization definition. It turns out the visitor didn't traverse the
base classes of Class/Var##TemplateSpecializationDecl, i.e.
CXXRecordDecl/VarDecl. This patch adds them back as what is done in
DEF_TRAVERSE_TMPL_PART_SPEC_DECL.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D126757
2022-06-06 02:35:34 -04:00
Yuki Okushi 5c14940394
[clangd] Remove a test with a duplicate of FileCacheTests
FIXME says it should be removed so followed it.

Differential Revision: https://reviews.llvm.org/D126608
2022-06-01 08:15:54 +09:00
Sam McCall 218393f44e Revert "[clangd] Fix hover crashing on integral or enumeral casts"
This reverts commit ce5ebf0b91.

Fails on bots e.g. https://buildkite-cloud.s3.amazonaws.com/logs-by-pipeline/f8ab115f-a384-49e8-a048-0f71ab03c5d0/0181020b-0737-40e5-a05a-ab198347d8ad/0181020b-ecbe-4ac6-ad23-e04c17217893.log?response-content-disposition=inline&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQPCP3C7LT7IGTS76%2F20220531%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220531T202904Z&X-Amz-Expires=600&X-Amz-Security-Token=IQo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yQFKcAolRDI%2F7NRmG8HwtP40iTCjflOHIxkJ1%2FnVNqkeyIznUu6zOr589zIjNqFCm74jOfWjj2%2FO8WU4pc%2FRqeBuGzzpQkAIGGxCwsmd3WG8Z8pyMoJomij7c4LO6ep4O0OUESxbXHcIfzUfR6ajPsKFKS9lb&X-Amz-SignedHeaders=host&X-Amz-Signature=96a132be6f99b5cd5cf29f3226115e480508079047bc8639d69c672f1fe9f0c1
2022-05-31 22:30:20 +02:00
Georg Kotheimer ce5ebf0b91 [clangd] Fix hover crashing on integral or enumeral casts
When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.
2022-05-31 22:05:23 +02:00
David Goldman c797952d4f [clangd] Minor fixes to ExtractVariableTests missed in D124486 2022-05-31 11:34:35 -04:00
David Goldman ae67984ca6 [clangd] ExtractVariable support for C and Objective-C
- Use the expression's type for non-C++ as the variable type. This works
  well, but might not preserve the typedefs due to type
  canonicalization.

- Improve support for Objective-C property references which are
  represented using `ObjCPropertyRefExpr` and `BuiltinType::PseudoObject`.

Differential Revision: https://reviews.llvm.org/D124486
2022-05-31 11:14:51 -04:00
Nathan Ridge 175833ed6f [clangd] Handle '--' in QueryDriverDatabase
Fixes https://github.com/clangd/clangd/issues/1100,
a regression from D116721.

Differential Revision: https://reviews.llvm.org/D126274
2022-05-24 13:10:41 -04:00
Sam McCall 1fef69da0b
Avoid uninitialized Diag.ID (which we pass but never read) 2022-05-20 20:29:47 +02:00
David Goldman 322e2a3b40 [clangd][ObjC] Filter ObjC method completions on the remaining selector
Previously, clangd would filter completions only on the first part of
the selector (first typed chunk) instead of all remaining selector
fragments (all typed chunks).

Differential Revision: https://reviews.llvm.org/D124637
2022-05-20 11:49:16 -04:00
Sam McCall edc7a08145 [clangd] Provide links to clang-tidy and include-cleaner diagnostic docs
LSP supports Diagnostic.codeInformation since 3.16.
In VSCode, this turns the code (e.g. "unused-includes" or "bugprone-foo") into
a clickable link that opens the docs in a web browser.

Differential Revision: https://reviews.llvm.org/D126065
2022-05-20 16:33:48 +02:00
Haojian Wu 5b0022a9df [clangd] Support UnresolvedUsingTypeLoc AST node in FindTarget.
to make features like hover, go-to-def work when the cursor is on the
UnresolvedUsingTypeLoc.

Differential Revision: https://reviews.llvm.org/D125684
2022-05-20 14:54:17 +02:00
Utkarsh Saxena 5bbf6ad5b6 Add an option to fill container for ref
This allows index implementations to fill container details when required specially when computing containerID is expensive.

Differential Revision: https://reviews.llvm.org/D125925
2022-05-19 16:05:38 +02:00
Kirill Bobyrev 4f5a4215bf
[clangd] Update the test after diagnostic message change 2022-05-19 12:03:31 +02:00
Kirill Bobyrev 43c0f90dd6
[clangd] NFC: Clarify the Include Cleaner warning 2022-05-19 11:59:00 +02:00
Sam McCall 4f35ca59d0 [clangd] Suppress warning: control reaches end of function 2022-05-19 08:26:13 +02:00
Sam McCall 03ea140b3a Reland(3) "[clangd] Indexing of standard library"
Tracked down the crash, which was argument-evaluation-order UB
in the wrapping indexStandardLibrary().
Sorry for the churn!

This reverts commit 77533ea443.
2022-05-19 08:13:23 +02:00
Sam McCall 77533ea443 Revert "Reland(2) "[clangd] Indexing of standard library""
This reverts commit ca875539f7.
2022-05-18 17:38:45 +02:00
Sam McCall ca875539f7 Reland(2) "[clangd] Indexing of standard library"
This reverts commit 6aabf60f2f.
2022-05-18 15:30:37 +02:00
Sam McCall 6aabf60f2f Revert "Reland "[clangd] Indexing of standard library""
This reverts commit ccdb56ac10.

Still seeing windows failures on GN bots: http://45.33.8.238/win/58316/step_9.txt

Unfortunately I can't debug these at all - it's a bare unsymbolized
stacktrace, and I can't reproduce the failure.
2022-05-17 21:33:48 +02:00
Sam McCall ccdb56ac10 Reland "[clangd] Indexing of standard library"
This reverts commit 76ddbb1ca7.
2022-05-17 21:02:23 +02:00
Sam McCall 127a1492d7 [clangd] Add command-line flag to set background indexing thread priority.
This is a followup to D124715, which changed the default, and it anticipates
future patches raising the priority of Low (which is currently equal to
Background on Windows & Linux).
The main point is to allow users to restore the old behavior, which e.g.
allows efficiency cores to remain idle.

I did consider making this a config setting, this is a more complicated change:
 - needs to touch queue priorities as well as thread priorities
 - we don't know the priority until evaluating the config inside the task
 - users would want the ability to prioritize background indexing tasks relative
   to each other without necessarily affecting thread priority, so using one
   option for both may be confusing
I don't really have a use case, so I prefer the simpler thing.

Differential Revision: https://reviews.llvm.org/D125673
2022-05-17 20:17:07 +02:00
Sam McCall 76ddbb1ca7 Revert "[clangd] Indexing of standard library"
This reverts commit ecaa4d9662.
2022-05-17 17:17:27 +02:00
Sam McCall ecaa4d9662 [clangd] Indexing of standard library
This provides a nice "warm start" with all headers indexed, not just
those included so far.

The standard library is indexed after a preamble is parsed, using that
file's configuration. The result is pushed into the dynamic index.
If we later see a higher language version, we reindex it.

It's configurable as Index.StandardLibrary, off by default for now.

Based on D105177 by @kuhnel

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

Differential Revision: https://reviews.llvm.org/D115232
2022-05-17 16:50:41 +02:00
Nathan Ridge df2a4eae6b [clang] Expose CoawaitExpr's operand in the AST
Previously the Expr returned by getOperand() was actually the
subexpression common to the "ready", "suspend", and "resume"
expressions, which often isn't just the operand but e.g.
await_transform() called on the operand.

It's important for the AST to expose the operand as written
in the source for traversals and tools like clangd to work
correctly.

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

Differential Revision: https://reviews.llvm.org/D115187
2022-05-17 08:13:37 -04:00
Utkarsh Saxena 2fb6ece2ca Optimise findRefs for XRefs and docHighlights
Reduces time spent in findRef by 66%.

Differential Revision: https://reviews.llvm.org/D125675
2022-05-16 21:07:14 +02:00
Utkarsh Saxena 5edd7665fd Add documentHighlight in clangd check for performance measurements.
Differential Revision: https://reviews.llvm.org/D125682
2022-05-16 20:22:36 +02:00
Tobias Ribizel 71cb8c8cb9 [clangd] parse all make_unique-like functions in preamble
I am working on support for forwarding parameter names in make_unique-like functions, first for inlay hints, later maybe for signature help.
For that to work generically, I'd like to parse all of these functions in the preamble. Not sure how this impacts performance on large codebases though.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D124688
2022-05-16 11:17:25 +02:00
Kirill Bobyrev 106e63ce47 [clangd] NFC: Rename field to be compatible with the function name 2022-05-16 10:18:08 +02:00
Kirill Bobyrev 40f361ace3
[clangd] Include Cleaner: ignore headers with IWYU export pragmas
Disable the warnings with `IWYU pragma: export` or `begin_exports` +
`end_exports` until we have support for these pragmas. There are too many
false-positive warnings for the headers that have the correct pragmas for now
and it makes the user experience very unpleasant.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D125468
2022-05-16 10:13:47 +02:00
stk 9902a0945d Add ThreadPriority::Low, and use QoS class Utility on Mac
On Apple Silicon Macs, using a Darwin thread priority of PRIO_DARWIN_BG seems to
map directly to the QoS class Background. With this priority, the thread is
confined to efficiency cores only, which makes background indexing take forever.

Introduce a new ThreadPriority "Low" that sits in the middle between Background
and Default, and maps to QoS class "Utility" on Mac. Make this new priority the
default for indexing. This makes the thread run on all cores, but still lowers
priority enough to keep the machine responsive, and not interfere with
user-initiated actions.

I didn't change the implementations for Windows and Linux; on these systems,
both ThreadPriority::Background and ThreadPriority::Low map to the same thread
priority. This could be changed as a followup (e.g. by using SCHED_BATCH for Low
on Linux).

See also https://github.com/clangd/clangd/issues/1119.

Reviewed By: sammccall, dgoldman

Differential Revision: https://reviews.llvm.org/D124715
2022-05-16 10:01:49 +02:00