Fix crash in LoopAnalyzer (#4888)
This commit is contained in:
parent
0b8af4fff7
commit
a6c5bb28c1
|
@ -2781,7 +2781,7 @@ namespace {
|
|||
if (var->declarationId() == loopVar->varId())
|
||||
return false;
|
||||
const Scope* scope = var->scope();
|
||||
return scope->isNestedIn(bodyTok->scope());
|
||||
return scope && scope->isNestedIn(bodyTok->scope());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -5476,6 +5476,23 @@ private:
|
|||
true);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Consider using std::all_of or std::none_of algorithm instead of a raw loop.\n",
|
||||
errout.str());
|
||||
|
||||
check("class C {\n"
|
||||
"private:\n"
|
||||
" QString s;\n"
|
||||
"public:\n"
|
||||
" C(QString);\n"
|
||||
"private slots:\n"
|
||||
" void f() {\n"
|
||||
" QVERIFY(QDir(s).exists());\n"
|
||||
" }\n"
|
||||
" void f(const QStringList& d) {\n"
|
||||
" for (QString f : d)\n"
|
||||
" QDir(s);\n"
|
||||
" }\n"
|
||||
"};\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void invalidContainer() {
|
||||
|
|
Loading…
Reference in New Issue