Replace 'unsigned' with 'nonneg' in tokenizer
This commit is contained in:
parent
64fea0d270
commit
b15e6801a4
|
@ -350,7 +350,7 @@ void Tokenizer::unsupportedTypedef(const Token *tok) const
|
||||||
|
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
const Token *tok1 = tok;
|
const Token *tok1 = tok;
|
||||||
unsigned int level = 0;
|
int level = 0;
|
||||||
while (tok) {
|
while (tok) {
|
||||||
if (level == 0 && tok->str() == ";")
|
if (level == 0 && tok->str() == ";")
|
||||||
break;
|
break;
|
||||||
|
@ -1017,12 +1017,12 @@ void Tokenizer::simplifyTypedef()
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
std::string pattern = typeName->str();
|
std::string pattern = typeName->str();
|
||||||
unsigned int scope = 0;
|
int scope = 0;
|
||||||
bool simplifyType = false;
|
bool simplifyType = false;
|
||||||
bool inMemberFunc = false;
|
bool inMemberFunc = false;
|
||||||
int memberScope = 0;
|
int memberScope = 0;
|
||||||
bool globalScope = false;
|
bool globalScope = false;
|
||||||
std::size_t classLevel = spaceInfo.size();
|
int classLevel = spaceInfo.size();
|
||||||
|
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
||||||
if (mSettings->terminated())
|
if (mSettings->terminated())
|
||||||
|
@ -1042,7 +1042,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
--classLevel;
|
--classLevel;
|
||||||
pattern.clear();
|
pattern.clear();
|
||||||
|
|
||||||
for (std::size_t i = classLevel; i < spaceInfo.size(); ++i)
|
for (int i = classLevel; i < spaceInfo.size(); ++i)
|
||||||
pattern += (spaceInfo[i].className + " :: ");
|
pattern += (spaceInfo[i].className + " :: ");
|
||||||
|
|
||||||
pattern += typeName->str();
|
pattern += typeName->str();
|
||||||
|
@ -1094,8 +1094,8 @@ void Tokenizer::simplifyTypedef()
|
||||||
spaceInfo[classLevel].bodyEnd = tok2->link();
|
spaceInfo[classLevel].bodyEnd = tok2->link();
|
||||||
++classLevel;
|
++classLevel;
|
||||||
pattern.clear();
|
pattern.clear();
|
||||||
for (std::size_t i = classLevel; i < spaceInfo.size(); ++i)
|
for (int i = classLevel; i < spaceInfo.size(); ++i)
|
||||||
pattern += (spaceInfo[i].className + " :: ");
|
pattern += spaceInfo[i].className + " :: ";
|
||||||
|
|
||||||
pattern += typeName->str();
|
pattern += typeName->str();
|
||||||
}
|
}
|
||||||
|
@ -1136,8 +1136,8 @@ void Tokenizer::simplifyTypedef()
|
||||||
// member function class variables don't need qualification
|
// member function class variables don't need qualification
|
||||||
if (!(inMemberFunc && tok2->str() == typeName->str()) && pattern.find("::") != std::string::npos) { // has a "something ::"
|
if (!(inMemberFunc && tok2->str() == typeName->str()) && pattern.find("::") != std::string::npos) { // has a "something ::"
|
||||||
Token *start = tok2;
|
Token *start = tok2;
|
||||||
std::size_t count = 0;
|
int count = 0;
|
||||||
int back = int(classLevel) - 1;
|
int back = classLevel - 1;
|
||||||
bool good = true;
|
bool good = true;
|
||||||
// check for extra qualification
|
// check for extra qualification
|
||||||
while (back >= 0) {
|
while (back >= 0) {
|
||||||
|
@ -1171,14 +1171,14 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove qualification if present
|
// remove qualification if present
|
||||||
for (std::size_t i = classLevel; i < spaceInfo.size(); ++i) {
|
for (int i = classLevel; i < spaceInfo.size(); ++i) {
|
||||||
tok2->deleteNext(2);
|
tok2->deleteNext(2);
|
||||||
}
|
}
|
||||||
simplifyType = true;
|
simplifyType = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tok2->strAt(-1) == "::") {
|
if (tok2->strAt(-1) == "::") {
|
||||||
std::size_t relativeSpaceInfoSize = spaceInfo.size();
|
int relativeSpaceInfoSize = spaceInfo.size();
|
||||||
Token * tokBeforeType = tok2->previous();
|
Token * tokBeforeType = tok2->previous();
|
||||||
while (relativeSpaceInfoSize != 0 &&
|
while (relativeSpaceInfoSize != 0 &&
|
||||||
tokBeforeType && tokBeforeType->str() == "::" &&
|
tokBeforeType && tokBeforeType->str() == "::" &&
|
||||||
|
@ -1289,7 +1289,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = classLevel; i < spaceInfo.size(); ++i) {
|
for (int i = classLevel; i < spaceInfo.size(); ++i) {
|
||||||
tok2->insertToken(spaceInfo[i].className);
|
tok2->insertToken(spaceInfo[i].className);
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
tok2->insertToken("::");
|
tok2->insertToken("::");
|
||||||
|
@ -1758,7 +1758,7 @@ namespace {
|
||||||
|
|
||||||
Token *findSemicolon(Token *tok)
|
Token *findSemicolon(Token *tok)
|
||||||
{
|
{
|
||||||
unsigned int level = 0;
|
int level = 0;
|
||||||
|
|
||||||
for (; tok && (level > 0 || tok->str() != ";"); tok = tok->next()) {
|
for (; tok && (level > 0 || tok->str() != ";"); tok = tok->next()) {
|
||||||
if (tok->str() == "{")
|
if (tok->str() == "{")
|
||||||
|
@ -2202,7 +2202,7 @@ void Tokenizer::simplifyMulAndParens()
|
||||||
if (!tok->isName())
|
if (!tok->isName())
|
||||||
continue;
|
continue;
|
||||||
//fix ticket #2784 - improved by ticket #3184
|
//fix ticket #2784 - improved by ticket #3184
|
||||||
unsigned int closedPars = 0;
|
int closedPars = 0;
|
||||||
Token *tokend = tok->next();
|
Token *tokend = tok->next();
|
||||||
Token *tokbegin = tok->previous();
|
Token *tokbegin = tok->previous();
|
||||||
while (tokend && tokend->str() == ")") {
|
while (tokend && tokend->str() == ")") {
|
||||||
|
@ -2233,7 +2233,7 @@ void Tokenizer::simplifyMulAndParens()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//find consecutive opening parentheses
|
//find consecutive opening parentheses
|
||||||
unsigned int openPars = 0;
|
int openPars = 0;
|
||||||
while (tokbegin && tokbegin->str() == "(" && openPars <= closedPars) {
|
while (tokbegin && tokbegin->str() == "(" && openPars <= closedPars) {
|
||||||
++openPars;
|
++openPars;
|
||||||
tokbegin = tokbegin->previous();
|
tokbegin = tokbegin->previous();
|
||||||
|
@ -2647,7 +2647,7 @@ void Tokenizer::arraySize()
|
||||||
|
|
||||||
if (addlength || Token::Match(tok, "%var% [ ] = %str% ;")) {
|
if (addlength || Token::Match(tok, "%var% [ ] = %str% ;")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
const std::size_t sz = Token::getStrSize(tok->tokAt(3));
|
const int sz = Token::getStrSize(tok->tokAt(3));
|
||||||
tok->insertToken(MathLib::toString(sz));
|
tok->insertToken(MathLib::toString(sz));
|
||||||
tok = tok->tokAt(5);
|
tok = tok->tokAt(5);
|
||||||
}
|
}
|
||||||
|
@ -3974,7 +3974,7 @@ bool Tokenizer::simplifySizeof()
|
||||||
const MathLib::bigint num = MathLib::toLongNumber(tok2->strAt(1));
|
const MathLib::bigint num = MathLib::toLongNumber(tok2->strAt(1));
|
||||||
if (num<0)
|
if (num<0)
|
||||||
break;
|
break;
|
||||||
size *= (unsigned)num;
|
size *= num;
|
||||||
tok2 = tok2->tokAt(3);
|
tok2 = tok2->tokAt(3);
|
||||||
} while (Token::Match(tok2, "[ %num% ]"));
|
} while (Token::Match(tok2, "[ %num% ]"));
|
||||||
if (Token::Match(tok2, "[;=]")) {
|
if (Token::Match(tok2, "[;=]")) {
|
||||||
|
@ -6656,7 +6656,7 @@ void Tokenizer::simplifyStaticConst()
|
||||||
// move 'static' before all other qualifiers and types, ...
|
// move 'static' before all other qualifiers and types, ...
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
bool continue2 = false;
|
bool continue2 = false;
|
||||||
for (size_t i = 0; i < sizeof(qualifiers)/sizeof(qualifiers[0]); i++) {
|
for (int i = 0; i < sizeof(qualifiers)/sizeof(qualifiers[0]); i++) {
|
||||||
|
|
||||||
// Keep searching for a qualifier
|
// Keep searching for a qualifier
|
||||||
if (!tok->next() || tok->next()->str() != qualifiers[i])
|
if (!tok->next() || tok->next()->str() != qualifiers[i])
|
||||||
|
@ -6666,7 +6666,7 @@ void Tokenizer::simplifyStaticConst()
|
||||||
Token* leftTok = tok;
|
Token* leftTok = tok;
|
||||||
bool behindOther = false;
|
bool behindOther = false;
|
||||||
for (; leftTok; leftTok = leftTok->previous()) {
|
for (; leftTok; leftTok = leftTok->previous()) {
|
||||||
for (size_t j = 0; j <= i; j++) {
|
for (int j = 0; j <= i; j++) {
|
||||||
if (leftTok->str() == qualifiers[j]) {
|
if (leftTok->str() == qualifiers[j]) {
|
||||||
behindOther = true;
|
behindOther = true;
|
||||||
break;
|
break;
|
||||||
|
@ -8945,7 +8945,7 @@ void Tokenizer::simplifyComma()
|
||||||
if (!startFrom)
|
if (!startFrom)
|
||||||
// to be very sure...
|
// to be very sure...
|
||||||
return;
|
return;
|
||||||
std::size_t commaCounter = 0;
|
int commaCounter = 0;
|
||||||
for (Token *tok2 = startFrom->next(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = startFrom->next(); tok2; tok2 = tok2->next()) {
|
||||||
if (tok2->str() == ";") {
|
if (tok2->str() == ";") {
|
||||||
endAt = tok2;
|
endAt = tok2;
|
||||||
|
@ -10817,7 +10817,7 @@ void Tokenizer::simplifyReturnStrncat()
|
||||||
Token *tok2 = tok->tokAt(3);
|
Token *tok2 = tok->tokAt(3);
|
||||||
|
|
||||||
//check if there are at least three arguments
|
//check if there are at least three arguments
|
||||||
for (unsigned char i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
tok2 = tok2->nextArgument();
|
tok2 = tok2->nextArgument();
|
||||||
if (!tok2) {
|
if (!tok2) {
|
||||||
tok = tok->linkAt(2)->next();
|
tok = tok->linkAt(2)->next();
|
||||||
|
@ -10912,7 +10912,7 @@ void Tokenizer::printUnknownTypes() const
|
||||||
|
|
||||||
if (!unknowns.empty()) {
|
if (!unknowns.empty()) {
|
||||||
std::string last;
|
std::string last;
|
||||||
size_t count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (std::multimap<std::string, const Token *>::const_iterator it = unknowns.begin(); it != unknowns.end(); ++it) {
|
for (std::multimap<std::string, const Token *>::const_iterator it = unknowns.begin(); it != unknowns.end(); ++it) {
|
||||||
// skip types is std namespace because they are not interesting
|
// skip types is std namespace because they are not interesting
|
||||||
|
|
Loading…
Reference in New Issue