diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp
index af227c891..69aea810c 100644
--- a/cli/cppcheckexecutor.cpp
+++ b/cli/cppcheckexecutor.cpp
@@ -122,7 +122,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
if (parser.getShowErrorMessages()) {
mShowAllErrors = true;
- std::cout << ErrorMessage::getXMLHeader();
+ std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName);
cppcheck->getErrorMessages();
std::cout << ErrorMessage::getXMLFooter() << std::endl;
}
@@ -908,7 +908,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
}
if (settings.xml) {
- reportErr(ErrorMessage::getXMLHeader());
+ reportErr(ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName));
}
if (!settings.buildDir.empty()) {
diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp
index e0c881543..180929b2e 100644
--- a/lib/errorlogger.cpp
+++ b/lib/errorlogger.cpp
@@ -368,7 +368,7 @@ bool ErrorMessage::deserialize(const std::string &data)
return true;
}
-std::string ErrorMessage::getXMLHeader()
+std::string ErrorMessage::getXMLHeader(const std::string& productName)
{
tinyxml2::XMLPrinter printer;
@@ -380,6 +380,8 @@ std::string ErrorMessage::getXMLHeader()
printer.PushAttribute("version", 2);
printer.OpenElement("cppcheck", false);
+ if (!productName.empty())
+ printer.PushAttribute("product-name", productName.c_str());
printer.PushAttribute("version", CppCheck::version());
printer.CloseElement(false);
printer.OpenElement("errors", false);
diff --git a/lib/errorlogger.h b/lib/errorlogger.h
index e81e541d7..702f10436 100644
--- a/lib/errorlogger.h
+++ b/lib/errorlogger.h
@@ -160,7 +160,7 @@ public:
*/
std::string toXML() const;
- static std::string getXMLHeader();
+ static std::string getXMLHeader(const std::string& productName);
static std::string getXMLFooter();
/**
diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp
index 7376614ea..0282fb430 100644
--- a/test/testerrorlogger.cpp
+++ b/test/testerrorlogger.cpp
@@ -192,7 +192,7 @@ private:
header += " \n ";
- ASSERT_EQUALS(header, ErrorMessage::getXMLHeader());
+ ASSERT_EQUALS(header, ErrorMessage::getXMLHeader(""));
ASSERT_EQUALS(" \n", ErrorMessage::getXMLFooter());
std::string message(" \n";
@@ -208,7 +208,7 @@ private:
header += " \n ";
- ASSERT_EQUALS(header, ErrorMessage::getXMLHeader());
+ ASSERT_EQUALS(header, ErrorMessage::getXMLHeader(""));
ASSERT_EQUALS(" \n", ErrorMessage::getXMLFooter());
std::string message(" \n";