@@ -1361,13 +1361,23 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
13611361
13621362 picojson::object obj = res.get <picojson::object>();
13631363
1364- const std::string fileName = obj[" file" ].get <std::string>();
1365- const int64_t lineNumber = obj[" linenr" ].get <int64_t >();
1366- const int64_t column = obj[" column" ].get <int64_t >();
1367-
13681364 ErrorMessage errmsg;
13691365
1370- errmsg.callStack .emplace_back (ErrorMessage::FileLocation (fileName, lineNumber, column));
1366+ if (obj.count (" file" ) > 0 ) {
1367+ const std::string fileName = obj[" file" ].get <std::string>();
1368+ const int64_t lineNumber = obj[" linenr" ].get <int64_t >();
1369+ const int64_t column = obj[" column" ].get <int64_t >();
1370+ errmsg.callStack .emplace_back (ErrorMessage::FileLocation (fileName, lineNumber, column));
1371+ } else if (obj.count (" loc" ) > 0 ) {
1372+ for (const picojson::value &locvalue: obj[" loc" ].get <picojson::array>()) {
1373+ picojson::object loc = locvalue.get <picojson::object>();
1374+ const std::string fileName = loc[" file" ].get <std::string>();
1375+ const int64_t lineNumber = loc[" linenr" ].get <int64_t >();
1376+ const int64_t column = loc[" column" ].get <int64_t >();
1377+ const std::string info = loc[" info" ].get <std::string>();
1378+ errmsg.callStack .emplace_back (ErrorMessage::FileLocation (fileName, info, lineNumber, column));
1379+ }
1380+ }
13711381
13721382 errmsg.id = obj[" addon" ].get <std::string>() + " -" + obj[" errorId" ].get <std::string>();
13731383 const std::string text = obj[" message" ].get <std::string>();
@@ -1376,7 +1386,7 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
13761386 errmsg.severity = Severity::fromString (severity);
13771387 if (errmsg.severity == Severity::SeverityType::none)
13781388 continue ;
1379- errmsg.file0 = fileName ;
1389+ errmsg.file0 = ((files. size () == 1 ) ? files[ 0 ] : " " ) ;
13801390
13811391 reportErr (errmsg);
13821392 }
0 commit comments