MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / reportClangErrors

Function reportClangErrors

lib/cppcheck.cpp:574–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574static bool reportClangErrors(std::istream &is, const std::function<void(const ErrorMessage&)>& reportErr, std::vector<ErrorMessage> &warnings)
575{
576 std::string line;
577 while (std::getline(is, line)) {
578 if (line.empty() || line[0] == ' ' || line[0] == '`' || line[0] == '-')
579 continue;
580
581 std::string::size_type pos3 = line.find(": error: ");
582 if (pos3 == std::string::npos)
583 pos3 = line.find(": fatal error:");
584 if (pos3 == std::string::npos)
585 pos3 = line.find(": warning:");
586 if (pos3 == std::string::npos)
587 continue;
588
589 // file:line:column: error: ....
590 const std::string::size_type pos2 = line.rfind(':', pos3 - 1);
591 const std::string::size_type pos1 = line.rfind(':', pos2 - 1);
592
593 if (pos1 >= pos2 || pos2 >= pos3)
594 continue;
595
596 std::string filename = line.substr(0, pos1);
597 const std::string linenr = line.substr(pos1+1, pos2-pos1-1);
598 const std::string colnr = line.substr(pos2+1, pos3-pos2-1);
599 const std::string msg = line.substr(line.find(':', pos3+1) + 2);
600
601 std::string locFile = Path::toNativeSeparators(std::move(filename));
602 const int line_i = strToInt<int>(linenr);
603 const int column = strToInt<unsigned int>(colnr);
604 ErrorMessage::FileLocation loc(locFile, line_i, column);
605 ErrorMessage errmsg({std::move(loc)},
606 std::move(locFile),
607 Severity::error,
608 msg,
609 "syntaxError",
610 Certainty::normal);
611
612 if (line.compare(pos3, 10, ": warning:") == 0) {
613 warnings.push_back(std::move(errmsg));
614 continue;
615 }
616
617 reportErr(errmsg);
618
619 return true;
620 }
621 return false;
622}
623
624std::string CppCheck::getLibraryDumpData() const {
625 std::string out;

Callers 1

checkClangMethod · 0.85

Calls 5

getlineFunction · 0.85
emptyMethod · 0.45
findMethod · 0.45
compareMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected