xml: output file0 whenever it is different to filename, both for included files and when #line is used.

This commit is contained in:
Daniel Marjamäki 2016-01-19 07:01:21 +01:00
parent 5ab8c20d8e
commit dc5e2d5c8d
2 changed files with 2 additions and 3 deletions

View File

@ -27,7 +27,6 @@
#include "xmlreport.h"
#include "xmlreportv2.h"
#include "cppcheck.h"
#include "path.h"
static const char ResultElementName[] = "results";
static const char CppcheckElementName[] = "cppcheck";
@ -122,7 +121,7 @@ void XmlReportV2::WriteError(const ErrorItem &error)
mXmlWriter->writeStartElement(LocationElementName);
QString file = QDir::toNativeSeparators(error.files[i]);
if (Path::isHeader(file.toStdString()) && !error.file0.isEmpty()) {
if (!error.file0.isEmpty() && file != error.file0) {
mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, quoteMessage(error.file0));
}
file = XmlReport::quoteMessage(file);

View File

@ -287,7 +287,7 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const
for (std::list<FileLocation>::const_reverse_iterator it = _callStack.rbegin(); it != _callStack.rend(); ++it) {
printer.OpenElement("location", false);
if (Path::isHeader((*it).getfile()) && !file0.empty())
if (!file0.empty() && (*it).getfile() != file0)
printer.PushAttribute("file0", Path::toNativeSeparators(file0).c_str());
printer.PushAttribute("file", (*it).getfile().c_str());
printer.PushAttribute("line", (*it).line);