Simplify code, read attribute once

This commit is contained in:
Dmitry-Me 2017-08-24 18:23:44 +03:00
parent eba9ea0ed0
commit 45996b1404
1 changed files with 16 additions and 12 deletions

View File

@ -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");
if (checkattr && std::strcmp(checkattr,"CheckUnusedFunctions")==0) {
for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) {
if (!e2->Attribute("functionName"))
continue; continue;
if (std::strcmp(e2->Name(),"functiondecl")==0 && e2->Attribute("lineNumber")) { const char *checkattr = e->Attribute("check");
decls[e2->Attribute("functionName")] = Location(sourcefile, std::atoi(e2->Attribute("lineNumber"))); if (checkattr == nullptr || std::strcmp(checkattr,"CheckUnusedFunctions") != 0)
} else if (std::strcmp(e2->Name(),"functioncall")==0) { continue;
calls.insert(e2->Attribute("functionName")); for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) {
} const char* functionName = e2->Attribute("functionName");
} if (functionName == nullptr)
continue;
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));
} }
} }
} }