File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -3380,6 +3380,8 @@ void CheckClass::checkReturnByReference()
33803380 continue ;
33813381 if (func.isOperator ())
33823382 continue ;
3383+ if (func.functionPointerUsage )
3384+ continue ;
33833385 if (const Library::Container* container = mSettings ->library .detectContainer (func.retDef ))
33843386 if (container->view )
33853387 continue ;
Original file line number Diff line number Diff line change @@ -9240,6 +9240,15 @@ class TestClass : public TestFixture {
92409240 " };\n " );
92419241 ASSERT_EQUALS (" [test.cpp:10:17]: (performance) Function 'get2()' should return member 'str' by const reference. [returnByReference]\n " ,
92429242 errout_str ());
9243+
9244+ checkReturnByReference (" struct S {\n " // #13845
9245+ " std::string m;\n "
9246+ " std::string get() { return m; }\n "
9247+ " };\n "
9248+ " std::string f(std::optional<S> o) {\n "
9249+ " return o.transform(&S::get).value_or(\"\" );\n "
9250+ " }\n " );
9251+ ASSERT_EQUALS (" " , errout_str ());
92439252 }
92449253};
92459254
You can’t perform that action at this time.
0 commit comments