https://github.com/torshepherd updated
https://github.com/llvm/llvm-project/pull/95712
>From 07e5dcc71dc20c9d7482fc076cbeeb5e97a797d7 Mon Sep 17 00:00:00 2001
From: Tor Shepherd
Date: Wed, 19 Jun 2024 09:55:34 -0400
Subject: [PATCH 1/2] after comments
---
clang-tools-extra/clangd/Config.h
torshepherd wrote:
Ok I took a stab at doing lambda captures as hover instead.
- Targeting the exact '=' or '&' is nontrivial since the capture list isn't in
the AST, the lambda is just `LambdaExpr` with children for the parameters and
the CompoundStmt body.
- `auto MyLambda = [...` already
https://github.com/torshepherd updated
https://github.com/llvm/llvm-project/pull/95712
>From 3830a49faf5e20781f864d459f5478221740ac3d Mon Sep 17 00:00:00 2001
From: Tor Shepherd
Date: Wed, 19 Jun 2024 09:55:34 -0400
Subject: [PATCH 1/2] after comments
---
clang-tools-extra/clangd/Config.h
https://github.com/torshepherd updated
https://github.com/llvm/llvm-project/pull/95712
>From 3830a49faf5e20781f864d459f5478221740ac3d Mon Sep 17 00:00:00 2001
From: Tor Shepherd
Date: Wed, 19 Jun 2024 09:55:34 -0400
Subject: [PATCH 1/2] after comments
---
clang-tools-extra/clangd/Config.h
@@ -372,6 +382,34 @@ maybeDropCxxExplicitObjectParameters(ArrayRef Params) {
return Params;
}
+llvm::StringRef getLambdaCaptureName(const LambdaCapture ) {
+ if (Capture.capturesVariable())
+return Capture.getCapturedVar()->getName();
+ if (Capture.capturesThis())
+
@@ -372,6 +382,34 @@ maybeDropCxxExplicitObjectParameters(ArrayRef Params) {
return Params;
}
+llvm::StringRef getLambdaCaptureName(const LambdaCapture ) {
+ if (Capture.capturesVariable())
+return Capture.getCapturedVar()->getName();
+ if (Capture.capturesThis())
+
@@ -15,9 +15,12 @@
#include "support/Context.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include
#include
+#include
torshepherd
https://github.com/torshepherd updated
https://github.com/llvm/llvm-project/pull/95712
>From 3830a49faf5e20781f864d459f5478221740ac3d Mon Sep 17 00:00:00 2001
From: Tor Shepherd
Date: Wed, 19 Jun 2024 09:55:34 -0400
Subject: [PATCH 1/2] after comments
---
clang-tools-extra/clangd/Config.h
https://github.com/torshepherd updated
https://github.com/llvm/llvm-project/pull/95712
>From 77bb21454b2110bed491689a4c323cff1c745207 Mon Sep 17 00:00:00 2001
From: Tor Shepherd
Date: Sun, 16 Jun 2024 10:54:43 -0400
Subject: [PATCH] Add default arguments and lambda captures only
---
zyn0217 wrote:
> To clarify, you mean hovering over the default capture '=' or '&' right?
Yep, that's what I thought.
> I'm happy to remove the lambdas from this PR in favor of the hover approach.
No worries, but let's wait for other reviewers' opinions before we move
forward. :)
@@ -504,10 +503,10 @@ struct FragmentCompiler {
auto Fast = isFastTidyCheck(Str);
if (!Fast.has_value()) {
diag(Warning,
- llvm::formatv(
- "Latency of clang-tidy check '{0}' is not known. "
- "It will only run if
@@ -1568,7 +1626,7 @@ TEST(TypeHints, SubstTemplateParameterAliases) {
)cpp";
llvm::StringRef VectorIntPtr = R"cpp(
-vector array;
+vector $init[[array]];
torshepherd wrote:
Another artifact, sorry
https://github.com/llvm/llvm-project/pull/95712
@@ -1458,13 +1463,66 @@ TEST(TypeHints, DefaultTemplateArgs) {
struct A {};
A foo();
auto $var[[var]] = foo();
-A bar[1];
+A baz;
+A bar[1]{};
torshepherd wrote:
My fault, an artifact from a different set of inlay hints I decided not
@@ -15,9 +15,12 @@
#include "support/Context.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include
#include
+#include
torshepherd
torshepherd wrote:
Aha, that's a great suggestion. I agree that beyond the trivial case of 2
captured variables it gets a bit noisy. On-hover would be quite nice though!
To clarify, you mean hovering over the default capture '=' or '&' right?
I'm happy to remove the lambdas from this PR in
@@ -372,6 +382,34 @@ maybeDropCxxExplicitObjectParameters(ArrayRef Params) {
return Params;
}
+llvm::StringRef getLambdaCaptureName(const LambdaCapture ) {
+ if (Capture.capturesVariable())
+return Capture.getCapturedVar()->getName();
+ if (Capture.capturesThis())
+
@@ -281,7 +281,7 @@ struct TextDocumentEdit {
/// The text document to change.
VersionedTextDocumentIdentifier textDocument;
- /// The edits to be applied.
+ /// The edits to be applied.
zyn0217 wrote:
Ditto. Unrelated blank changes. Please revert
@@ -1458,13 +1463,66 @@ TEST(TypeHints, DefaultTemplateArgs) {
struct A {};
A foo();
auto $var[[var]] = foo();
-A bar[1];
+A baz;
+A bar[1]{};
zyn0217 wrote:
Why there's an empty initializer? Can you revert it?
@@ -504,10 +503,10 @@ struct FragmentCompiler {
auto Fast = isFastTidyCheck(Str);
if (!Fast.has_value()) {
diag(Warning,
- llvm::formatv(
- "Latency of clang-tidy check '{0}' is not known. "
- "It will only run if
@@ -1568,7 +1626,7 @@ TEST(TypeHints, SubstTemplateParameterAliases) {
)cpp";
llvm::StringRef VectorIntPtr = R"cpp(
-vector array;
+vector $init[[array]];
zyn0217 wrote:
Will the range ever be used somewhere?
@@ -372,6 +382,34 @@ maybeDropCxxExplicitObjectParameters(ArrayRef Params) {
return Params;
}
+llvm::StringRef getLambdaCaptureName(const LambdaCapture ) {
+ if (Capture.capturesVariable())
+return Capture.getCapturedVar()->getName();
+ if (Capture.capturesThis())
+
@@ -755,12 +807,34 @@ class InlayHintVisitor : public
RecursiveASTVisitor {
bool NameHint = shouldHintName(Args[I], Name);
bool ReferenceHint = shouldHintReference(Params[I], ForwardedParams[I]);
+ bool IsDefault = isa(Args[I]);
+ HasNonDefaultArgs |=
https://github.com/zyn0217 commented:
My two cents:
While I appreciate the value of inspecting more semantic information about
lambdas, I still have mixed feelings about user experience.
Admittedly, presenting implicitly captured variables provides users with
insight into ODR-used variables,
@@ -15,9 +15,12 @@
#include "support/Context.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include
#include
+#include
zyn0217 wrote:
https://github.com/zyn0217 edited
https://github.com/llvm/llvm-project/pull/95712
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
llvmbot wrote:
@llvm/pr-subscribers-clang-tools-extra
Author: Tor Shepherd (torshepherd)
Changes
Title. This PR adds support for showing implicit lambda captures:
![image](https://github.com/llvm/llvm-project/assets/49597791/d0150817-f71e-4971-8d8b-e25d2b1e8bf8)
and defaulted function
github-actions[bot] wrote:
Thank you for submitting a Pull Request (PR) to the LLVM Project!
This PR will be automatically labeled and the relevant teams will be
notified.
If you wish to, you can add reviewers by using the "Reviewers" section on this
page.
If this is not working for you,
https://github.com/torshepherd created
https://github.com/llvm/llvm-project/pull/95712
Title. This PR adds support for showing implicit lambda captures:
![image](https://github.com/llvm/llvm-project/assets/49597791/d0150817-f71e-4971-8d8b-e25d2b1e8bf8)
and defaulted function arguments:
28 matches
Mail list logo