[clang-tools-extra] [clangd] Add inlay hints for default function arguments and implicit lambda captures (PR #95712)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 16 22:37:38 PDT 2024
================
@@ -372,6 +382,34 @@ maybeDropCxxExplicitObjectParameters(ArrayRef<const ParmVarDecl *> Params) {
return Params;
}
+llvm::StringRef getLambdaCaptureName(const LambdaCapture &Capture) {
+ if (Capture.capturesVariable())
+ return Capture.getCapturedVar()->getName();
+ if (Capture.capturesThis())
+ return llvm::StringRef{"this"};
+ return llvm::StringRef{"unknown"};
+}
+
+template <typename R, typename P>
+std::string joinAndTruncate(R &&Range, size_t MaxLength,
+ P &&GetAsStringFunction) {
+ std::string Out;
+ bool IsFirst = true;
+ for (auto &&Element : Range) {
+ if (!IsFirst)
+ Out.append(", ");
+ else
+ IsFirst = false;
----------------
zyn0217 wrote:
nit: 1. We don't usually append to a string; instead, we use `llvm::raw_string_ostream`. 2. This whole thing can be simplified by [`llvm::ListSeparator`](https://github.com/llvm/llvm-project/blob/ef18986b2033a44e69b7c3553a356e9037ac1413/llvm/include/llvm/ADT/StringExtras.h#L507-L529)
https://github.com/llvm/llvm-project/pull/95712
More information about the cfe-commits
mailing list