Running astlye [ci skip]

This commit is contained in:
orbitcowboy 2021-01-22 21:47:24 +01:00
parent ef6c0e6a43
commit bb451ca289
8 changed files with 44 additions and 41 deletions

View File

@ -65,8 +65,8 @@ void TestCppcheckLibraryData::podtypeValid()
QCOMPARE(libraryData.podtypes[0].sign.isEmpty(), true); QCOMPARE(libraryData.podtypes[0].sign.isEmpty(), true);
QCOMPARE(libraryData.podtypes[0].size.isEmpty(), true); QCOMPARE(libraryData.podtypes[0].size.isEmpty(), true);
QCOMPARE(libraryData.podtypes[1].name, "ulong"); QCOMPARE(libraryData.podtypes[1].name, "ulong");
QCOMPARE(libraryData.podtypes[1].stdtype, "uint32_t"); QCOMPARE(libraryData.podtypes[1].stdtype, "uint32_t");
QCOMPARE(libraryData.podtypes[1].sign, "u"); QCOMPARE(libraryData.podtypes[1].sign, "u");
QCOMPARE(libraryData.podtypes[1].size, "4"); QCOMPARE(libraryData.podtypes[1].size, "4");

View File

@ -1741,7 +1741,7 @@ void CheckStl::missingComparison()
if (!tok3) if (!tok3)
break; break;
} else if (Token::simpleMatch(tok3->astParent(), "++")) } else if (Token::simpleMatch(tok3->astParent(), "++"))
incrementToken = tok3; incrementToken = tok3;
else if (Token::simpleMatch(tok3->astParent(), "+")) { else if (Token::simpleMatch(tok3->astParent(), "+")) {
if (Token::Match(tok3->astSibling(), "%num%")) { if (Token::Match(tok3->astSibling(), "%num%")) {
const Token* tokenGrandParent = tok3->astParent()->astParent(); const Token* tokenGrandParent = tok3->astParent()->astParent();

View File

@ -21,8 +21,7 @@ struct ForwardTraversal {
bool analyzeOnly; bool analyzeOnly;
Terminate terminate = Terminate::None; Terminate terminate = Terminate::None;
Progress Break(Terminate t = Terminate::None) Progress Break(Terminate t = Terminate::None) {
{
if (!analyzeOnly && t != Terminate::None) if (!analyzeOnly && t != Terminate::None)
terminate = t; terminate = t;
return Progress::Break; return Progress::Break;
@ -225,15 +224,14 @@ struct ForwardTraversal {
ft.updateRange(start, end); ft.updateRange(start, end);
} }
std::vector<ForwardTraversal> forkScope(Token* endBlock, bool isModified = false) std::vector<ForwardTraversal> forkScope(Token* endBlock, bool isModified = false) {
{
if (analyzer->updateScope(endBlock, isModified)) { if (analyzer->updateScope(endBlock, isModified)) {
ForwardTraversal ft = *this; ForwardTraversal ft = *this;
ft.analyzer->forkScope(endBlock); ft.analyzer->forkScope(endBlock);
ft.updateRange(endBlock->link(), endBlock); ft.updateRange(endBlock->link(), endBlock);
return {ft}; return {ft};
} }
return std::vector<ForwardTraversal>{}; return std::vector<ForwardTraversal> {};
} }
static bool hasGoto(const Token* endBlock) { static bool hasGoto(const Token* endBlock) {
@ -270,8 +268,7 @@ struct ForwardTraversal {
return a; return a;
} }
void continueUpdateRangeAfterLoop(std::vector<ForwardTraversal>& ftv, Token* start, const Token* endToken) void continueUpdateRangeAfterLoop(std::vector<ForwardTraversal>& ftv, Token* start, const Token* endToken) {
{
for (ForwardTraversal& ft : ftv) { for (ForwardTraversal& ft : ftv) {
// If analysis has terminated normally, then continue analysis // If analysis has terminated normally, then continue analysis
if (ft.terminate == Terminate::None) if (ft.terminate == Terminate::None)
@ -283,8 +280,7 @@ struct ForwardTraversal {
Token* endBlock, Token* endBlock,
Token* condTok, Token* condTok,
Token* initTok = nullptr, Token* initTok = nullptr,
Token* stepTok = nullptr) Token* stepTok = nullptr) {
{
const bool isDoWhile = precedes(endBlock, condTok); const bool isDoWhile = precedes(endBlock, condTok);
Analyzer::Action bodyAnalysis = analyzeScope(endBlock); Analyzer::Action bodyAnalysis = analyzeScope(endBlock);
Analyzer::Action allAnalysis = bodyAnalysis; Analyzer::Action allAnalysis = bodyAnalysis;

View File

@ -10,7 +10,10 @@
#include <limits> #include <limits>
#include <memory> #include <memory>
void ProgramMemory::setValue(MathLib::bigint exprid, const ValueFlow::Value& value) { values[exprid] = value; } void ProgramMemory::setValue(MathLib::bigint exprid, const ValueFlow::Value& value)
{
values[exprid] = value;
}
const ValueFlow::Value* ProgramMemory::getValue(MathLib::bigint exprid) const const ValueFlow::Value* ProgramMemory::getValue(MathLib::bigint exprid) const
{ {
const ProgramMemory::Map::const_iterator it = values.find(exprid); const ProgramMemory::Map::const_iterator it = values.find(exprid);
@ -61,7 +64,10 @@ void ProgramMemory::setUnknown(MathLib::bigint exprid)
values[exprid].valueType = ValueFlow::Value::ValueType::UNINIT; values[exprid].valueType = ValueFlow::Value::ValueType::UNINIT;
} }
bool ProgramMemory::hasValue(MathLib::bigint exprid) { return values.find(exprid) != values.end(); } bool ProgramMemory::hasValue(MathLib::bigint exprid)
{
return values.find(exprid) != values.end();
}
void ProgramMemory::swap(ProgramMemory &pm) void ProgramMemory::swap(ProgramMemory &pm)
{ {

View File

@ -1310,7 +1310,9 @@ public:
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope))); return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
} }
bool isVarId(nonneg int varid) const { return varid < mVariableList.size(); } bool isVarId(nonneg int varid) const {
return varid < mVariableList.size();
}
const Variable *getVariableFromVarId(nonneg int varId) const { const Variable *getVariableFromVarId(nonneg int varId) const {
return mVariableList.at(varId); return mVariableList.at(varId);

View File

@ -128,17 +128,17 @@ void Token::update_property_info()
} }
static const std::unordered_set<std::string> stdTypes = { "bool" static const std::unordered_set<std::string> stdTypes = { "bool"
, "_Bool" , "_Bool"
, "char" , "char"
, "double" , "double"
, "float" , "float"
, "int" , "int"
, "long" , "long"
, "short" , "short"
, "size_t" , "size_t"
, "void" , "void"
, "wchar_t" , "wchar_t"
}; };
void Token::update_property_isStandardType() void Token::update_property_isStandardType()
{ {

View File

@ -563,7 +563,7 @@ void Tokenizer::simplifyUsingToTypedef()
// using a::b; => typedef a::b b; // using a::b; => typedef a::b b;
if ((Token::Match(tok, "[;{}] using %name% :: %name% ::|;") && !tok->tokAt(2)->isKeyword()) || if ((Token::Match(tok, "[;{}] using %name% :: %name% ::|;") && !tok->tokAt(2)->isKeyword()) ||
(Token::Match(tok, "[;{}] using :: %name% :: %name% ::|;") && !tok->tokAt(3)->isKeyword())) { (Token::Match(tok, "[;{}] using :: %name% :: %name% ::|;") && !tok->tokAt(3)->isKeyword())) {
Token *endtok = tok->tokAt(5); Token *endtok = tok->tokAt(5);
if (Token::Match(endtok, "%name%")) if (Token::Match(endtok, "%name%"))
endtok = endtok->next(); endtok = endtok->next();
while (Token::Match(endtok, ":: %name%")) while (Token::Match(endtok, ":: %name%"))
@ -3437,8 +3437,8 @@ void Tokenizer::setVarId()
#define NOTSTART_C "NOT", "case", "default", "goto", "not", "return", "sizeof", "typedef" #define NOTSTART_C "NOT", "case", "default", "goto", "not", "return", "sizeof", "typedef"
static const std::unordered_set<std::string> notstart_c = { NOTSTART_C }; static const std::unordered_set<std::string> notstart_c = { NOTSTART_C };
static const std::unordered_set<std::string> notstart_cpp = { NOTSTART_C, static const std::unordered_set<std::string> notstart_cpp = { NOTSTART_C,
"delete", "friend", "new", "throw", "using", "virtual", "explicit", "const_cast", "dynamic_cast", "reinterpret_cast", "static_cast", "template" "delete", "friend", "new", "throw", "using", "virtual", "explicit", "const_cast", "dynamic_cast", "reinterpret_cast", "static_cast", "template"
}; };
void Tokenizer::setVarIdPass1() void Tokenizer::setVarIdPass1()
{ {
@ -9824,15 +9824,15 @@ void Tokenizer::findGarbageCode() const
// Keywords in global scope // Keywords in global scope
static const std::unordered_set<std::string> nonGlobalKeywords{"break", static const std::unordered_set<std::string> nonGlobalKeywords{"break",
"continue", "continue",
"for", "for",
"goto", "goto",
"if", "if",
"return", "return",
"switch", "switch",
"while", "while",
"try", "try",
"catch"}; "catch"};
for (const Token *tok = tokens(); tok; tok = tok->next()) { for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (tok->str() == "{") if (tok->str() == "{")
tok = tok->link(); tok = tok->link();

View File

@ -1742,7 +1742,7 @@ static bool bifurcateVariableChanged(const Variable* var,
bool result = false; bool result = false;
const Token* tok = start; const Token* tok = start;
while ((tok = findVariableChanged( while ((tok = findVariableChanged(
tok->next(), end, var->isPointer(), var->declarationId(), var->isGlobal(), settings, true))) { tok->next(), end, var->isPointer(), var->declarationId(), var->isGlobal(), settings, true))) {
if (Token::Match(tok->astParent(), "%assign%")) { if (Token::Match(tok->astParent(), "%assign%")) {
if (!bifurcate(tok->astParent()->astOperand2(), varids, settings, depth - 1)) if (!bifurcate(tok->astParent()->astOperand2(), varids, settings, depth - 1))
return true; return true;
@ -2312,8 +2312,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
return unknown; return unknown;
} }
virtual ProgramState getProgramState() const OVERRIDE virtual ProgramState getProgramState() const OVERRIDE {
{
ProgramState ps; ProgramState ps;
ps[expr->exprId()] = value; ps[expr->exprId()] = value;
return ps; return ps;