parent
af0a585a70
commit
95dc05b21d
|
@ -5104,6 +5104,12 @@
|
|||
<function name="crend" yields="end-iterator"/>
|
||||
</access>
|
||||
</container>
|
||||
<type-checks>
|
||||
<unusedvar>
|
||||
<suppress>QApplication</suppress>
|
||||
<suppress>QMutexLocker</suppress>
|
||||
</unusedvar>
|
||||
</type-checks>
|
||||
<!-- Treat QStringList as QList<QString> since we can't remove the template parameter when we inherit. -->
|
||||
<define name="QStringList" value="QList<QString>"/>
|
||||
<define name="Q_ARG(type, data)" value="QArgument<type >(#type, data)"/>
|
||||
|
|
|
@ -8342,6 +8342,12 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
|
|||
<suppress>std::lock_guard</suppress>
|
||||
<suppress>std::unique_lock</suppress>
|
||||
<suppress>std::shared_lock</suppress>
|
||||
<suppress>std::fstream</suppress>
|
||||
<suppress>std::wfstream</suppress>
|
||||
<suppress>std::ofstream</suppress>
|
||||
<suppress>std::wofstream</suppress>
|
||||
<suppress>std::basic_fstream</suppress>
|
||||
<suppress>std::basic_ofstream</suppress>
|
||||
<check>std::pair</check>
|
||||
</unusedvar>
|
||||
</type-checks>
|
||||
|
|
|
@ -1192,7 +1192,7 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
|||
continue;
|
||||
|
||||
if (tok->isName()) {
|
||||
if (isRaiiClass(tok->valueType(), mTokenizer->isCPP(), true))
|
||||
if (isRaiiClass(tok->valueType(), mTokenizer->isCPP(), false))
|
||||
continue;
|
||||
tok = tok->next();
|
||||
}
|
||||
|
@ -1223,6 +1223,8 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
|||
op1tok = op1tok->astOperand1();
|
||||
|
||||
const Variable *op1Var = op1tok ? op1tok->variable() : nullptr;
|
||||
if (!op1Var && Token::Match(tok, "(|{") && tok->previous() && tok->previous()->variable())
|
||||
op1Var = tok->previous()->variable();
|
||||
std::string bailoutTypeName;
|
||||
if (op1Var) {
|
||||
if (op1Var->isReference() && op1Var->nameToken() != tok->astOperand1())
|
||||
|
@ -1278,8 +1280,8 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
|||
Severity::information,
|
||||
"checkLibraryCheckType",
|
||||
"--check-library: Provide <type-checks><unusedvar> configuration for " + bailoutTypeName);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// warn
|
||||
|
|
|
@ -5431,6 +5431,17 @@ private:
|
|||
" std::unique_lock<std::mutex> lock(m);\n" // #4624
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void f() {\n" // #7732
|
||||
" const std::pair<std::string, std::string> p(\"a\", \"b\");\n"
|
||||
" std::pair<std::string, std::string> q{\"a\", \"b\" };\n"
|
||||
" auto r = std::pair<std::string, std::string>(\"a\", \"b\");\n"
|
||||
" auto s = std::pair<std::string, std::string>{ \"a\", \"b\" };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
||||
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n"
|
||||
"[test.cpp:4]: (style) Variable 'r' is assigned a value that is never used.\n"
|
||||
"[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", errout.str());
|
||||
}
|
||||
|
||||
void localVarClass() {
|
||||
|
@ -5610,7 +5621,7 @@ private:
|
|||
" int buf[6];\n"
|
||||
" Data data(buf);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (information) --check-library: Provide <type-checks><unusedvar> configuration for Data\n", errout.str());
|
||||
}
|
||||
|
||||
void localvarCpp11Initialization() {
|
||||
|
|
Loading…
Reference in New Issue