Bugfix: Apply --relative-paths also to preprocessor errors

Merged from LCppC
This commit is contained in:
PKEuS 2021-02-18 22:35:55 +01:00 committed by Daniel Marjamäki
parent f836c7a546
commit 1a7595e29b
2 changed files with 10 additions and 2 deletions

View File

@ -574,7 +574,11 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
}
if (err) {
const ErrorMessage::FileLocation loc1(output.location.file(), output.location.line, output.location.col);
std::string file = Path::fromNativeSeparators(output.location.file());
if (mSettings.relativePaths)
file = Path::getRelativePath(file, mSettings.basePaths);
const ErrorMessage::FileLocation loc1(file, output.location.line, output.location.col);
std::list<ErrorMessage::FileLocation> callstack(1, loc1);
ErrorMessage errmsg(callstack,

View File

@ -810,7 +810,11 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const
{
std::list<ErrorMessage::FileLocation> locationList;
if (!filename.empty()) {
const ErrorMessage::FileLocation loc(filename, linenr, 0);
std::string file = Path::fromNativeSeparators(filename);
if (mSettings.relativePaths)
file = Path::getRelativePath(file, mSettings.basePaths);
const ErrorMessage::FileLocation loc(file, linenr, 0);
locationList.push_back(loc);
}
mErrorLogger->reportErr(ErrorMessage(locationList,