Skip to content

Commit 3553cb7

Browse files
committed
fixed #13926 - the original filename was not stored in the XML [skip ci]
1 parent 2c2342f commit 3553cb7

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

lib/errorlogger.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,19 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
196196
for (const tinyxml2::XMLElement *e = errmsg->FirstChildElement(); e; e = e->NextSiblingElement()) {
197197
const char* name = e->Name();
198198
if (std::strcmp(name,"location")==0) {
199+
const char *strorigfile = e->Attribute("origfile");
199200
const char *strfile = e->Attribute("file");
200201
const char *strinfo = e->Attribute("info");
201202
const char *strline = e->Attribute("line");
202203
const char *strcolumn = e->Attribute("column");
203204

205+
const char *origfile = strorigfile ? strorigfile : unknown;
204206
const char *file = strfile ? strfile : unknown;
205207
const char *info = strinfo ? strinfo : "";
206208
const int line = strline ? strToInt<int>(strline) : 0;
207209
const int column = strcolumn ? strToInt<int>(strcolumn) : 0;
208210
callStack.emplace_front(file, info, line, column);
211+
callStack.front().setOrigFile(origfile);
209212
} else if (std::strcmp(name,"symbol")==0) {
210213
mSymbolNames += e->GetText();
211214
}
@@ -508,6 +511,7 @@ std::string ErrorMessage::toXML() const
508511

509512
for (auto it = callStack.crbegin(); it != callStack.crend(); ++it) {
510513
printer.OpenElement("location", false);
514+
printer.PushAttribute("origfile", it->getOrigFile().c_str());
511515
printer.PushAttribute("file", it->getfile(false).c_str());
512516
printer.PushAttribute("line", std::max(it->line,0));
513517
printer.PushAttribute("column", it->column);
@@ -750,6 +754,11 @@ void ErrorMessage::FileLocation::setfile(std::string file)
750754
mFileName = Path::simplifyPath(std::move(file));
751755
}
752756

757+
void ErrorMessage::FileLocation::setOrigFile(std::string file)
758+
{
759+
mOrigFileName = Path::simplifyPath(std::move(file));
760+
}
761+
753762
std::string ErrorMessage::FileLocation::stringify(bool addcolumn) const
754763
{
755764
std::string str;

lib/errorlogger.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class CPPCHECKLIB ErrorMessage {
8181
*/
8282
void setfile(std::string file);
8383

84+
/**
85+
* Set the filename.
86+
* @param file Filename to set.
87+
*/
88+
void setOrigFile(std::string file);
89+
8490
/**
8591
* @return the location as a string. Format: [file:line]
8692
*/

0 commit comments

Comments
 (0)