parent
39c5274742
commit
fbf63b932e
|
@ -329,20 +329,17 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
QXmlStreamReader::TokenType type;
|
||||
if (xmlReader.attributes().hasAttribute("ext")) {
|
||||
markup.ext = xmlReader.attributes().value("ext").toString();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mandatoryAttibuteMissing(xmlReader, "ext");
|
||||
}
|
||||
if (xmlReader.attributes().hasAttribute("aftercode")) {
|
||||
markup.afterCode = (xmlReader.attributes().value("aftercode") == "true") ? true : false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mandatoryAttibuteMissing(xmlReader, "aftercode");
|
||||
}
|
||||
if (xmlReader.attributes().hasAttribute("reporterrors")) {
|
||||
markup.reportErrors = (xmlReader.attributes().value("reporterrors") == "true") ? true : false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mandatoryAttibuteMissing(xmlReader, "reporterrors");
|
||||
}
|
||||
|
||||
|
@ -358,8 +355,7 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
continue;
|
||||
if (xmlReader.name().toString() == "keyword") {
|
||||
markup.keywords.append(xmlReader.attributes().value("name").toString());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unhandledElement(xmlReader);
|
||||
}
|
||||
}
|
||||
|
@ -372,13 +368,11 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
continue;
|
||||
if (xmlReader.name().toString() == "block") {
|
||||
codeBlock.blocks.append(xmlReader.attributes().value("name").toString());
|
||||
}
|
||||
else if (xmlReader.name().toString() == "structure") {
|
||||
} else if (xmlReader.name().toString() == "structure") {
|
||||
codeBlock.offset = xmlReader.attributes().value("offset").toInt();
|
||||
codeBlock.start = xmlReader.attributes().value("start").toString();
|
||||
codeBlock.end = xmlReader.attributes().value("end").toString();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unhandledElement(xmlReader);
|
||||
}
|
||||
}
|
||||
|
@ -392,14 +386,11 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
continue;
|
||||
if (xmlReader.name().toString() == "exporter") {
|
||||
exporter.prefix = xmlReader.attributes().value("prefix").toString();
|
||||
}
|
||||
else if (xmlReader.name().toString() == "prefix") {
|
||||
} else if (xmlReader.name().toString() == "prefix") {
|
||||
exporter.prefixList.append(xmlReader.readElementText());
|
||||
}
|
||||
else if (xmlReader.name().toString() == "suffix") {
|
||||
} else if (xmlReader.name().toString() == "suffix") {
|
||||
exporter.suffixList.append(xmlReader.readElementText());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unhandledElement(xmlReader);
|
||||
}
|
||||
}
|
||||
|
@ -411,8 +402,7 @@ static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
|
|||
continue;
|
||||
if (xmlReader.name().toString() == "importer") {
|
||||
markup.importer.append(xmlReader.readElementText());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unhandledElement(xmlReader);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ void TestCppcheckLibraryData::markupValid()
|
|||
QCOMPARE(libraryData.markups[0].afterCode, true);
|
||||
|
||||
QCOMPARE(libraryData.markups[0].keywords.size(), 4);
|
||||
QCOMPARE(libraryData.markups[0].keywords, QStringList( {"if", "while", "typeof", "for"} ));
|
||||
QCOMPARE(libraryData.markups[0].keywords, QStringList({"if", "while", "typeof", "for"}));
|
||||
|
||||
QCOMPARE(libraryData.markups[0].importer.size(), 1);
|
||||
QCOMPARE(libraryData.markups[0].importer, QStringList("connect"));
|
||||
|
@ -491,11 +491,11 @@ void TestCppcheckLibraryData::markupValid()
|
|||
QCOMPARE(libraryData.markups[0].exporter[0].suffixList.size(), 1);
|
||||
QCOMPARE(libraryData.markups[0].exporter[0].suffixList, QStringList("READ"));
|
||||
QCOMPARE(libraryData.markups[0].exporter[0].prefixList.size(), 3);
|
||||
QCOMPARE(libraryData.markups[0].exporter[0].prefixList, QStringList( {"READ", "WRITE", "NOTIFY"} ));
|
||||
QCOMPARE(libraryData.markups[0].exporter[0].prefixList, QStringList({"READ", "WRITE", "NOTIFY"}));
|
||||
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks.size(), 2);
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].blocks.size(), 5);
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].blocks, QStringList( {"onClicked", "onFinished", "onTriggered", "onPressed", "onTouch"} ));
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].blocks, QStringList({"onClicked", "onFinished", "onTriggered", "onPressed", "onTouch"}));
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].offset, 3);
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].start, "{");
|
||||
QCOMPARE(libraryData.markups[0].codeBlocks[0].end, "}");
|
||||
|
|
|
@ -755,13 +755,12 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
|
|||
std::vector<ReferenceToken> followAllReferences(const Token* tok, bool inconclusive, ErrorPath errors, int depth)
|
||||
{
|
||||
struct ReferenceTokenLess {
|
||||
bool operator()(const ReferenceToken& x, const ReferenceToken& y) const
|
||||
{
|
||||
bool operator()(const ReferenceToken& x, const ReferenceToken& y) const {
|
||||
return x.token < y.token;
|
||||
}
|
||||
};
|
||||
if (!tok)
|
||||
return std::vector<ReferenceToken>{};
|
||||
return std::vector<ReferenceToken> {};
|
||||
if (depth < 0)
|
||||
return {{tok, std::move(errors)}};
|
||||
const Variable *var = tok->variable();
|
||||
|
@ -811,7 +810,7 @@ std::vector<ReferenceToken> followAllReferences(const Token* tok, bool inconclus
|
|||
if (returnTok == tok)
|
||||
continue;
|
||||
std::vector<ReferenceToken> argvarRt = followAllReferences(returnTok, inconclusive, errors, depth - 1);
|
||||
for(const ReferenceToken& rt:followAllReferences(returnTok, inconclusive, errors, depth - 1)) {
|
||||
for (const ReferenceToken& rt:followAllReferences(returnTok, inconclusive, errors, depth - 1)) {
|
||||
const Variable* argvar = rt.token->variable();
|
||||
if (!argvar)
|
||||
return {{tok, std::move(errors)}};
|
||||
|
|
|
@ -2845,7 +2845,9 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
|
|||
// the full definition must be compared
|
||||
bool fullDefinition = std::all_of(classScope->functionList.begin(),
|
||||
classScope->functionList.end(),
|
||||
[](const Function& f) { return f.hasBody(); });
|
||||
[](const Function& f) {
|
||||
return f.hasBody();
|
||||
});
|
||||
if (!fullDefinition)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -584,7 +584,6 @@ void execute(const Token *expr,
|
|||
*result = 0;
|
||||
else
|
||||
*error = true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
*error = true;
|
||||
}
|
||||
|
|
|
@ -2001,8 +2001,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
|||
return isModified(tok);
|
||||
}
|
||||
|
||||
Action analyzeToken(const Token* ref, const Token* tok, Direction d, bool inconclusiveRef) const
|
||||
{
|
||||
Action analyzeToken(const Token* ref, const Token* tok, Direction d, bool inconclusiveRef) const {
|
||||
if (!ref)
|
||||
return Action::None;
|
||||
// If its an inconclusiveRef then ref != tok
|
||||
|
@ -2054,7 +2053,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
|||
// Follow references
|
||||
std::vector<ReferenceToken> refs = followAllReferences(tok);
|
||||
const bool inconclusiveRefs = refs.size() != 1;
|
||||
for(const ReferenceToken& ref:refs) {
|
||||
for (const ReferenceToken& ref:refs) {
|
||||
Action a = analyzeToken(ref.token, tok, d, inconclusiveRefs);
|
||||
if (a != Action::None)
|
||||
return a;
|
||||
|
|
|
@ -5038,18 +5038,18 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfXKnown(code, 4U, 0));
|
||||
|
||||
code = "bool f(std::string s) {\n"
|
||||
" if (!s.empty()) {\n"
|
||||
" bool x = s == \"0\";\n"
|
||||
" return x;\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 0));
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 1));
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
||||
code = "bool f(std::string s) {\n"
|
||||
" if (!s.empty()) {\n"
|
||||
" bool x = s == \"0\";\n"
|
||||
" return x;\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 0));
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 1));
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
||||
|
||||
code = "bool f() {\n"
|
||||
code = "bool f() {\n"
|
||||
" std::list<int> x1;\n"
|
||||
" std::list<int> x2;\n"
|
||||
" for (int i = 0; i < 10; ++i) {\n"
|
||||
|
|
Loading…
Reference in New Issue