| 583 | } |
| 584 | |
| 585 | static void writeFunction(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Function &function) |
| 586 | { |
| 587 | QString comments = function.comments; |
| 588 | while (comments.startsWith("\n")) |
| 589 | comments = comments.mid(1); |
| 590 | while (comments.endsWith("\n")) |
| 591 | comments.chop(1); |
| 592 | for (const QString &comment : comments.split('\n')) { |
| 593 | if (comment.length() >= 1) |
| 594 | xmlWriter.writeComment(comment); |
| 595 | } |
| 596 | |
| 597 | xmlWriter.writeStartElement("function"); |
| 598 | xmlWriter.writeAttribute("name", function.name); |
| 599 | |
| 600 | if (function.useretval) |
| 601 | xmlWriter.writeEmptyElement("use-retval"); |
| 602 | if (function.gccConst) |
| 603 | xmlWriter.writeEmptyElement("const"); |
| 604 | if (function.gccPure) |
| 605 | xmlWriter.writeEmptyElement("pure"); |
| 606 | if (!function.returnValue.empty()) { |
| 607 | xmlWriter.writeStartElement("returnValue"); |
| 608 | if (!function.returnValue.type.isNull()) |
| 609 | xmlWriter.writeAttribute("type", function.returnValue.type); |
| 610 | if (function.returnValue.container >= 0) |
| 611 | xmlWriter.writeAttribute("container", QString::number(function.returnValue.container)); |
| 612 | if (!function.returnValue.value.isNull()) |
| 613 | xmlWriter.writeCharacters(function.returnValue.value); |
| 614 | xmlWriter.writeEndElement(); |
| 615 | } |
| 616 | if (function.noreturn != CppcheckLibraryData::Function::Unknown) |
| 617 | xmlWriter.writeTextElement("noreturn", bool_to_string(function.noreturn == CppcheckLibraryData::Function::True)); |
| 618 | if (function.leakignore) |
| 619 | xmlWriter.writeEmptyElement("leak-ignore"); |
| 620 | // Argument info.. |
| 621 | for (const CppcheckLibraryData::Function::Arg &arg : function.args) { |
| 622 | if (arg.formatstr) { |
| 623 | xmlWriter.writeStartElement("formatstr"); |
| 624 | if (!function.formatstr.scan.isNull()) |
| 625 | xmlWriter.writeAttribute("scan", function.formatstr.scan); |
| 626 | if (!function.formatstr.secure.isNull()) |
| 627 | xmlWriter.writeAttribute("secure", function.formatstr.secure); |
| 628 | xmlWriter.writeEndElement(); |
| 629 | } |
| 630 | |
| 631 | xmlWriter.writeStartElement("arg"); |
| 632 | if (arg.nr == CppcheckLibraryData::Function::Arg::ANY) |
| 633 | xmlWriter.writeAttribute("nr", "any"); |
| 634 | else if (arg.nr == CppcheckLibraryData::Function::Arg::VARIADIC) |
| 635 | xmlWriter.writeAttribute("nr", "variadic"); |
| 636 | else |
| 637 | xmlWriter.writeAttribute("nr", QString::number(arg.nr)); |
| 638 | if (!arg.defaultValue.isNull()) |
| 639 | xmlWriter.writeAttribute("default", arg.defaultValue); |
| 640 | if (arg.formatstr) |
| 641 | xmlWriter.writeEmptyElement("formatstr"); |
| 642 | if (arg.notnull) |
no test coverage detected