Simplify code, read attribute once
This commit is contained in:
parent
eba9ea0ed0
commit
45996b1404
|
@ -353,18 +353,22 @@ void CheckUnusedFunctions::analyseWholeProgram(ErrorLogger * const errorLogger,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) {
|
for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) {
|
||||||
if (std::strcmp(e->Name(), "FileInfo") == 0) {
|
if (std::strcmp(e->Name(), "FileInfo") != 0)
|
||||||
const char *checkattr = e->Attribute("check");
|
continue;
|
||||||
if (checkattr && std::strcmp(checkattr,"CheckUnusedFunctions")==0) {
|
const char *checkattr = e->Attribute("check");
|
||||||
for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) {
|
if (checkattr == nullptr || std::strcmp(checkattr,"CheckUnusedFunctions") != 0)
|
||||||
if (!e2->Attribute("functionName"))
|
continue;
|
||||||
continue;
|
for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) {
|
||||||
if (std::strcmp(e2->Name(),"functiondecl")==0 && e2->Attribute("lineNumber")) {
|
const char* functionName = e2->Attribute("functionName");
|
||||||
decls[e2->Attribute("functionName")] = Location(sourcefile, std::atoi(e2->Attribute("lineNumber")));
|
if (functionName == nullptr)
|
||||||
} else if (std::strcmp(e2->Name(),"functioncall")==0) {
|
continue;
|
||||||
calls.insert(e2->Attribute("functionName"));
|
if (std::strcmp(e2->Name(),"functioncall") == 0) {
|
||||||
}
|
calls.insert(functionName);
|
||||||
}
|
continue;
|
||||||
|
} else if (std::strcmp(e2->Name(),"functiondecl") == 0) {
|
||||||
|
const char* lineNumber = e2->Attribute("lineNumber");
|
||||||
|
if (lineNumber)
|
||||||
|
decls[functionName] = Location(sourcefile, std::atoi(lineNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue