File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4703,6 +4703,16 @@ class TestStl : public TestFixture {
47034703 " }\n " );
47044704 ASSERT_EQUALS (" [test.cpp:3:14]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n " ,
47054705 errout_str ());
4706+
4707+ check (" std::string get();\n "
4708+ " std::string f(std::string & s) {\n "
4709+ " s = get().c_str();\n "
4710+ " std::string s2{ get().c_str() };\n "
4711+ " return s2;\n "
4712+ " }\n " );
4713+ ASSERT_EQUALS (" [test.cpp:3:5]: (performance) Assigning the result of c_str() to a std::string is slow and redundant. [stlcstrAssignment]\n "
4714+ " [test.cpp:4:17]: (performance) Constructing a std::string from the result of c_str() is slow and redundant. [stlcstrConstructor]\n " ,
4715+ errout_str ());
47064716 }
47074717
47084718 void uselessCalls () {
You can’t perform that action at this time.
0 commit comments