This commit is contained in:
parent
2cd1f0f387
commit
8d3fd88d3f
|
@ -2054,7 +2054,7 @@ void CheckStl::string_c_str()
|
|||
if (Token::Match(refTok, "%var% = %var% .|;|["))
|
||||
refToNonLocal = !isLocal(refTok->tokAt(2));
|
||||
}
|
||||
ptrOrRef = refToNonLocal || (tok2->variable() && tok2->variable()->isPointer());
|
||||
ptrOrRef = refToNonLocal || (tok2->variable() && (tok2->variable()->isPointer() || tok2->variable()->isSmartPointer()));
|
||||
}
|
||||
while (tok2) {
|
||||
if (Token::Match(tok2, "%var% .|::")) {
|
||||
|
|
|
@ -4261,6 +4261,15 @@ private:
|
|||
" std::string_view sv(s.data(), 13);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct S { std::string x; };\n" // #11802
|
||||
"std::vector<std::shared_ptr<S>> global;\n"
|
||||
"const char* f() {\n"
|
||||
" auto s = std::make_shared<S>();\n"
|
||||
" global.push_back(s);\n"
|
||||
" return s->x.c_str();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uselessCalls() {
|
||||
|
|
Loading…
Reference in New Issue