added environment variable `UNUSEDFUNCTION_ONLY` to make sure only the `unusedFunction` check is being executed (#4362)
This commit is contained in:
parent
12afb9bbf4
commit
9f7a725983
|
@ -78,6 +78,7 @@ jobs:
|
||||||
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
|
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
|
||||||
env:
|
env:
|
||||||
DISABLE_VALUEFLOW: 1
|
DISABLE_VALUEFLOW: 1
|
||||||
|
UNUSEDFUNCTION_ONLY: 1
|
||||||
|
|
||||||
# the following steps are duplicated from above since setting up the build node in a parallel step takes longer than the actual steps
|
# the following steps are duplicated from above since setting up the build node in a parallel step takes longer than the actual steps
|
||||||
- name: CMake (no test)
|
- name: CMake (no test)
|
||||||
|
@ -98,6 +99,7 @@ jobs:
|
||||||
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
|
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
|
||||||
env:
|
env:
|
||||||
DISABLE_VALUEFLOW: 1
|
DISABLE_VALUEFLOW: 1
|
||||||
|
UNUSEDFUNCTION_ONLY: 1
|
||||||
|
|
||||||
- name: Fetch corpus
|
- name: Fetch corpus
|
||||||
run: |
|
run: |
|
||||||
|
@ -126,6 +128,7 @@ jobs:
|
||||||
head -50 callgrind.annotated.log
|
head -50 callgrind.annotated.log
|
||||||
env:
|
env:
|
||||||
DISABLE_VALUEFLOW: 1
|
DISABLE_VALUEFLOW: 1
|
||||||
|
UNUSEDFUNCTION_ONLY: 1
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -1025,6 +1025,10 @@ void CppCheck::checkRawTokens(const Tokenizer &tokenizer)
|
||||||
|
|
||||||
void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||||
{
|
{
|
||||||
|
// TODO: this should actually be the behavior if only "--enable=unusedFunction" is specified - see #10648
|
||||||
|
const char* unusedFunctionOnly = std::getenv("UNUSEDFUNCTION_ONLY");
|
||||||
|
const bool doUnusedFunctionOnly = unusedFunctionOnly && (std::strcmp(unusedFunctionOnly, "1") == 0);
|
||||||
|
|
||||||
// call all "runChecks" in all registered Check classes
|
// call all "runChecks" in all registered Check classes
|
||||||
for (Check *check : Check::instances()) {
|
for (Check *check : Check::instances()) {
|
||||||
if (Settings::terminated())
|
if (Settings::terminated())
|
||||||
|
@ -1033,6 +1037,9 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||||
if (Tokenizer::isMaxTime())
|
if (Tokenizer::isMaxTime())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (doUnusedFunctionOnly && dynamic_cast<CheckUnusedFunctions*>(check) == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &s_timerResults);
|
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &s_timerResults);
|
||||||
check->runChecks(&tokenizer, &mSettings, this);
|
check->runChecks(&tokenizer, &mSettings, this);
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1060,10 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||||
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
|
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Check *check: Check::instances()) {
|
for (const Check *check : Check::instances()) {
|
||||||
|
if (doUnusedFunctionOnly && dynamic_cast<const CheckUnusedFunctions*>(check) == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
|
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
|
||||||
if (fi != nullptr) {
|
if (fi != nullptr) {
|
||||||
if (mSettings.jobs == 1)
|
if (mSettings.jobs == 1)
|
||||||
|
|
Loading…
Reference in New Issue