[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 25 22:08:38 PDT 2023
PiotrZSL marked 2 inline comments as done.
PiotrZSL added inline comments.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst:18
+
+ const std::string& value("hello");
+
----------------
xgupta wrote:
> PiotrZSL wrote:
> > xgupta wrote:
> > > The below comment is not matching, do you want to write -
> > > `const std::string& str = std::string("hello");`
> > > ?
> > actually comment is +- fine, constructor to std::string will be called anyway, and for compiler I think those 2 are equal.
> > Will verify.
> but you have written below `reference variable ``str`` is assigned a temporary object` and there is no str variable.
Ok, that's actually a bug. It's `value`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146368/new/
https://reviews.llvm.org/D146368
More information about the cfe-commits
mailing list