[PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 13:48:12 PDT 2016


Prazek added inline comments.

================
Comment at: clang-tidy/performance/ReturningTypeCheck.cpp:43
@@ +42,3 @@
+///   matches "b(1)".
+AST_MATCHER_P(CXXConstructExpr, ctorCallee,
+              ast_matchers::internal::Matcher<CXXConstructorDecl>,
----------------
This seems like a usefull matcher. We should probably add it to ASTMatchers, or at least move it to Utils

================
Comment at: docs/clang-tidy/checks/performance-returning-type.rst:26
@@ +25,3 @@
+    ;;;
+    return std::move(s);
+  }
----------------
It actually becomes boost::optional<std::string>(std::move(s));


================
Comment at: docs/clang-tidy/checks/performance-returning-type.rst:35
@@ +34,2 @@
+    return "str";
+  }
----------------
Please add some subsection, or something similiar with note:
"This check requires C++11 or higher to run"

================
Comment at: docs/clang-tidy/checks/performance-returning-type.rst:35
@@ +34,2 @@
+    return "str";
+  }
----------------
Prazek wrote:
> Please add some subsection, or something similiar with note:
> "This check requires C++11 or higher to run"
Also describe a little bit when the checks doesn't triggers, or when it triggers, like
"for function returning A, that is constructible from B
check triggers when:
- B::B(A &&)
- B::B(A) when A is movable and not trivially copyable
- A::operator B() when B is movable 

check doesn't trigger when
- B::B(const A&)
- a is const


(and some other rules that I didn't add here)




http://reviews.llvm.org/D21303





More information about the cfe-commits mailing list