Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/errorlogger.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -196,16 +196,20 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
for (const tinyxml2::XMLElement *e = errmsg->FirstChildElement(); e; e = e->NextSiblingElement()) {
const char* name = e->Name();
if (std::strcmp(name,"location")==0) {
const char *strorigfile = e->Attribute("origfile");
const char *strfile = e->Attribute("file");
const char *strinfo = e->Attribute("info");
const char *strline = e->Attribute("line");
const char *strcolumn = e->Attribute("column");

const char *file = strfile ? strfile : unknown;
const char *origfile = strorigfile ? strorigfile : file;
const char *info = strinfo ? strinfo : "";
const int line = strline ? strToInt<int>(strline) : 0;
const int column = strcolumn ? strToInt<int>(strcolumn) : 0;
callStack.emplace_front(file, info, line, column);
callStack.emplace_front(origfile, info, line, column);
if (strorigfile)
callStack.front().setfile(file);
} else if (std::strcmp(name,"symbol")==0) {
mSymbolNames += e->GetText();
}
Expand DownExpand Up@@ -508,7 +512,11 @@ std::string ErrorMessage::toXML() const

for (auto it = callStack.crbegin(); it != callStack.crend(); ++it) {
printer.OpenElement("location", false);
printer.PushAttribute("file", it->getfile(false).c_str());
const std::string origfile = it->getOrigFile(false);
const std::string file = it->getfile(false);
if (origfile != file)
printer.PushAttribute("origfile", origfile.c_str());
printer.PushAttribute("file", file.c_str());
printer.PushAttribute("line", std::max(it->line,0));
printer.PushAttribute("column", it->column);
if (!it->getinfo().empty())
Expand Down
10 changes: 6 additions & 4 deletions test/testerrorlogger.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -409,9 +409,9 @@ class TestErrorLogger : public TestFixture {
message += " <location file=\"bar.cpp\" line=\"8\" column=\"1\" info=\"\\303\\244\"/>\n";
message += " <location file=\"foo.cpp\" line=\"5\" column=\"1\"/>\n";
message += " <location file=\"dir1/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location file=\"dir2/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location file=\"dir3/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location file=\"dir4/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location origfile=\"dir2\\a.cpp\" file=\"dir2/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location origfile=\"dir/a.cpp\" file=\"dir3/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " <location origfile=\"dir/a.cpp\" file=\"dir4/a.cpp\" line=\"1\" column=\"1\"/>\n";
message += " </error>";
ASSERT_EQUALS(message, msg.toXML());
}
Expand DownExpand Up@@ -443,7 +443,7 @@ class TestErrorLogger : public TestFixture {
" hash=\"456\""
">\n"
" <location file=\"bar.cpp\" line=\"8\" column=\"1\"/>\n"
" <location file=\"foo.cpp\" line=\"5\" column=\"2\"/>\n"
" <location origfile=\"proj/foo.cpp\" file=\"foo.cpp\" line=\"5\" column=\"2\"/>\n"
"</error>";
tinyxml2::XMLDocument doc;
ASSERT(doc.Parse(xmldata, sizeof(xmldata)) == tinyxml2::XML_SUCCESS);
Expand All@@ -458,9 +458,11 @@ class TestErrorLogger : public TestFixture {
ASSERT_EQUALS("Verbose error", msg.verboseMessage());
ASSERT_EQUALS(456u, msg.hash);
ASSERT_EQUALS(2u, msg.callStack.size());
ASSERT_EQUALS("proj/foo.cpp", msg.callStack.front().getOrigFile(false));
ASSERT_EQUALS("foo.cpp", msg.callStack.front().getfile(false));
ASSERT_EQUALS(5, msg.callStack.front().line);
ASSERT_EQUALS(2u, msg.callStack.front().column);
ASSERT_EQUALS("bar.cpp", msg.callStack.back().getOrigFile(false));
ASSERT_EQUALS("bar.cpp", msg.callStack.back().getfile(false));
ASSERT_EQUALS(8, msg.callStack.back().line);
ASSERT_EQUALS(1u, msg.callStack.back().column);
Expand Down