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

Function loadFunction

gui/cppchecklibrarydata.cpp:199–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, const QString &comments)
200{
201 CppcheckLibraryData::Function function;
202 function.comments = comments;
203 function.name = xmlReader.attributes().value("name").toString();
204 QXmlStreamReader::TokenType type;
205 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
206 xmlReader.name().toString() != "function") {
207 if (type != QXmlStreamReader::StartElement)
208 continue;
209 const QString elementName = xmlReader.name().toString();
210 if (elementName == "noreturn")
211 function.noreturn = (xmlReader.readElementText() == "true") ? CppcheckLibraryData::Function::True : CppcheckLibraryData::Function::False;
212 else if (elementName == "pure")
213 function.gccPure = true;
214 else if (elementName == "const")
215 function.gccConst = true;
216 else if (elementName == "leak-ignore")
217 function.leakignore = true;
218 else if (elementName == "use-retval")
219 function.useretval = true;
220 else if (elementName == "returnValue") {
221 const QString container = xmlReader.attributes().value("container").toString();
222 function.returnValue.container = container.isNull() ? -1 : container.toInt();
223 function.returnValue.type = xmlReader.attributes().value("type").toString();
224 function.returnValue.value = xmlReader.readElementText();
225 } else if (elementName == "formatstr") {
226 function.formatstr.scan = xmlReader.attributes().value("scan").toString();
227 function.formatstr.secure = xmlReader.attributes().value("secure").toString();
228 } else if (elementName == "arg")
229 function.args.append(loadFunctionArg(xmlReader));
230 else if (elementName == "warn") {
231 function.warn.severity = xmlReader.attributes().value("severity").toString();
232 function.warn.cstd = xmlReader.attributes().value("cstd").toString();
233 function.warn.reason = xmlReader.attributes().value("reason").toString();
234 function.warn.alternatives = xmlReader.attributes().value("alternatives").toString();
235 function.warn.msg = xmlReader.readElementText();
236 } else if (elementName == "not-overlapping-data") {
237 const QStringList attributeList {"ptr1-arg", "ptr2-arg", "size-arg", "strlen-arg"};
238 for (const QString &attr : attributeList) {
239 if (xmlReader.attributes().hasAttribute(attr)) {
240 function.notOverlappingDataArgs[attr] = xmlReader.attributes().value(attr).toString();
241 }
242 }
243 } else if (elementName == "container") {
244 const QStringList attributeList {"action", "yields"};
245 for (const QString &attr : attributeList) {
246 if (xmlReader.attributes().hasAttribute(attr)) {
247 function.containerAttributes[attr] = xmlReader.attributes().value(attr).toString();
248 }
249 }
250 } else {
251 unhandledElement(xmlReader);
252 }
253 }
254 return function;
255}
256

Callers 2

loadMethod · 0.85
openMethod · 0.85

Calls 5

loadFunctionArgFunction · 0.85
unhandledElementFunction · 0.85
toStringMethod · 0.45
valueMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected