parent
72a36172aa
commit
0dc53ac7fe
|
@ -522,7 +522,7 @@ unsigned int CppCheck::check(const std::string &path)
|
|||
}
|
||||
|
||||
// run addons
|
||||
executeAddons(dumpFile);
|
||||
executeAddons(dumpFile, path);
|
||||
|
||||
} catch (const InternalError &e) {
|
||||
const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, path, "Bailing out from analysis: Processing Clang AST dump failed");
|
||||
|
@ -967,7 +967,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
|||
fdump.close();
|
||||
}
|
||||
|
||||
executeAddons(dumpFile);
|
||||
executeAddons(dumpFile, Path::simplifyPath(filename));
|
||||
|
||||
} catch (const TerminateException &) {
|
||||
// Analysis is terminated
|
||||
|
@ -1371,15 +1371,15 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token
|
|||
}
|
||||
#endif
|
||||
|
||||
void CppCheck::executeAddons(const std::string& dumpFile)
|
||||
void CppCheck::executeAddons(const std::string& dumpFile, const std::string& file0)
|
||||
{
|
||||
if (!dumpFile.empty()) {
|
||||
std::vector<std::string> f{dumpFile};
|
||||
executeAddons(f);
|
||||
executeAddons(f, file0);
|
||||
}
|
||||
}
|
||||
|
||||
void CppCheck::executeAddons(const std::vector<std::string>& files)
|
||||
void CppCheck::executeAddons(const std::vector<std::string>& files, const std::string& file0)
|
||||
{
|
||||
if (mSettings.addons.empty() || files.empty())
|
||||
return;
|
||||
|
@ -1444,7 +1444,7 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
|||
}
|
||||
else if (!mSettings.severity.isEnabled(errmsg.severity))
|
||||
continue;
|
||||
errmsg.file0 = ((files.size() == 1) ? files[0] : "");
|
||||
errmsg.file0 = file0;
|
||||
|
||||
reportErr(errmsg);
|
||||
}
|
||||
|
@ -1463,7 +1463,7 @@ void CppCheck::executeAddonsWholeProgram(const std::map<std::string, std::size_t
|
|||
}
|
||||
|
||||
try {
|
||||
executeAddons(ctuInfoFiles);
|
||||
executeAddons(ctuInfoFiles, "");
|
||||
} catch (const InternalError& e) {
|
||||
const ErrorMessage errmsg = ErrorMessage::fromInternalError(e, nullptr, "", "Bailing out from analysis: Whole program analysis failed");
|
||||
reportErr(errmsg);
|
||||
|
|
|
@ -182,8 +182,8 @@ private:
|
|||
/**
|
||||
* Execute addons
|
||||
*/
|
||||
void executeAddons(const std::vector<std::string>& files);
|
||||
void executeAddons(const std::string &dumpFile);
|
||||
void executeAddons(const std::vector<std::string>& files, const std::string& file0);
|
||||
void executeAddons(const std::string &dumpFile, const std::string& file0);
|
||||
|
||||
/**
|
||||
* Execute addons
|
||||
|
|
|
@ -211,6 +211,18 @@ def test_execute_addon_failure_2(tmpdir):
|
|||
assert stderr == "{}:0:0: error: Bailing out from analysis: Checking file failed: Failed to execute addon 'naming' - exitcode is {} [internalError]\n\n^\n".format(test_file, ec)
|
||||
|
||||
|
||||
def test_execute_addon_file0(tmpdir):
|
||||
test_file = os.path.join(tmpdir, 'test.c')
|
||||
with open(test_file, 'wt') as f:
|
||||
f.write('void foo() {}\n')
|
||||
|
||||
args = ['--xml', '--addon=misra', '--enable=style', test_file]
|
||||
|
||||
_, _, stderr = cppcheck(args)
|
||||
assert 'misra-c2012-8.2' in stderr
|
||||
assert '.dump' not in stderr
|
||||
|
||||
|
||||
# TODO: find a test case which always fails
|
||||
@pytest.mark.skip
|
||||
def test_internal_error(tmpdir):
|
||||
|
|
Loading…
Reference in New Issue