[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 04:14:28 PDT 2023


PiotrZSL added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:39
+              ID) {
+  NotExtendedByDeclBoundToPredicate Predicate;
+  Predicate.ID = ID;
----------------
xgupta wrote:
> Can be written using direct initialization as  `NotExtendedByDeclBoundToPredicate Predicate{ID};`
Yes, but I followed like others are done.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst:18
+
+   const std::string& value("hello");
+
----------------
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.


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