[clang-tools-extra] [clangd] Show comment of field on hover (PR #182738)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 06:24:18 PDT 2026


================
@@ -541,75 +557,91 @@ std::optional<StringRef> getterVariableName(const CXXMethodDecl *CMD) {
 //   void foo(T arg) { FieldName = std::move(arg); }
 //   R foo(T arg) { FieldName = std::move(arg); return *this; }
 // then returns "FieldName"
-std::optional<StringRef> setterVariableName(const CXXMethodDecl *CMD) {
+// Returns the LHS expression of the assignment in a trivial setter body, or
+// nullptr if the method does not match the pattern of a trivial setter.
----------------
timon-ul wrote:

Actually I got baited a bit by the old comment too, it mentions the case of `return *this`, which is only a trivial setter if the return type is specifically a reference, so it should probably say `R&` and not just `R`.

Also `return this` is also working and missing from the list (this then actually has a return type of `R`).

https://github.com/llvm/llvm-project/pull/182738


More information about the cfe-commits mailing list