[PATCH] D90682: [clangd][NFC] Make Located::operator->() use pointer sematics
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 06:17:47 PST 2020
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
njames93 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
This enables using the arrow operator to access members of the contained item.
Located<std::string> X;
const char* CStr = X->c_str();
This is inline with how classes like `Optional` handle the arrow operator.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90682
Files:
clang-tools-extra/clangd/ConfigFragment.h
Index: clang-tools-extra/clangd/ConfigFragment.h
===================================================================
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -51,8 +51,8 @@
: Range(Range), Value(std::move(Value)) {}
llvm::SMRange Range;
- T &operator->() { return Value; }
- const T &operator->() const { return Value; }
+ T *operator->() { return &Value; }
+ const T *operator->() const { return &Value; }
T &operator*() { return Value; }
const T &operator*() const { return Value; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90682.302565.patch
Type: text/x-patch
Size: 563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201103/9eb86edd/attachment.bin>
More information about the cfe-commits
mailing list