From ecb3f0a9341ec6c6f4c83b2d65f203b940d006be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 16 May 2017 22:58:02 +0200 Subject: [PATCH] ErrorLogger: Write ErrorPath info in the xml report --- lib/errorlogger.cpp | 20 +++++++++++++++----- lib/errorlogger.h | 7 +++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index a141fdf51..d13f2fc4d 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -193,9 +193,9 @@ std::string ErrorLogger::ErrorMessage::serialize() const oss << saneVerboseMessage.length() << " " << saneVerboseMessage; oss << _callStack.size() << " "; - for (std::list::const_iterator tok = _callStack.begin(); tok != _callStack.end(); ++tok) { + for (std::list::const_iterator loc = _callStack.begin(); loc != _callStack.end(); ++loc) { std::ostringstream smallStream; - smallStream << (*tok).line << ":" << (*tok).getfile(); + smallStream << (*loc).line << ':' << (*loc).getfile() << '\t' << loc->getinfo(); oss << smallStream.str().length() << " " << smallStream.str(); } @@ -260,11 +260,19 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data) const std::string::size_type colonPos = temp.find(':'); if (colonPos == std::string::npos) throw InternalError(0, "Internal Error: No colon found in pattern"); + const std::string::size_type tabPos = temp.find('\t'); + if (tabPos == std::string::npos) + throw InternalError(0, "Internal Error: No tab found in pattern"); + const std::string tempinfo = temp.substr(tabPos + 1); + temp.erase(tabPos); + const std::string tempfile = temp.substr(colonPos + 1); + temp.erase(colonPos); + const std::string templine = temp; ErrorLogger::ErrorMessage::FileLocation loc; - loc.setfile(temp.substr(colonPos + 1)); - temp = temp.substr(0, colonPos); - std::istringstream fiss(temp); + loc.setfile(tempfile); + loc.setinfo(tempinfo); + std::istringstream fiss(templine); fiss >> loc.line; _callStack.push_back(loc); @@ -366,6 +374,8 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const printer.PushAttribute("file0", Path::toNativeSeparators(file0).c_str()); printer.PushAttribute("file", (*it).getfile().c_str()); printer.PushAttribute("line", (*it).line); + if (!it->getinfo().empty()) + printer.PushAttribute("info", it->getinfo().c_str()); printer.CloseElement(false); } printer.CloseElement(false); diff --git a/lib/errorlogger.h b/lib/errorlogger.h index c9cfe3e72..6c352ddc1 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -193,6 +193,10 @@ public: : line(aline), fileNumber(0), _file(file) { } + FileLocation(const std::string &file, const std::string &info, unsigned int aline) + : line(aline), fileNumber(0), _file(file), _info(info) { + } + FileLocation(const Token* tok, const TokenList* list); FileLocation(const Token* tok, const std::string &info, const TokenList* tokenList); @@ -217,6 +221,9 @@ public: unsigned int line; unsigned int fileNumber; + std::string getinfo() const { return _info; } + void setinfo(const std::string &i) { _info = i; } + private: std::string _file; std::string _info;